<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SVG | ウダ2Blog</title>
	<atom:link href="https://uda2.com/blog/tag/svg/feed/" rel="self" type="application/rss+xml" />
	<link>https://uda2.com/blog</link>
	<description>大阪でフリーランスとしてWEB制作している管理人が気になった技術をメモったり、作ったツールの紹介などを綴っているブログです。</description>
	<lastBuildDate>Fri, 07 Jul 2023 07:03:01 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>SVGのリンク機能で集中線を描く</title>
		<link>https://uda2.com/blog/sunlightsvg/</link>
					<comments>https://uda2.com/blog/sunlightsvg/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Mon, 22 Jul 2019 14:46:50 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[SVG]]></category>
		<guid isPermaLink="false">https://uda2.com/blog/?p=2462</guid>

					<description><![CDATA[<p>旭日旗の光線のような線（集中線？）を背景にしたいときにはイラストレーターで回転複製して作ってsvgなどに書き出してました。無駄なタグを掃除する為にSVGファイルをエディタで開くとコピーした多角形羅列されていて無駄が多い事</p>
The post <a href="https://uda2.com/blog/sunlightsvg/">SVGのリンク機能で集中線を描く</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>旭日旗の光線のような線（集中線？）を背景にしたいときにはイラストレーターで回転複製して作ってsvgなどに書き出してました。<br>無駄なタグを掃除する為にSVGファイルをエディタで開くとコピーした多角形羅列されていて無駄が多い事に気づき手書きしてみました。</p>



<span id="more-2462"></span>



<pre><code>&lt;svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
&lt;defs&gt;
&lt;g id="lightbar"&gt;
&lt;path d="M0,0 L996.19469810,87.15574275 L996.19469810,-87.15574274z" fill-opacity="0.15" fill="#ffffff" /&gt;
&lt;/g&gt;
&lt;/defs&gt;
&lt;radialGradient id="hGradient"&gt;
&lt;stop offset="20%" style="stop-color:#ff4317;" /&gt;
&lt;stop offset="100%" style="stop-color:#ff0000;" /&gt;
&lt;/radialGradient&gt;
&lt;rect width="100%" height="100%" fill="url(#hGradient)"/&gt;
&lt;svg x="50%" y="50%" overflow="visible"&gt;
&lt;use xlink:href="#lightbar" transform="rotate(0)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(20)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(40)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(60)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(80)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(100)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(120)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(140)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(160)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(180)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(200)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(220)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(240)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(260)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(280)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(300)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(320)" /&gt;
&lt;use xlink:href="#lightbar" transform="rotate(340)" /&gt;
&lt;/svg&gt;
&lt;/svg&gt;</code></pre>



<p>おおまかな流れは下記のような感じです。  ・背景に円形のグラデーションを描画  ・defsにリンク元（シンボルとかエイリアス的な機能）の三角形を作成  ・useタグでそれを角度を変えて描画  簡単に思えたのですが一カ所引っかかり描画されませんでした。  問題は一行目のsvgタグに「xmlns:xlink=&#8221;http://www.w3.org/1999/xlink&#8221;」が抜けてたのが原因でした。  リンク機能を使う場合はこの記述が必要らしいです。</p>



<p>これをベースに集中線を生成するツールをさくせいしました。乱数を設定することでコミックの集中線ぽいものも作れるようにしています。<br><a href="https://tools.uda2.com/central-line.html"> https://tools.uda2.com/central-line.html </a></p>The post <a href="https://uda2.com/blog/sunlightsvg/">SVGのリンク機能で集中線を描く</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/sunlightsvg/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SVGでボタンの枠線アニメーション</title>
		<link>https://uda2.com/blog/svg_line_animatiion/</link>
					<comments>https://uda2.com/blog/svg_line_animatiion/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Wed, 31 Oct 2018 12:47:36 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[アニメーション]]></category>
		<guid isPermaLink="false">https://uda2.com/blog/?p=2257</guid>

					<description><![CDATA[<p>一般的にボタンの枠線のアニメーションはCSSのborderを使う。 CSSだけで完結するので見やすく便利だが、角丸で2点から囲うようなアニメーションを作ろうと思ったらCSSでは難しそうなのでSVGでやってみた。 サンプル</p>
The post <a href="https://uda2.com/blog/svg_line_animatiion/">SVGでボタンの枠線アニメーション</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>一般的にボタンの枠線のアニメーションはCSSのborderを使う。<br />
CSSだけで完結するので見やすく便利だが、角丸で2点から囲うようなアニメーションを作ろうと思ったらCSSでは難しそうなのでSVGでやってみた。<br />
<span id="more-2257"></span></p>
<div style="width:70px; margin:0 auto;"><a href="#" class="anirect">サンプル</a></div>
<style>a.anirect {
	color:#FFF;
	text-decoration: none;
	padding: 5px;
	font-size: 12px;
	display: block;
	position: relative;
	text-align:center;
}
a.anirect svg {
	position: absolute;
	top: 0;left: 0;
	display:block;
	pointer-events: none;
}
a.anirect svg rect {
	fill:none;
	stroke:#FFF;
	stroke-dasharray: 0 98;
	stroke-dashoffset: -40;
	stroke-width: 1;
	transition: stroke-dasharray 500ms 0s ease;
}
a.anirect:hover svg rect {
	stroke-dasharray: 98 0;
}</style>
<p><script>
var navs = document.body.querySelectorAll('a.anirect');
navs.forEach(function(nav) {
  var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
  rect.setAttribute("x", "0.5");
  rect.setAttribute("y", "0.5");
  rect.setAttribute("rx", "3");
  rect.setAttribute("ry", "3");
  rect.setAttribute("width", nav.clientWidth - 1);
  rect.setAttribute("height", nav.clientHeight - 1);
  var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
  svg.setAttribute("viewBox", "0 0 "+nav.clientWidth+" "+nav.clientHeight);
  svg.appendChild(rect);
  nav.appendChild(svg);
});</script><br />
なんで線を描くだけでSVGを使うかというと破線の間隔（stroke-dasharray）や開始位置（stroke-dashoffset）といった設定が可能な為だ。<br />
SVGを背景にするとアニメーションの設定が出来ないのでインラインSVGにしたが、都度HTMLに挟み込むのは面倒なのでjavascriptで配置する事にした。<br />
ここで難所が現れた何故か埋め込んでも現れないのだ、開発ツール上ではあるのに現れず、CSSも適応されていない。<br />
javascriptで通常何か要素を作る時は「createElement」を使うが、svgのような名前空間を持つ要素を作成する場合は「createElementNS」を使うらしい。</p>
<pre><code>var navs = document.body.querySelectorAll('a.anirect');
navs.forEach(function(nav) {
  var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
  rect.setAttribute("x", "0.5");
  rect.setAttribute("y", "0.5");
  rect.setAttribute("rx", "3");
  rect.setAttribute("ry", "3");
  rect.setAttribute("width", nav.clientWidth - 1);
  rect.setAttribute("height", nav.clientHeight - 1);
  var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
  svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
  svg.setAttribute("viewBox", "0 0 "+nav.clientWidth+" "+nav.clientHeight);
  svg.appendChild(rect);
  nav.appendChild(svg);
});</code></pre>
<p>次にCSSですが98というのは要素の高さと幅の合計です。</p>
<pre><code>a.anirect {
	color:#FFF;
	text-decoration: none;
	padding: 5px;
	font-size: 12px;
	display: block;
	position: relative;
}
a.anirect svg {
	position: absolute;
	top: 0;left: 0;
	display:block;
	pointer-events: none;
}
a.anirect svg rect {
	fill:none;
	stroke:#FFF;
	stroke-dasharray: 0 98;
	stroke-dashoffset: -40;
	stroke-width: 1;
	transition: stroke-dasharray 500ms 0s ease;
}
a.anirect:hover svg rect {
	stroke-dasharray: 98 0;
}</code></pre>The post <a href="https://uda2.com/blog/svg_line_animatiion/">SVGでボタンの枠線アニメーション</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/svg_line_animatiion/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ワールドカップ記念10連マトリョーシカ</title>
		<link>https://uda2.com/blog/matryoshka/</link>
					<comments>https://uda2.com/blog/matryoshka/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Tue, 19 Jun 2018 06:06:02 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[マトリョーシカ]]></category>
		<guid isPermaLink="false">https://uda2.com/blog/?p=2236</guid>

					<description><![CDATA[<p>ワールドカップ2018はロシアです。なので10連マトリョーシカ作りました。 マトリョーシカ 元にした絵はFree マトリョーシカ人形 Stock Photo &#8211; FreeImages.comなんですがトレース</p>
The post <a href="https://uda2.com/blog/matryoshka/">ワールドカップ記念10連マトリョーシカ</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>ワールドカップ2018はロシアです。なので10連マトリョーシカ作りました。</p>
<p><a href="https://uda2.com/matryoshka/" target="_blank">マトリョーシカ</a><br />
<span id="more-2236"></span><br />
元にした絵は<a href="https://jp.freeimages.com/photo/matryoshka-doll-1416467" target="_blank">Free マトリョーシカ人形 Stock Photo &#8211; FreeImages.com</a>なんですがトレースまでしたのにいじりすぎて原型は無くなってます。<br />
おなかの所は元はエプロンに花柄なのですが、エプロンは微妙なので止めました。エプロンを止めるとシンプルな花柄ではもたなくなったのでユリアン（ウチのフレブル）を抱かしておきました。<br />
拡縮するので画像はSVGにしてます。</p>
<p>絵はともかくやりったかったのはマトリョーシカをスポポポーンと連続で開く動きを作りたかったので、カーソルの上下移動に合わせて次々に開閉し、カーソルの左右で回転するようにしました。<br />
一応スマホでもできるように傾きを検知させましたが、ブラウザが回転してしまうので微妙です。<br />
すぽんという効果音は<a href="https://dova-s.jp/se/play766.html" target="_blank">DOVA-SYNDROME</a>さんのものをトリミングして使っています。<br />
ただマトリョーシカの実物を見たことが無いので本当にこんな音がするかは不明です。</p>
<p>特に何かの役に立つわけではないけど気持ちいいです。</p>The post <a href="https://uda2.com/blog/matryoshka/">ワールドカップ記念10連マトリョーシカ</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/matryoshka/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SVGアニメーション</title>
		<link>https://uda2.com/blog/svg_animatioon/</link>
					<comments>https://uda2.com/blog/svg_animatioon/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Tue, 25 Nov 2014 16:56:36 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[SVG]]></category>
		<guid isPermaLink="false">http://uda2.com/blog/?p=1529</guid>

					<description><![CDATA[<p>なんだかんだでcanvasに押され気味のSVGだがAnimated SVG Iconsなんかを見ているとSVGにも可能性を感じる。 という事で昨年やった静止画のSVGに続きSVGアニメーションもやってみた。 上記の「An</p>
The post <a href="https://uda2.com/blog/svg_animatioon/">SVGアニメーション</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><object type="image/svg+xml" data="/blog/images/svg_animation.svg" height="300" width="300" style="background-color:#FFF"></object></p>
<p>なんだかんだでcanvasに押され気味のSVGだが<a href="http://tympanus.net/Development/AnimatedSVGIcons/" target="_blank">Animated SVG Icons</a>なんかを見ているとSVGにも可能性を感じる。<br />
<span id="more-1529"></span><br />
という事で昨年やった<a href="http://uda2.com/blog/2012/08/retina_logo_svg/">静止画のSVG</a>に続きSVGアニメーションもやってみた。<br />
上記の「Animated SVG Icons」は<a href="http://snapsvg.io/" target="_blank">Snap.svg</a>というAdobe製のライブラリを使っていたがちょっと動かすだけなので直接svgを書いてます。<br />
目は“神衣純潔”なイメージです。<br />
目は数値入力をして作りましたが、眉毛はイラレで作ってエディタで開いてコピペしてます。こういった作り方ができるのはSVGのいいところでもあります。<br />
上から眉毛、目の輪郭のアニメーション、目玉のアニメーション、目玉のマスクのアニメーションとなっています。<br />
問題はモダンなブラウザしか動かない事です。IE11だと眉毛だけになってしまいます。</p>
<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt;
&lt;svg version="1.1" id="figure1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="300px" height="300px" viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve"&gt;
&lt;path fill="#000" d="M28.892,156l14.729-42.108c0,0,137.946-56.473,160.039-61.512s67.868,70.039,67.868,70.039s-39.187-62.287-62.055-57.636
	s-84.036,56.953-111.943,67.806S28.892,156,28.892,156z"/&gt;
&lt;path stroke="#000" stroke-width="5" fill="#FFF"&gt;
	&lt;animate attributeName="d" calcMode="linear" from="M50,150 Q120,200 250,130 Q150,200 50,150 Z" to="M50,150 Q120,125 250,130 Q150,250 50,150 Z" keySplines="0.25 0.1 0.25 1.0" begin="0s" dur="0.5s" repeatCount="1" fill="freeze" /&gt;
&lt;/path&gt;
&lt;g id="eye"&gt;
	&lt;clipPath id="eyeball"&gt;
		&lt;circle id="clkipShape" cx="100" cy="150" r="45" /&gt;
		&lt;animate xlink:href="#clkipShape" attributeType="XML" attributeName="cx" calcMode="spline" from="100" to="150" begin="0.5s" dur="0.5s" repeatCount="1" fill="freeze" keySplines="0.0 0.0 0.58 1.0" /&gt;
	&lt;/clipPath&gt;
&lt;path clip-path="url(#eyeball)"&gt;
	&lt;animate attributeName="d" calcMode="linear" from="M50,150 Q120,200 250,130 Q150,200 50,150 Z" to="M50,150 Q120,125 250,130 Q150,250 50,150 Z" keySplines="0.25 0.1 0.25 1.0" begin="0s" dur="0.5s" repeatCount="1" fill="freeze" /&gt;
&lt;/path&gt;
&lt;/g&gt;
&lt;/svg&gt;</code></pre>
<p>参照<br />
<a href="http://www.hcn.zaq.ne.jp/___/SVGTiny12/animate.html#AnimateElement" target="_blank">Animation SVG Tiny 1.2</a><br />
<a href="http://www.h2.dion.ne.jp/~defghi/svgMemo/svgMemo.htm" target="_blank">svg要素の基本的な使い方まとめ</a><br />
<a href="http://sample.atmarkit.jp/fux/1207/02/sample.xhtml" target="_blank">「10分でわかるSVG 応用編」サンプル</a></p>The post <a href="https://uda2.com/blog/svg_animatioon/">SVGアニメーション</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/svg_animatioon/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Retina時代のスマホサイトのタイトルロゴはSVG</title>
		<link>https://uda2.com/blog/retina_logo_svg/</link>
					<comments>https://uda2.com/blog/retina_logo_svg/#comments</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Mon, 20 Aug 2012 09:25:56 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[Retina]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[スマホ]]></category>
		<guid isPermaLink="false">http://uda2.com/blog/?p=1317</guid>

					<description><![CDATA[<p>「Retina時代のスマホサイトのタイトルロゴはSVGがいい」と何処かに書いていたので作ってみた。 元画像はマイリリースのスマホ版トップのロゴ画像で元は480×109で作成して、iPhoneだと縦(320px)にも横(4</p>
The post <a href="https://uda2.com/blog/retina_logo_svg/">Retina時代のスマホサイトのタイトルロゴはSVG</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<style type="text/css"><!--
#sample01 div,#sample02 div {
width:240px; height:109px;
background-position: center top;
background-color:#000;
background-repeat:no-repeat;
background-size: 480px 109px;
-webkit-background-size: 480px 109px;
-moz-background-size: 480px 109px
-o-background-size: 480px 109px
}
#sample01 div {background-image: url(/blog/images/big.jpg);}
#sample02 div {background-image: url(/blog/images/big.png);}
--></style>
<p>「Retina時代のスマホサイトのタイトルロゴはSVGがいい」と何処かに書いていたので作ってみた。<br />
元画像はマイリリースのスマホ版トップのロゴ画像で元は480×109で作成して、iPhoneだと縦(320px)にも横(480px)にも使える様にしてる。<br />
  <br />
元々FireWorksで作成していたのでJPEG・PNGはRetinaテスト用に倍の解像度に変更しするだけで済んだが、SVGはFireWorksが未対応だったのでイラレに書き出し作り直した上でエディタでフィルタを追加したりと微調整した。</p>
<div id="sample01">
<div></div>
<p><strong>よくやる2倍サイズの<a href="/blog/images/big.jpg" target="_blank">JPEG画像</a></strong>（23.70KB）<br />
モヤモヤが出るので今回の様なロゴ画像には向かないJPEGだけどRetinaだとそんなに問題無さそう、グラデの掛かった画像の圧縮率は魅力的</p>
</div>
<div id="sample02">
<div></div>
<p><strong>よくやる2倍サイズの<a href="/blog/images/big.png" target="_blank">PNG画像</a></strong>（39.88KB）<br />
RetinaだとJPEGと画質は分らないし容量も大きい、グラデーションが無ければ色数を落として圧縮率を上げる事も出来るかも</p>
</div>
<div id="sample03">
<object type="image/svg+xml" data="/blog/images/myreleasez.svg" height="109" width="240"></object></p>
<p><strong><a href="/blog/images/myreleasez.svg" target="_blank">SVG画像</a></strong>（8.85KB）<br />
予想以上に低容量、SVGは表示が重いらしいがこのサイズだと差は分らない。</p>
</div>
<p>safariだとfilterが上手く動かないのかドロップシャドーが効かないみたいで昔のイラレみたいに手作業で追加する必要があり、容量も若干増える事になってしまう。</p>The post <a href="https://uda2.com/blog/retina_logo_svg/">Retina時代のスマホサイトのタイトルロゴはSVG</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/retina_logo_svg/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
