Replies: 1 comment
-
Unfortunately, Inkscape extensions can't render animations like you'd hope. Modifications to the image are applied all at once and only if the extension returns a success code. That's why in your first script, you see nothing on the canvas: the final canvas state at the end of the script, which happened to take 5s to run, has no new rectangles on it. By the same logic, the final canvas state at the end of your second script, which also takes 5s to run, has two new rectangles on it. In other words, no reordering is occurring; the canvas simply is not updating in real time. Let me instead recommend using Simple Inkscape Scripting's Here's how I'd make the rectangles disappear after five seconds: r1 = rect((0, 0), (200, 100), fill='#FF7F2A', opacity=1)
r2 = rect((18, 33), (18+30, 33+30), fill='#C8B7B7', opacity=1)
invisible = rect((0, 0), (1, 1), opacity=0)
anim_params = {
'duration': '5s',
'key_times': [0.0, 1.0],
'attr_filter': lambda a: a == 'opacity',
'interpolation': 'discrete',
}
r1.animate(invisible, **anim_params)
r2.animate(invisible, **anim_params) By way of explanation,
I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I enjoy using SimpInkScr a lot and lately I was trying the following, which unfortunately did not work as expected:
I draw two rectangles, wait for 5 seconds and then remove all objects. I would like to make small animations. However,
time.sleep()
somehow executes not in the correct order:I do not see anything on the canvas, when running the above code. Probably, because the two rectangles are drawn, removed and then the script is sleeping for 5 seconds. However, I would like to actually see the two rectangles for 5 seconds and then remove them.
Everything works as expected though, when starting with the sleep call:
Does anybody have an idea why
time.sleep()
seems to be executed in an arbitrary order and is there another way to pause / stop the script for a given period of time?Any help or ideas are highly appreciated :).
Beta Was this translation helpful? Give feedback.
All reactions