0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SVG 簡単なanimate

Posted at

gif.gif

circleタグのr(半径)を20から80に2秒かけてアニメーション。
animateタグ内に記述。
おまけでjsでアクセスもしてみる

hoge.html
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>polylineとpolygon</title>
</head>
<body>
	<svg width="500" height="500" onload="
		var c = document.getElementById('circle');

		// 0.5秒間隔で色変更
		setInterval(setRandColor, 500);
		
		// ランダムな色設定
		function setRandColor(){
		    var randColorArr = ['orange', 'blue', 'pink', 'red', 'aqua'];
			var random = randColorArr[Math.floor(Math.random() * randColorArr.length)];
			c.setAttribute('fill',random);
		}

	">

	  <!-- r半径を20から80に2秒かけてアニメーション -->
	  <circle id="circle" cx="100" cy="100" r="20" fill="pink">
	  	<animate attributeName="r" from="20" to="80" dur="2s" repeatCount="indefinite"/>
	  </circle>


 	</svg>
</body>
</html>

svgタグのonload属性にJsをかけるらしい。
それでプロパティにアクセスしていじるの可能。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?