brython svg
from browser import document, svg, timer
rect = svg.rect(x=10, y=10, width=100, height=100)
def move_rect():
# the attributes of the SVG element are strings, they must be explicitely
# converted into integers
rect.attrs["y"] = int(rect.attrs["y"]) + 1
# ends animation when the rectangle reaches its target
if int(rect.attrs["y"] ) > 50:
timer.clear_interval(loop)
panel = document['panel5']
panel <= rect
# initialise the animation loop
loop = timer.set_interval(move_rect, 30)
4.33
9
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="140" height="200" style="border-style:solid;border-width:1;border-color:#000;">
<g id="panel">
</g>
</svg>
Thank you!
9
0
4.2
10
from browser import document, svg
star = svg.polygon(fill="red", stroke="blue", stroke_width="10",
points=""" 75,38 90,80 135,80 98,107
111,150 75,125 38,150 51,107
15,80 60,80""")
panel = document['panel4']
panel <= star
Thank you!
10
0
4
2
from browser import document, svg
title = svg.text('Title', x=70, y=25, font_size=22,
text_anchor="middle")
circle = svg.circle(cx=70, cy=120, r=40,
stroke="black",stroke_width="2",fill="red")
panel = document['panel']
panel <= title
panel <= circle
Thank you!
2
0
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line