SMIL ã«ãã SVG ã¢ãã¡ã¼ã·ã§ã³
SMIL (Synchronized Multimedia Integration Language) ã¯ã対話åãã«ãã¡ãã£ã¢ãã¬ã¼ã³ãã¼ã·ã§ã³ã使ããããã® XML ãã¼ã¹ã®è¨èªã§ãã å¶ä½è ã¯ãä»ã® XML ãã¼ã¹ã®è¨èªã§ SMIL æ§æã使ç¨ãã¦ãã¢ãã¡ã¼ã·ã§ã³ã®è¦ç´ ã®ã¿ã¤ãã³ã°ãã¬ã¤ã¢ã¦ããå®ç¾©ãããã¨ãã§ãã¾ãã
SMIL ã§ã¯æ¬¡ã®ãããªãã¨ãã§ãã¾ãã
- è¦ç´ ã®æ°å¤å±æ§ï¼xãy ãªã©ï¼ã®ã¢ãã¡ã¼ã·ã§ã³
- transform 屿§ï¼translationãrotateããªã©ï¼ã®ã¢ãã¡ã¼ã·ã§ã³
- color 屿§ã®ã¢ãã¡ã¼ã·ã§ã³
- ã¢ã¼ã·ã§ã³ãã¹ã®è¿½è·¡
次ã®ç¯ã§ã¯ããããã® 4 ã¤ã®ç¨éã§ SVG ã«ãã㦠SMIL ã使ç¨ããæ¹æ³ã示ãã¾ãã
è¦ç´ ã®å±æ§ã®ã¢ãã¡ã¼ã·ã§ã³
以ä¸ã®ä¾ã¯ãå (circle) ã® cx 屿§ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ãã¾ãããã®ããã«ã<circle> è¦ç´ ã®å
é¨ã« <animate> è¦ç´ ã追å ãã¾ãã<animate> ã®éè¦ãªå±æ§ã¯ä»¥ä¸ã®ã¨ããã§ãã
attributeName-
ã¢ãã¡ã¼ã·ã§ã³ãè¡ã屿§å
from-
屿§ã®åæç¶æ ã®å¤
to-
屿§ã®æå¾ã®å¤
dur-
ã¢ãã¡ã¼ã·ã§ã³ãè¡ãæéï¼ä¾ãã°ã5 ç§ã®å ´å㯠'5s' ã¨æ¸ãï¼
åãè¦ç´ ã§ããå¤ãã®å±æ§ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ãããå ´åã¯ã<animate> è¦ç´ ã追å ãã¦ãã ããã
<svg width="300" height="100">
<title>SMIL ã«ãã屿§ã®ã¢ãã¡ã¼ã·ã§ã³</title>
<rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
<circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
<animate
attributeName="cx"
from="0"
to="500"
dur="5s"
repeatCount="indefinite" />
</circle>
</svg>
transform 屿§ã®ã¢ãã¡ã¼ã·ã§ã³
<animateTransform> è¦ç´ ã«ããã transform 屿§ã®ã¢ãã¡ã¼ã·ã§ã³ãã§ãã¾ããæ°å¤ãã¨ã x ã®ãããªãåç´ãªå±æ§ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ãã®ã§ã¯ãªãããããã®æ°ããè¦ç´ ãå¿
è¦ã§ãã rotation 屿§ã¯ rotation(theta, x, y) ã®ããã«ãªãã¾ããããã§ theta ã¯è§åº¦ãx ããã³ y ã¯çµ¶å¯¾ä½ç½®ã示ãã¾ãã以ä¸ã®ä¾ã§ã¯ãå転ã®ä¸å¿ä½ç½®ã¨è§åº¦ã®ã¢ãã¡ã¼ã·ã§ã³ãè¡ãã¾ãã
<svg width="300" height="100">
<title>transform ã«ãã SVG SMIL ã¢ãã¡ã¼ã·ã§ã³</title>
<rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
<rect
x="0"
y="50"
width="15"
height="34"
fill="blue"
stroke="black"
stroke-width="1">
<animateTransform
attributeName="transform"
begin="0s"
dur="20s"
type="rotate"
from="0 60 60"
to="360 100 60"
repeatCount="indefinite" />
</rect>
</svg>
ãã¹ã追跡ããã¢ãã¡ã¼ã·ã§ã³
The <animateMotion> è¦ç´ ã¯ããã¹ã«å¾ã£ã SVG è¦ç´ ã®ä½ç½®ãå転ã®ã¢ãã¡ã¼ã·ã§ã³ãå¯è½ã«ãã¾ãããã¹ã¯ <path> ã¨åãæ¹æ³ã§å®ç¾©ããã¾ãããªãã¸ã§ã¯ãããã¹ã®æ¥ç·ã«æ²¿ã£ã¦å転ããããå®ç¾©ãã屿§ãè¨å®ãããã¨ãã§ãã¾ãã
ä¾ 1: ç´ç·çãªç§»å
ãã®ä¾ã§ã¯ãéãå (circle) ãé»ãåè§å½¢ã®å·¦ç«¯ã¨å³ç«¯ããã¦ã³ãããããã«ãç¡éã«è¡ãæ¥ãã¾ãããã®ã¢ãã¡ã¼ã·ã§ã³ã¯ <animateMotion> è¦ç´ ã§å¶å¾¡ããã¾ããããã§ã¯ãã¢ãã¡ã¼ã·ã§ã³ã®å§ç¹ãå®ç¾©ãã MoveTo ã³ãã³ããåã 300 ãã¯ã»ã«å³ã¸ç§»åãã Horizontal-line ã³ãã³ããããã¦ãã¹ãéãã¦å§ç¹ã¸æ»ããã¨ãå®ç¾©ãã Z ã³ãã³ãã§æ§æããããã¹ãæå®ãã¦ãã¾ããrepeatCount 屿§ã®å¤ã indefinite ã«ãããã¨ã§ãSVG ç»åãåå¨ããéã¯æ°¸ä¹
ã«ã¢ãã¡ã¼ã·ã§ã³ãç¹°ãè¿ãããæå®ãã¾ãã
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="100">
<title>SVG SMIL Animate with Path</title>
<rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
<circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
<animateMotion path="M 0 0 H 300 Z" dur="3s" repeatCount="indefinite" />
</circle>
</svg>
ä¾ 2: æ²ç·ç¶ã®ç§»å
åã¨åæ§ã®ä¾ããæ²ç·ç¶ã®ãã¹ãç¨ããã¾ããã¹ã®æ¹åã«å¾ãå転ããããã«ãããã®ã§ãã
<svg width="300" height="100">
<title>ãã¹ã«ãã SVG SMIL ã¢ãã¡ã¼ã·ã§ã³</title>
<rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
<rect
x="0"
y="0"
width="20"
height="20"
fill="blue"
stroke="black"
stroke-width="1">
<animateMotion
path="M 250,80 H 50 Q 30,80 30,50 Q 30,20 50,20 H 250 Q 280,20,280,50 Q 280,80,250,80Z"
dur="3s"
repeatCount="indefinite"
rotate="auto" />
</rect>
</svg>
é¢é£æ å ±
- SVG
- SVG ã¢ãã¡ã¼ã·ã§ã³ä»æ§æ¸ï¼è±èªï¼
- SMIL 仿§æ¸ï¼è±èªï¼