In [1]:
from IPython.display import HTML
In [2]:
HTML("""
<html>
<body>
<h3>Move Circle</h3>
<svg width="500" height="100">
<circle r="30" cx="50" cy="50" fill="orange">
</circle>
</svg>
</body>
</html>
""")
Out[2]:
In [3]:
HTML("""
<html>
<body>
<h3>Animate Circle</h3>
<svg width="500" height="100">
<circle r="30" cx="50" cy="50" fill="orange">
<animate
attributeName="cx"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze" />
</circle>
</svg>
</body>
</html>
""")
Out[3]:
In [4]:
HTML("""
<html>
<body>
<h3>Move Circle</h3>
<svg width="500" height="500">
<circle r="30" cx="50" cy="50" fill="orange">
<animate
attributeName="cy"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze" />
</circle>
</svg>
</body>
</html>
""")
Out[4]:
In [5]:
HTML("""
<html>
<body>
<h3>Move Circle</h3>
<svg width="500" height="500">
<circle r="30" cx="50" cy="50" fill="orange">
<animate
attributeName="cx"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze" />
</circle>
<circle r="30" cx="150" cy="150" fill="green">
<animate
attributeName="cx"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze" />
</circle>
</svg>
</body>
</html>
""")
Out[5]:
In [6]:
HTML("""
<html>
<body>
<h3>Move Circle</h3>
<svg width="500" height="500">
<circle r="30" cx="50" cy="50" fill="orange">
<animate
attributeName="cx"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze" repeatCount="indefinite" />
</circle>
<circle r="30" cx="150" cy="150" fill="green">
<animate
attributeName="cx"
from="50"
to="450"
dur="1s"
begin="click"
fill="freeze"
/>
</circle>
</svg>
</body>
</html>
""")
Out[6]:
In [7]:
HTML("""
<html>
<body>
<h3>Move Circle</h3>
<svg viewBox="0 0 10 10" width = "200" height = "100">
<rect width="10" height="10">
<animate attributeName="rx" values="0;5;0" dur="10s" repeatCount="indefinite" />
</rect>
</svg>
</body>
</html>
""")
Out[7]:
In [ ]:
In [8]:
HTML("""
<html>
<body>
<svg viewBox="0 0 200 100" width="500" height="200">
<path id="path1" fill="none" stroke="lightgrey"
d="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />
<circle r="5" fill="red">
<animateMotion dur="10s" repeatCount="indefinite"
path="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />
</circle>
</svg>
</body>
</html>
""")
Out[8]:
In [ ]:
In [ ]:
In [9]:
HTML("""
<html>
<body>
<svg viewBox="0,0 10,10" width="200px" height="200px">
<path
id="theMotionPath"
fill="none"
stroke="lightgrey"
stroke-width="0.25"
d="
M 5 5
m -4, 0
a 4,4 0 1,0 8,0
"
/>
</svg>
</body>
</html>
""")
Out[9]:
In [10]:
HTML("""
<html>
<body>
<svg viewBox="0,0 10,10" width="200px" height="200px">
<path
id="theMotionPath"
fill="none"
stroke="lightgrey"
stroke-width="0.25"
d="
M 5 5
m -4, 0
a 4,4 0 1,0 8,0
a 4,4 0 1,0 -8,0
"
/>
</svg>
</body>
</html>
""")
Out[10]:
In [11]:
HTML("""
<html>
<body>
<h3>Draw polygon</h3>
<svg viewBox="0,0 10,10" width="200px" height="200px">
<path
id="theMotionPath"
fill="none"
stroke="lightgrey"
stroke-width="0.25"
d="
M 5 5
m -4, 0
a 4,4 0 1,0 8,0
a 4,4 0 1,0 -8,0
"
/>
<circle r="1" fill="red">
</circle>
</svg>
</body>
</html>
""")
Out[11]:
The SVG
In [12]:
HTML("""
<html>
<body>
<h3>Draw polygon</h3>
<svg viewBox="0,0 10,10" width="200px" height="200px">
<path
id="theMotionPath"
fill="none"
stroke="lightgrey"
stroke-width="0.25"
d="
M 5 5
m -4, 0
a 4,4 0 1,0 8,0
a 4,4 0 1,0 -8,0
"
/>
<circle r="1" fill="red">
<animateMotion dur="5s" repeatCount="indefinite">
</animateMotion>
</circle>
</svg>
</body>
</html>
""")
Out[12]:
In [13]:
HTML("""
<html>
<body>
<h3>Draw polygon</h3>
<svg viewBox="0,0 10,10" width="200px" height="200px">
<path
id="theMotionPath"
fill="none"
stroke="lightgrey"
stroke-width="0.25"
d="
M 5 5
m -4, 0
a 4,4 0 1,0 8,0
a 4,4 0 1,0 -8,0
"
/>
<circle r="1" fill="red">
<animateMotion dur="5s" repeatCount="indefinite">
<mpath xlink:href="#theMotionPath" />
</animateMotion>
</circle>
</svg>
</body>
</html>
""")
Out[13]: