<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>SVG Weblog</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/" />
    <link rel="self" type="application/atom+xml" href="http://www.samurai-logic.com/svg/atom.xml" />
    <id>tag:www.samurai-logic.com,2008-07-08:/svg//4</id>
    <updated>2008-08-26T00:21:11Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.21-ja</generator>

<entry>
    <title>Chapter 10 : Polygon &amp; Polyline element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-10-polygon-polyline-el.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.122</id>

    <published>2008-07-23T11:53:03Z</published>
    <updated>2008-08-26T00:21:11Z</updated>

    <summary> Polygon element(ポリゴン要素)と Polyline eleme...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Polygon &amp; Polyline element" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="polygon" label="polygon" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="polyline" label="polyline" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
<em>Polygon element(ポリゴン要素)と Polyline element (ポリライン要素)で描く </em></p>
<p>
Polygon element と Polyline element には、points属性があります。 Polygonは下の図のように各点を結ぶ線の始点と終点が結ばれていますが、 Polylineは始点と終点が指定された位置になります。（黒い丸点はパスを分かり易く見えるようにしたものです。）
</p>
<p>
points = 図形を線で結ぶためのX軸Y軸を指定した各点
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="polygon.png" src="http://www.samurai-logic.com/svg/img/polygon.png" width="602" height="304" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span><p>
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="polyline.png" src="http://www.samurai-logic.com/svg/img/polyline.png" width="602" height="304" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>

]]>
        <![CDATA[<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/polygon.svg" />
</p>
<p>
<br />
<small>SVGがサポートされていないブラウザでは、SVG Viewerプラグインをインストールしてください。</small>
<br /><br />
IEで、Adobe SVG Viewer をインストールしてあれば、Altキーを押したまま上の画面をマウスでドラッグすれば動きます。また、Ctrlキーを押してクリックでズームイン、Ctrl + Shift キーを押してクリックするとズームアウトすることができます。
<br /><br />
左上の "defs" はポリラインとポリゴンのパスだけを定義したものです。スタイル属性は何も指定されていません。
</p>
<p>
その下の☆型の図形は、フィルの色をオレンジに、ストロークの色を青にしています。ポリゴンはストロークが繋がっていますが、ポリラインは最後に指定したパスでストロークは終了しています。
</p>
<p>
スタイル属性を何も指定しなければポリゴンもポリラインもフィルの部分のみが黒になります。右下は、フィルの色を無くしてストロークの色と幅のみを指定したものです。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>

<p>
下のコードは上のSVGファイルのコードです。
</p>

<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="520">
<desc>shapes of line element</desc>
<title>polygon-polyline element</title>
<style type="text/css">
<![CDATA[

.txt {font-family:Arial;font-weight:bold; }

]]&gt;
</style>
<defs>

    <pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse">
      <polyline points="10,0 0,0 0,10"
	 fill="none"
         stroke="gray"
         stroke-width="0.25" />
    </pattern>

 <polygon id="polygon1" 
	  points="201,246 125,191 62,261 90,171 5,133 98,133 108,39 138,128 230,109 154,165" />

 <polyline id="polyline1"
	   points="201,246 125,191 62,261 90,171 5,133 98,133 108,39 138,128 230,109 154,165" />

</defs>

<!-- grids //-->
<rect fill="white" width="850" height="530" />
  <rect fill="url(#grid)" stroke="black" stroke-width="1"  
           x="0" y="0" width="850" height="550" />

<!-- polygon an polyline //-->

<g style="fill:blue;stroke:blue;stroke-width:15;fill:orange;stroke-linejoin:round;stroke-linecap:round">
  <use xlink:href="#polygon1" transform="translate(20,80) scale(0.75)" />
  <use xlink:href="#polyline1" transform="translate(220,80) scale(0.75)" />
</g>

<g style="fill:none;stroke:blue;stroke-width:15;">
  <use xlink:href="#polygon1" transform="translate(450,280) scale(0.5)" />
  <use xlink:href="#polyline1" transform="translate(650,280) scale(0.5)" />
</g>

  <use xlink:href="#polygon1" transform="translate(450,80) scale(0.5)" />
  <use xlink:href="#polyline1" transform="translate(650,80) scale(0.5)" />

<g class="txt"> 
  <text font-size="16" fill="red"
     x="15"
     y="20">defs</text> 
  <text font-size="12"
     x="15"
     y="35">&lt;polygon id=&quot;polygon1&quot; </text> 
  <text font-size="12"
     x="15"
     y="50">points=&quot;201,246 125,191 62,261 90,171 5,133 98,133 108,39 138,128 230,109 154,165&quot; 

/&gt;</text> 
  <text font-size="12"
     x="15"
     y="75">&lt;polyline id=&quot;polyline1&quot;</text> 
  <text font-size="12"
     x="15"
     y="90">points=&quot;201,246 125,191 62,261 90,171 5,133 98,133 108,39 138,128 230,109 154,165&quot; 

/&gt;</text>

  <text font-size="12"
     x="5"
     y="300">&lt;g style=&quot;fill:blue;stroke:blue;stroke-width:15;</text> 
  <text font-size="12"
     x="50"
     y="315">fill:orange;stroke-linejoin:round;stroke-linecap:round&quot;&gt;</text> 
  <text font-size="12" fill="green"
     x="5"
     y="330">&lt;use xlink:href=&quot;#polygon1&quot; transform=&quot;translate(20,80) scale(0.75)&quot; 

/&gt;</text> 
  <text font-size="12" fill="green"
     x="5"
     y="345">&lt;use xlink:href=&quot;#polyline1&quot; transform=&quot;translate(220,80) scale(0.75)&quot; 

/&gt;</text> 
  <text font-size="12"
     x="5"
     y="360">&lt;/g&gt;</text>

  <text font-size="12"
     x="430"
     y="430">&lt;g style=&quot;fill:none;stroke:blue;stroke-width:15;&quot;&gt;</text> 
  <text font-size="12" fill="green"
     x="430"
     y="445">&lt;use xlink:href=&quot;#polygon1&quot; transform=&quot;translate(450,280) scale(0.5)&quot; 

/&gt;</text> 
  <text font-size="12" fill="green"
     x="430"
     y="460">&lt;use xlink:href=&quot;#polyline1&quot; transform=&quot;translate(650,280) scale(0.5)&quot; 

/&gt;</text> 
  <text font-size="12"
     x="430"
     y="475">&lt;/g&gt;</text> 


  <text font-size="12"
     x="430"
     y="315"></text> 
  <text font-size="12" fill="green"
     x="430"
     y="240">&lt;use xlink:href=&quot;#polygon1&quot; transform=&quot;translate(450,80) scale(0.5)&quot; 

/&gt;</text> 
  <text font-size="12" fill="green"
     x="430"
     y="255">&lt;use xlink:href=&quot;#polyline1&quot; transform=&quot;translate(650,80) scale(0.5)&quot; 

/&gt;</text> 
  <text font-size="12"
     x="430"
     y="360"></text> 

</g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 9 - 5 : SVG &amp; Canvas Matrix Transformation</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-9-5-svg-canvas-matrix.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.121</id>

    <published>2008-07-23T05:51:30Z</published>
    <updated>2008-07-26T21:23:04Z</updated>

    <summary><![CDATA[ これは、SVG &amp; Canvas で使われているMatrix Tran...]]></summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Canvas" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Matrix" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Transform attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="canvas" label="Canvas" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="matrix" label="Matrix" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="transform" label="Transform" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
これは、SVG &amp; Canvas で使われているMatrix Transformation をJavascript で計算して値を求めるためのツールです。そのMatrix値を使ってCanvas に描くようにしました。Matrix は、3×3ですので2Dです。3Dは4×4のマトリックスになります。
</p>
<p>
<iframe src="http://www.samurai-logic.com/svg/svg/matrix.html" width="600" height="685" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
</p>
<p>
<em>How to : &amp; example </em><br />
<span style="font-weight:bold;">
input value of translate(t<sub>x</sub>t<sub>y</sub>) ---> translate(50,40) <br />
input value of scale(s<sub>x</sub>s<sub>y</sub>) ---> scale(2) or scale(1,-0.75) <br />
input value of rotate(angle) ---> rotate(25)<br />
input value of skewX(angle) ---> skew(-45)<br />
"Get Matrix" button is to get values of Matrix Transformation <br />
"Clear Text" button is to clear the textarea<br />
"Draw Matrix" button is to redraw the image below <br />
"Clear Canvas" button is to clear images which is drawn.
</span>
</p>
<p>
<small>IEでも表示させるために Google の excanvas.js を使っていますが、excanvas.js に Matrixで描写するための setTransform 属性がないためにスクリプトを改造しています。しかし、IEでは、外側の赤い部分しか Matrix を Transform 出来ません。</small><br /><br />
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="matrix.png" src="http://www.samurai-logic.com/svg/img/matrix.png" width="600" height="317" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>]]>
        <![CDATA[<p>
マトリックスの計算方法は、上の図のようになります。<br /><br />
translate, scale, rotate, skewX, skewY 式にそれぞれの値を代入して、下の図で2つの式を計算させます。transform 属性で書かれている順番に従いさえすれば、頭から計算しても最後から計算しても同じです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
transform = "translate(tx [ ty])
             rotate(angle [cx cy])
             scale(sx [sy])
             skewX(angle)
             skewY(angle)"

transform = "matrix(a, b, c, d, e, f)" --->matrix(a, b, c, d, e, f, 0, 0, 1)

transform = "translate(tx, ty)" ---> transform = "matrix(1, 0, tx, d, 1, ty)" 

transform = "rotate(angle)"  ---> transform = "matrix(cos α, -sin α, 0, sin α, cos α, 0)"

α =  angle * π/180

transform = "skewX(angle)"   ---> transform = "matrix(1, tan α, 0, 0, 1, 0)"

transform ="skewY(angle)"   ---> transform ="matrix(1, 0, 0, tan α, 1, 0)"

transform = "scale(sx, sy)" ---> transform = "matrix(sx, 0, 0, 0, sy, 0)" 
</textarea>
</p>

<p>
<embed id="skew1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/matrix.svg" />
</p>
<p>
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
<br /><br />
<textarea name="code" class="xml" rows="15" cols="100">
  <use xlink:href="#cup" transform="translate(0,0)" />
  <use xlink:href="#cup" transform="matrix(1,0,0,1,0,0)" />

  <use xlink:href="#cup" transform="translate(450,450) scale(-1,1) rotate(165)" />
  <use xlink:href="#cup" transform="matrix(0.9659,0.2588,0.2588,-0.9659,450,450)" />
</textarea>
</p>
<p>これは、translate, scale, rotate, skew でTransform されたものをMatrix変換して纏めたものです。SVGレンダラーは、transform 属性で設定された各プロパティ値をMatrix変換してして処理するのでMatrix transform属性を使うことで計算量が減少した分、パフォーマンスが得られます。<br /><br />
<em>translate(0,0) </em> と <em>matrix(1,0,0,1,0,0)</em> は同じ位置に表示されます。<br />
同じように、<em>translate(450,450) scale(-1,1) rotate(165)</em> と <em>matrix(0.9659,0.2588,0.2588,-0.9659,450,450)</em> も同じ位置です。
</p>
<!--
 <p>
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
<mstyle mathvariant="bold" mathsize="normal">
<mi>T</mi>
</mstyle>
<mo>=</mo>
<mrow><mo>(</mo>
<mrow>
<mtable>
<mtr>
  <mtd>
  <mrow><msub><mi>a</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
  <mtd>
  <mrow><msub><mi>c</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
  <mtd>
  <mrow><msub><mi>e</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
</mtr>
<mtr>
  <mtd>
  <mrow><msub><mi>b</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
  <mtd>
  <mrow><msub><mi>d</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
  <mtd>
  <mrow><msub><mi>f</mi><mrow><mn>1</mn></mrow></msub></mrow></mtd>
</mtr>
<mtr>
  <mtd><mn>0</mn></mtd>
  <mtd><mn>0</mn></mtd>
  <mtd><mn>1</mn></mtd>
</mtr>
</mtable>
</mrow>
<mo>)</mo>
</mrow>
</mrow>
</math>
</p>
//-->
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>matrix attribute</desc>
<title>matrix attribute</title>

<style type="text/css">
<![CDATA[

.txt {font-family:Arial;font-weight:bold;
      font-size:15;
     }
.arrow {stroke:black;stroke-width:2.5;
	marker-start:url(#start);
	marker-end:url(#end);
	}
]]&gt;
</style>

<defs>
    <pattern
       id="gridPattern"
       width="10"
       height="10"
       patternUnits="userSpaceOnUse">
      <polyline points="10,0 0,0 0,10"
         fill="none"
         stroke="gray"
         stroke-width="0.25" />
    </pattern>

  <rect
     id="grids"
     width="800"
     height="530"
     stroke="gray"
     stroke-width="0.25"
     fill="url(#gridPattern)" />

  <marker id="start" viewBox="0 -10 20 20" markerUnits="userSpaceOnUse"
	  refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
   <polygon points="0,0 20,-6 16,0 20,6" stroke="black" />
  </marker>

  <marker id="end" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="black" />
  </marker>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="cup" stroke="black" stroke-linejoin="round" >
	<rect id="handle" width="35" height="50" x="90" y="30" rx="7" ry="30" 
	style="fill:none;stroke:#002222;stroke-width:10" />
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="104" height="5" x="-2" y="-1" fill="url(#shade1)" />
    </g>

  <path id="bracket" d="M0,0 Q-30,50 0 100" style="stroke:blue;stroke-width:3;fill:none" />

</defs>

<!-- grids //-->

 <use xlink:href="#grids" />

  <use xlink:href="#cup" transform="translate(0,0)" />
  <use xlink:href="#cup" transform="matrix(1,0,0,1,0,0)" />


  <use xlink:href="#cup" transform="translate(450,450) scale(-1,1) rotate(165)" />
  <use xlink:href="#cup" transform="matrix(0.9659,0.2588,0.2588,-0.9659,450,450)" />


  <use xlink:href="#cup" transform="matrix(0.8192,-0.5736,-0.5736,-0.8192,500,200)" />
  <use xlink:href="#cup" transform="translate(500,200) scale(1,-1) rotate(35)" />


  <use xlink:href="#cup" transform="matrix(-0.7071,-0.7071,-0.7071,0.7071,400,200)" />
  <use xlink:href="#cup" transform="translate(400,200) scale(-1,1) rotate(-45)" />


  <use xlink:href="#cup" transform="matrix(0.39482239,0.58852073,1.2247,-0.7071,150,450)" />
  <use xlink:href="#cup" transform="translate(150,450) scale(-1,1) rotate(165) skewX(45) skewY(-25)" />

 
<g class="txt">
</g>

</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 9 - 4 : Transform attribute (skewX, skewY) SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-9-4-transform-attribut.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.120</id>

    <published>2008-07-18T13:01:41Z</published>
    <updated>2008-07-19T02:43:24Z</updated>

    <summary>   skewX, skewY から構成されるスキュー・トランスフォーメーション...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Transform attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Translate" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="skewX skewY" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="skewx" label="skewX" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="skewy" label="skewY" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[  <p>
skewX, skewY から構成されるスキュー・トランスフォーメーションは、その形状からシアリング(shearing) と呼ばれたりします。<br /><br />
skewX はX軸に対して、skewY はY軸に対して設定された角度分、図のようにオブジェクトを変形させます。<br /><br />
もし設定角度(angle)がマイナスの場合は、逆の方向になります。
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="skew.png" src="http://www.samurai-logic.com/svg/img/skew.png" width="602" height="239" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>]]>
        <![CDATA[<p>
<textarea name="code" class="xml" rows="15" cols="100">
transform = "translate(tx [ ty])
             rotate(angle [cx cy])
             scale(sx [sy])
             skewX(angle)
             skewY(angle)"

transform = "translate(tx, ty)" ---> transform = "matrix(1, 0, tx, d, 1, ty)" 

transform = "skewX(angle)"   ---> transform = "matrix(1, tan &alpha;, 0, 0, 1, 0)"

transform ="skewY(angle)"   ---> transform ="matrix(1, 0, 0, tan &alpha;, 1, 0)"
</textarea>
</p>

<p>
<embed id="skew1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/skew.svg" />
</p>
<p>
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
<br /><br />
scale や rotate プロパティと同じように、同じtransform 属性で、skew の後にtranslate が設定されると移動する方向が違ってきます。
</p>
<p>

</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>skewX skewY property</desc>
<title>skewX skewY property</title>

<style type="text/css">
<![CDATA[

.arrow {stroke:red;stroke-width:2.5;
	marker-end:url(#end_red);
	}

.txt {font-family:Arial;font-weight:bold;
      font-size:15;
     }
	
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="265" 
	x2="850" y2="265" fill="none"
	stroke-width="530" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

  <marker id="end_red" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="red" />
  </marker>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>
    <linearGradient  id="shade2" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="can" stroke="black" stroke-linejoin="round" >
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="-1" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="146" fill="url(#shade1)" />
    </g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

  <line id="line1" x1="0" x2="800" y1="0" y2="0" 
	stroke="blue" stroke-width="0.25mm" transform="rotate(45)" />

  <use xlink:href="#line1" transform="rotate(-18.5)" />
  <use xlink:href="#line1" transform="translate(750,0) rotate(90)" />

  <line class="arrow" x1="110" y1="80" x2="650" y2="80" /> 

  <line class="arrow" x1="630" y1="170" x2="460" y2="340" /> 

  <use xlink:href="#can" />

  <use xlink:href="#can" transform="skewX(45) skewY(45) translate(200,0)" />

  <use xlink:href="#can" transform="translate(750,0) skewX(-45)" />

  <use xlink:href="#can" transform="translate(750,0) skewX(-45) translate(0,350)" />

  <use xlink:href="#can" transform="skewY(45)" />

  <use xlink:href="#can" transform="skewY(45) translate(200,0)" />

  <use xlink:href="#can" transform="translate(200,0) skewY(45)" />

  <circle cx="750" cy="0" r="5" fill="red" />
  <circle cx="0" cy="0" r="5" fill="red" />

  <line class="arrow" x1="110" y1="210" x2="180" y2="280" />
  <line class="arrow" x1="110" y1="120" x2="180" y2="120" />  

<g class="txt">

 text goes here

</g>

</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushCss.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Invader Game SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/invader-game-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.119</id>

    <published>2008-07-18T08:06:32Z</published>
    <updated>2008-07-18T09:23:29Z</updated>

    <summary>  Svg で書かれた懐かしのインベーダーゲームです。グラフィックオブジェクトを...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Game" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="game" label="game" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[ <p>
Svg で書かれた懐かしのインベーダーゲームです。<br /><br />グラフィックオブジェクトをECMAScipt で動かしています。SVGは、まだまだ発展途上の段階で大きな可能性を秘めています。
SVG2.0 でもっと自由度が増しそうです。<br /><br />

<a href="http://www.croczilla.com/svg/samples/invaders/invaders.svg" target="_blank">Invader game &copy;2007 simon place</a>&ensp;&ensp;方向キーを押してスタート
</p>

<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><a href="http://www.samurai-logic.com/svg/img/invader.JPG"><img alt="invader.JPG" src="http://www.samurai-logic.com/svg/img/invader-thumb-450x291.jpg" width="450" height="291" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></a></span>
</p>

]]>
        
    </content>
</entry>

<entry>
    <title>Chapter 9 - 3 : Transform attribute (negative scale)SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-9-3-transform-attribut-1.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.118</id>

    <published>2008-07-17T22:23:49Z</published>
    <updated>2008-07-19T02:41:27Z</updated>

    <summary>  transform 属性の、scale のプロパティ値がマイナスになった場合...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Rotate" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Scale" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Transform attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Translate" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="rotate" label="rotate" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scale" label="scale" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="transform" label="transform" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="translate" label="translate" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[ <p>
transform 属性の、scale のプロパティ値がマイナスになった場合、オブジェクトはミラーリング(mirroring)します。Chapter 9 の今回のセクションでは、これにrotate, translate などをミックスさせた位置関係を説明します。
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="transfrom scale" src="http://www.samurai-logic.com/svg/img/scale.png" width="601" height="301" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>]]>
        <![CDATA[
<p>
<textarea name="code" class="xml" rows="15" cols="100">
transform = "translate(tx [ ty])
             rotate(angle [cx cy])
             scale(sx [sy])
             skewX(angle)
             skewY(angle)"

transform = "matrix(a, b, c, d, e, f)" --->matrix(a, b, c, d, e, f, 0, 0, 1)

transform = "translate(tx, ty)" ---> transform = "matrix(1, 0, tx, d, 1, ty)" 

transform = "rotate(angle)"  ---> transform = "matrix(cos &alpha;, -sin &alpha;, 0, sin &alpha;, cos &alpha;, 0)"

transform = "scale(sx, sy)" ---> transform = "matrix(sx, 0, 0, 0, sy, 0)" 
</textarea>
</p>
<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/scale_rotate.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
左上のある#cup は、rotate(15) へ回転させた位置です。
<br />
rotate(15) scale(-1, 1) の位置は、X軸がマイナスの位置に表示されます。
<br />
rotate(15) scale(-1, 1) translate(-370, 0) の位置が右上2番目のオブジェクトです。この場合、translate(-370, 0) のマイナス370の方向は、scale(-1, 1) でX軸に反転してますので、逆の方向になります。これは、matrix 換算時にこうならなければいけないためです。
<br />
簡単に言うと、一旦scale(-1, 0)でX軸に反転させてますので、オブジェクトのカップの黒い取っ手のある方向がX軸にプラスの方向になります。もしscale が最後に設定されるのであれば関係ありません。また、transform での位置設定が終われば関係ありません。
<br /><br />
<font color="red">●</font>の位置は、x=650, y=250 の位置にあります。scale(-sx, -sy)の位置はその<font color="red">●</font>にクロスしている青線の反対側に反転された位置になります。
</p>
<p>
<em><u>基準となるオブジェクトの位置を、X=0, Y=0 の位置に設定すればその分簡単になります。</u></em><br />
</p>
<p>
<br /><br />

</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
    <g id="cup" stroke="black" stroke-linejoin="round" >	
	<rect id="handle" width="35" height="50" 
	      x="140" y="50" rx="7" ry="30" 
	      style="fill:none;stroke:#002222;stroke-width:10" />
	<rect x="50" y="20" width="100" height="150" 
	      rx="8" ry="8" fill="url(#shade1)" />
	<rect x="48" y="19" width="104" height="5" fill="url(#shade1)" />
    </g>
</textarea>
</p>
<p>
今回の#cup のx, y のオリジナルの位置は移動しています。前回までの#cup のrect 要素の左上(x, y) は指定していないので、x="0" y="0" でした。今回は、x="140" y="50" となっています。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="100%" height="100%">
<desc>rotate and negative scale property</desc>
<title>rotate and scale property</title>

<style type="text/css">
<![CDATA[

.arrow {stroke:red;stroke-width:2.5;
	marker-end:url(#end_red);
	}

.style1 {stroke:black;stroke-width:1.5mm;}

.txt {font-family:Impact; /*Arial;*/
      font-size:14;
     }
	
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="300" 
	x2="850" y2="300" fill="none"
	stroke-width="600" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="600" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

  <marker id="start" viewBox="0 -10 20 20" markerUnits="userSpaceOnUse"
	  refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
   <polygon points="0,0 20,-6 16,0 20,6" stroke="black" />
  </marker>

  <marker id="end" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="black" />
  </marker>

  <marker id="end_red" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" fill="red" stroke="red" />
  </marker>

    <linearGradient id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="cup" stroke="black" stroke-linejoin="round" >	
	<rect id="handle" width="35" height="50" 
	      x="140" y="50" rx="7" ry="30" 
	      style="fill:none;stroke:#002222;stroke-width:10" />
	<rect x="50" y="20" width="100" height="150" 
	      rx="8" ry="8" fill="url(#shade1)" />
	<rect x="48" y="19" width="104" height="5" fill="url(#shade1)" />
    </g>


</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- cup //-->

<g class="arrow">

</g>

<use xlink:href="#cup" transform="rotate(15)"/>

<use xlink:href="#cup" transform="scale(-1,1)"/>

<use xlink:href="#cup" transform="rotate(15) scale(-1,1) translate(-370,0)" />

<use xlink:href="#cup" transform="rotate(15) scale(-1,1) translate(-520,0)" />

<use xlink:href="#cup" transform="translate(600,250) rotate(-25)" />

<g  style="stroke:blue; stroke-width:0.5mm">
 <line x1="600" x2="600" y1="75" y2="425" transform="rotate(-25,600,250)" />
 <line x1="600" x2="600" y1="75" y2="425" transform="rotate(65,600,250)" /> 
</g>

<use xlink:href="#cup" transform="translate(600,250) rotate(-25) scale(-1,1)" />

<use xlink:href="#cup" transform="translate(600,250) rotate(-25) scale(-0.25)" />

<use xlink:href="#cup" transform="translate(600,250) rotate(-25) scale(-0.25,1)" />

<use xlink:href="#cup" transform="translate(600,250) rotate(-25) scale(1,-1)" />

<use xlink:href="#cup" transform="translate(600,250) rotate(-25) scale(-1,1) translate(350,-150)" />

<circle cx="600" cy="250" r="5" fill="red" />

<line x1="470" y1="400" x2="240" y2="400" class="arrow" />

<g class="txt">
 text goes here
</g>

</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushCss.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 9 - 2 : Transform attribute (rotate)SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-9-2-transform-attribut.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.116</id>

    <published>2008-07-16T11:56:43Z</published>
    <updated>2008-07-19T02:40:58Z</updated>

    <summary>  Transform 属性の rotate プロパティは、オブジェクトを回転さ...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Rotate" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Transform attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Translate" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="transform" label="Transform" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rotate" label="rotate" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[ <p>
Transform 属性の rotate プロパティは、オブジェクトを回転させるためのものですが、回転の軸(cx, cy)がどこにあるかで位置が変わります。rotate(angle, cx, cy) の cx, cy はオプションです。rotate(angle) と指定されてなければ、cx, cy はオブジェクトの x, y の位置になります。<br /><br />
circle 要素は、cx, cy の回転の軸が中心にあるため、このrotate プロパティはグラデーションやstroke-dasharrayなどのスタイル属性に対して有効になります。(ellipse要素は、X軸とY軸の半径（r) -->rx, ry があるので有効です）
</p>]]>
        <![CDATA[<p>
<textarea name="code" class="xml" rows="15" cols="100">
transform = "translate(tx [ ty])
             rotate(angle [cx cy])
             scale(sx [sy])
             skewX(angle)
             skewY(angle)"

transform = "translate(tx, ty)" ---> transform = "matrix(1, 0, tx, d, 1, ty)" 

transform = "rotate(angle)"  ---> transform = "matrix(cos &alpha;, -sin &alpha;, 0, sin &alpha;, cos &alpha;, 0)"
</textarea>
</p>

<p>
<embed id="rotate1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/rotate.svg" />
</p>
<p>
左上のオブジェクトは、rotate(45) させたものです。この場合は、オブジェクトの位置は、x=0, y=0 ですので、rotate(45,0,0) と同じ意味になります。もしオブジェクトの位置が、 x=100, y=100 にあると、rotate(45) は rotate(45,100,100) と同じです。
<br /><br />
rotate(45)と設定すると、オブジェクトが時計回りに45度、x, y を軸にして回転します。rotate(360) と設定すると rotate(0) と同じ位置ですので変化はありません。rotate(45)=rotate(405)<br /><br />
左側の図は#cup を translate(350,0) rotate(45) と rotate(45) translate(350,0) にトランスフォームさっせた図です。<br /><br />
<em> translate(350,0) rotate(45)</em> は、translate(350,0) と移動させた位置で rotate(45) と回転させています。<br /><br />
<em> rotate(45) translate(350,0)</em> は、rotate(45) と回転させた状態で translate(350,0) と移動させています。<br /><br />
右側の図は、translate(450,0) と移動させて、その位置から(200,75) の位置を軸にして回転させた例です。<em>rotate(angle, 200, 75)</em>と設定します。
<br /><br /><br /><br />
</p>
<p>
<embed id="rotate2" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/rotate2.svg" />
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<g id="cup2">
 <use xlink:href="#cup" transform="translate(200,200)" />
</g>

 <use xlink:href="#cup2" transform="rotate(-25)" />

 <use xlink:href="#cup" transform="rotate(25) translate(200,200)" />
</textarea>
</p>
<p>
#cup2 は、#cup をtranslate(200,200) の位置に移動させたものです。<br /><br />
#cup rotate(25) translate(200,200) の位置は #cup2 rotate(25) と同じになります。#cup2 はグループ化されたIDになります。そのIDを指定するということは、rotate がtranslate(200,200) よりも先になります。上の例は、rotate(-25) と反時計周りに移動させてます。<br /><br />
</p>
<p>
<em><u>基準となるオブジェクトの位置を、X=0, Y=0 の位置に設定すればその分簡単になります。</u></em><br />
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<g id="cup3">
 <use xlink:href="#cup2" transform="translate(400,0)" />
</g>

 <use xlink:href="#cup3" transform="rotate(-15)" />

 <use xlink:href="#cup3" transform="rotate(15)" />
</textarea>
</p>
<p>
#cup3 の例も同じです。<br />
</p>
<p>
<em>問題：</em>#cup3 をrotate(15) させた位置を、#cup を使ってトランスフォームさせよ
<br /><br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
<br /><br />
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="100%" height="100%">
<desc>rotate property</desc>
<title>rotate property</title>

<style type="text/css">
<![CDATA[
.arrow {stroke:black;stroke-width:2.5;
	marker-end:url(#end);
	}

.style1 {stroke:black;stroke-width:1.5mm;}

.txt {font-family:Impact; /*Arial;*/
      font-size:14;
     }
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="300" 
	x2="850" y2="300" fill="none"
	stroke-width="600" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="600" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

  <marker id="start" viewBox="0 -10 20 20" markerUnits="userSpaceOnUse"
	  refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
   <polygon points="0,0 20,-6 16,0 20,6" stroke="black" />
  </marker>

  <marker id="end" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="black" />
  </marker>

  <marker id="end_red" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" fill="red" stroke="red" />
  </marker>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="cup" stroke="black" stroke-linejoin="round" >
	
	<rect id="handle" width="35" height="50" x="90" y="30" rx="7" ry="30" 
	style="fill:none;stroke:#002222;stroke-width:10" />
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="104" height="5" x="-2" y="-1" fill="url(#shade1)" />
    </g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- cup //-->

<use xlink:href="#cup"  transform="translate(450,0)" />

<circle transform="translate(450,0)" r="5" />
<circle cx="650" cy="75" r="5" />

<use xlink:href="#cup" transform="translate(450,0) rotate(-45,200,75)" />
<use xlink:href="#cup" transform="translate(450,0) rotate(-90,200,75)" />
<use xlink:href="#cup" transform="translate(450,0) rotate(-135,200,75)" />
<use xlink:href="#cup" transform="translate(450,0) rotate(180,200,75)" />

<g style="stroke:gray; stroke-width:0.5mm">
 <line id="line2" x1="450" y1="0" x2="650" y2="75" />
 <use xlink:href="#line2" transform="rotate(-45,650,75)" />
 <use xlink:href="#line2" transform="rotate(-90,650,75)" />
 <use xlink:href="#line2" transform="rotate(270,650,75)" />
 <use xlink:href="#line2" transform="rotate(225,650,75)" />
 <use xlink:href="#line2" transform="rotate(180,650,75)" />
</g>

<g class="arrow">
 <line x1="450" y1="0" x2="650" y2="75" />
</g>

<use xlink:href="#cup" transform="rotate(45)" />

<use xlink:href="#cup" transform="translate(350,0) rotate(45)" />
<use xlink:href="#cup" transform="rotate(45) translate(350,0)" />

<g class="arrow">
 <line x1="100" y1="75" x2="250" y2="75" />
 <line x1="50" y1="150" x2="175" y2="275" />
</g>

 <line x1="0" y1="0" x2="400" y2="400" stroke="gray" stroke-width="0.5mm" />

   <path d="M100,0 Q100 35.35 70.7,70.7" style="fill:none;stroke:red;stroke-width:1mm;marker-end:url(#end_red)" />

 <g class="txt">

 <!-- text goes here //-->

  <text x="215" y="230"></text> 
 </g>

</svg>
</textarea>
</p>

<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="100%" height="100%">
<desc>rotate property</desc>
<title>rotate property</title>

<style type="text/css">
<![CDATA[
.arrow {stroke:black;stroke-width:2.5;
	marker-end:url(#end);
	}

.style1 {stroke:black;stroke-width:1.5mm;}

.txt {font-family:Impact; /*Arial;*/
      font-size:14;
     }
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="300" 
	x2="850" y2="300" fill="none"
	stroke-width="600" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="600" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

  <marker id="start" viewBox="0 -10 20 20" markerUnits="userSpaceOnUse"
	  refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
   <polygon points="0,0 20,-6 16,0 20,6" stroke="black" />
  </marker>

  <marker id="end" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="black" />
  </marker>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="cup" stroke="black" stroke-linejoin="round" >
	
	<rect id="handle" width="35" height="50" x="90" y="30" rx="7" ry="30" 
	style="fill:none;stroke:#002222;stroke-width:10" />
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="104" height="5" x="-2" y="-1" fill="url(#shade1)" />
    </g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- cup //-->

<g id="cup2">
 <use xlink:href="#cup" transform="translate(200,200)" />
</g>

 <use xlink:href="#cup2" transform="rotate(-25)" />

 <use xlink:href="#cup" transform="rotate(25) translate(200,200)" />

 <line id="line1" x1="0" y1="0" x2="200" y2="200" style="stroke:gray;stroke-width:0.5mm" />
 <use xlink:href="#line1" transform="rotate(25)" />
 <use xlink:href="#line1" transform="rotate(-25)" />

 <circle id="dot" transform="translate(200, 200)" r="4.5" />
 <use xlink:href="#dot" transform="rotate(25)" />
 <use xlink:href="#dot" transform="rotate(-25)" />

<g id="cup3">
 <use xlink:href="#cup2" transform="translate(400,0)" />
</g>

 <use xlink:href="#cup3" transform="rotate(-15)" />
 <use xlink:href="#cup3" transform="rotate(15)" />

<g class="arrow">
 <line x1="330" x2="580" y1="275" y2="275" />
</g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 9 - 1 : Transform attribute (translate, scale) SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-9-transform-attribute.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.115</id>

    <published>2008-07-15T01:14:16Z</published>
    <updated>2008-07-19T02:40:27Z</updated>

    <summary> transform 属性は、translate, rotate, scale,...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Scale" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Transform attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Translate" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="transform" label="Transform" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="scale" label="scale" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="translate" label="translate" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
transform 属性は、translate, rotate, scale, skewX, skewY の5つのプロパティから構成されています。<br /><br />
translate(tx, ty) はIDのある xlink:href 属性によってリンクされたオブジェクトをX軸(tx)、Y軸(ty)に移動させます。<br /><br />
rotate(angle)は、オブジェクトを回転させます。(Chapter9-2, 9-3)<br /><br />
scale(sx,sy)は、オブジェクトの大きさ(X軸にsx 倍, Y軸にsy 倍)を変更します。(Chapter9-1, 9-3)<br /><br />
skewX(angle)は、オブジェクトをX軸の方向に設定された角度分歪みを加えます。(Chapter9-4)
skewY(angle)は、オブジェクトをY軸の方向に設定された角度分歪みを加えます。(Chapter9-4
</p>
<p>

</p>]]>
        <![CDATA[
<p>
<textarea name="code" class="xml" rows="15" cols="100">
transform = "translate(tx [ ty])
             rotate(angle [cx cy])
             scale(sx [sy])
             skewX(angle)
             skewY(angle)"

transform = "matrix(a, b, c, d, e, f)" --->matrix(a, b, c, d, e, f, 0, 0, 1)

transform = "translate(tx, ty)" ---> transform = "matrix(1, 0, tx, d, 1, ty)" 

transform = "rotate(angle)"  ---> transform = "matrix(cos &alpha;, -sin &alpha;, 0, sin &alpha;, cos &alpha;, 0)"

&alpha; =  angle * &pi;/180

transform = "skewX(angle)"   ---> transform = "matrix(1, tan &alpha;, 0, 0, 1, 0)"

transform ="skewY(angle)"   ---> transform ="matrix(1, 0, 0, tan &alpha;, 1, 0)"

transform = "scale(sx, sy)" ---> transform = "matrix(sx, 0, 0, 0, sy, 0)" 
</textarea>
</p>
<p>
<br /><br />matrixは、それらのプロパティ値を 3*3 マトリックス<u>matrix(a, b, c, d, e, f, 0, 0, 1)</u> に纏めたものです。一番下の段に当たる 0, 0, 1 の部分はtransform 要素には関係ないので省略されます。SVGレンダラーは、transform 属性の各プロパティ (translate, rotate, scale, skewX, skewY) を1つの matrix に変換します。よって matrix プロパティを使うことでパフォーマンス的に有利になります。マトリックスは、Chapter 9 の最後の記事で説明します。
</p>
<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/transform1.svg" />
</p>
<p>
これは、scaleプロパティを使ったときのオブジェクトの位置を説明したものです。scale(0.5, 0.5)とした場合のX軸とY軸の値はオリジナルのオブジェクトの半分になります。 もし、オリジナルのオブジェクトの位置が、x="0" y="0" にある場合は位置は変わりません。
<br /><br />
<em>scale(0.5 0.5) ---> x="x * 0.5" y="y * 0.5"</em>
</p>

<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/transform.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>

<p>
左の図形は、id="can" にリンクをさせてtransform="translate(50, 30)" ---> X軸に50px、Y軸に30px 移動させたものです。最初のrect 要素には、x="", y="" が設定されていませんので、x="0" y="0" となります。<br /><br />
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
    <g id="can" stroke="black" stroke-linejoin="round" >

<!-- x="0" y="0" //-->
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />

	<rect width="102" height="5" x="-1" y="-1" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="146" fill="url(#shade1)" />
    </g>
</textarea>
</p>
<p>
2番目の図形は、transform="translate(200, 30) scale(1.5 0.5)" と、X軸に200、Y軸に30、幅(X軸に対する倍率）が1.5倍、高さ（Y軸に対する倍率）が0.5倍の大きさになっています。<br /><br />
3番目の図形は、2番目の図形(id="drum")にネストさせてます。<br />
<em>transform=&quot;translate(400,0)　scale(0.20 0.75)&quot;</em><br />
<em>transform=&quot;translate(400,168.75)　scale(0.20 0.75)&quot;</em><br />
translate(400, 0)とX軸に400px移動させた位置で大きさを変更しています。もし先にscaleで大きさを変更したまま translate で移動させる場合は下のように書かなければいけません。
<br /><br />
<em>&lt;use xlink:href=&quot;#drum&quot; transform=&quot;scale(0.20 0.75) translate(2000,0)&quot; /&gt;</em><br />
<em>&lt;use xlink:href=&quot;#drum&quot; transform=&quot;scale(0.20 0.75) translate(2000,225)&quot; /&gt;</em><br /><br />
これは、scale(0.2 0.75) とX軸の幅を先に20% にした状態で移動させなければいけないのでX軸に5倍(0.2×5=1) の距離 ---> translate(2000,0) となります( 400 × 5 = 2000 ) ---> matrix 換算値
<br /><br />
<b>Y軸：Y軸に168.75移動した位置で0.75倍の高さ(Y軸）にするということは、<br />
0.75倍の高さ(Y軸）した状態でY軸に225動かす</b>と同じことになります。(168.75 × 4 ÷ 3 = 225)
<br /><br />
</p>
<p>
<em><u>基準となるオブジェクトの位置を、X=0, Y=0 の位置に設定すればその分簡単になります。</u></em><br />
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>scale property</desc>
<title>scale property</title>

<style type="text/css">
<![CDATA[

.txt {font-family:Arial;font-weight:bold;
      font-size:15;
     }

.arrow {stroke:black;stroke-width:2.5;
	marker-start:url(#start);
	marker-end:url(#end);
	}
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="265" 
	x2="850" y2="265" fill="none"
	stroke-width="530" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="0" y1="265" 
	x2="550" y2="265" fill="none"
	stroke-width="550" 
	stroke="gray"
	stroke-dasharray="1.5 48.5" />

  <line x1="250" y1="0" 
	x2="250" y2="550" fill="none"
	stroke-width="500" stroke="gray"
	stroke-dasharray="1.5 48.5" />
</g>
  <marker id="start" viewBox="0 -10 20 20" markerUnits="userSpaceOnUse"
	  refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
   <polygon points="0,0 20,-6 16,0 20,6" stroke="black" />
  </marker>

  <marker id="end" viewBox="-20 -10 20 20" markerUnits="userSpaceOnUse"
	refX="0" refY="0" markerWidth="20" markerHeight="20" orient="auto">
    <polygon points="0,0 -20,-6 -16,0 -20,6" stroke="black" />
  </marker>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="can" stroke="black" stroke-linejoin="round" >
	<rect width="100" height="200" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="-1" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="196" fill="url(#shade1)" />
    </g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />


<g id="drum">
  <use xlink:href="#can" transform="translate(300,300) scale(2 1)" />
  <use xlink:href="#can" transform="translate(300,366) scale(2 0.33)" />
</g>

  <use xlink:href="#drum" transform="scale(0.25 0.25)" />
  <use xlink:href="#drum" transform="scale(0.5 0.5)" />
  <use xlink:href="#drum" transform="scale(0.5 1)" />
  <use xlink:href="#drum" transform="scale(1 0.5)" />

<g class="arrow">
  <line x1="300" y1="0" x2="300" y2="300" />
  <line x1="150" y1="0" x2="150" y2="150" />
  <line y1="300" x1="0" y2="300" x2="300" />
  <line y1="150" x1="0" y2="150" x2="150" />
</g>

<g class="txt">
 <text ..... />
</g>

</svg>
</textarea>
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>transform attribute</desc>
<title>transform attribute</title>

<style type="text/css">
<![CDATA[

.txt {font-family:Arial;
      font-size:15;
     }
	
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="265" 
	x2="850" y2="265" fill="none"
	stroke-width="530" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

    <linearGradient  id="shade1" x2="50%" y2="0%" spreadMethod="reflect">
      <stop offset="0%" stop-color="darkslategray"/>
      <stop offset="100%" stop-color="white"/>
    </linearGradient>

    <g id="can" stroke="black" stroke-linejoin="round" >
	<rect width="100" height="150" rx="8" ry="8" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="-1" fill="url(#shade1)" />
	<rect width="102" height="5" x="-1" y="146" fill="url(#shade1)" />
    </g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- circle 1 //-->

<use x="0" y="0" xlink:href="#can" transform="translate(50,30)" />

<g id="drum">
  <use xlink:href="#can" transform="translate(200,30) scale(1.5 0.5)" />
  <use xlink:href="#can" transform="translate(200,105) scale(1.5 0.5)" />
  <use xlink:href="#can" transform="translate(200,180) scale(1.5 0.5)" />
</g>

<!-- nesting "drum" //-->

<g id="banboo">
  <use xlink:href="#drum" transform="translate(400,0) scale(0.20 0.75)" />
  <use xlink:href="#drum" transform="translate(400,168.75) scale(0.20 0.75)" />
</g>

<!-- nesting "banboo" //-->

<g id="nesting">
  <use xlink:href="#banboo" transform="translate(500,0) scale(0.25 0.75)" />
  <use xlink:href="#banboo" transform="translate(550,0) scale(0.25 0.75)" />
  <use xlink:href="#banboo" transform="translate(600,0) scale(0.25 0.75)" />
  <use xlink:href="#banboo" transform="translate(650,0) scale(0.25 0.75)" />
  <use xlink:href="#banboo" transform="translate(700,0) scale(0.25 0.75)" />
</g>

 <g class="txt">

 <!-- text goes here //-->

  <text x="215" y="230"></text> 
 </g>

</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushCss.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter8 : CSS Style attributes SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/css-style-attributes-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.114</id>

    <published>2008-07-14T11:20:28Z</published>
    <updated>2008-07-15T00:36:57Z</updated>

    <summary>  SVG でカスケード・スタイル・シート(CSS)を利用する。 SVG ではC...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="CSS Style attribute" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="css" label="CSS" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="styleattribute" label="style attribute" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
<em> SVG でカスケード・スタイル・シート(CSS)を利用する。</em>
<br /><br />
SVG ではCSSもサポートサポートされています。Style 属性で指定できるプロパティはスタイルタグ(&lt;style&gt;)の中で設定することが出来ます。Fill &amp; Stroke プロパティの他に、線形グラデーション、放射グラデーション、Fillter Effect などがあります。
<br /><br /><b>fill, fill-opacity, stroke, stroke-opacity, stroke-width, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit, linerGradient, radialGradient,　Fillter, etc.</b>
</p>]]>
        <![CDATA[<p>
各スタイル属性のプロパティはスタイルタグに以下のように書くことができます。グラデーションなどは、defs で設定したIDにリンクさせています。
<br /><br />
<u>参考までに</u><br />
group 要素のみにスタイル(.style1)を適用したければ、<em>g.style1 { ... }</em> <br />
line 要素のみにスタイル(.style2)を適用したければ、<em>line.style2 { ... }</em> <br />
group 要素タグ内の circle 要素のみにスタイル(.style4)を適用したければ、<em>g circle.style4 { ... }</em> <br />
と子孫セレクタを指定して書くことが出来ますが、まだ曖昧な部分があってあまり使えそうにありません。
</p>

<p>
<textarea name="code" class="css" rows="15" cols="100">
<style type="text/css">
<![CDATA[

.style1 {fill:navy; fill-opacity:0.7; 
	 stroke:red; 
	 stroke-opacity:0.7; 
	 stroke-width:20;
	 stroke-opacity:0.75;
	 stroke-dasharray:10 10;
	 stroke-dashoffset:4;
         fill:url(#Id_Name);
	}

/* these are not usefull,but just for references */
g.style2 {fill:navy; fill-opacity:0.7; } /* g element only*/

circle.style3 { fill:url(#Id_Name); } /* circle ement only */

rect.style4 { fill:blue; stroke:red; } /* rect element only */

g rect.style5 {stroke-width:5; } /* rect element in group element only */

g line.style6 {fill-opacity:0.5; } /* line element in group element only */

g text.txt {fill:#111;
      font-family:Arial; 
      font-size:14;
     }
	
]]&gt;
</style>
</textarea>
</p>
<p>
<embed id="line1" height="500" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/css.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
左の図形は、circle 要素を使って円を１つ描いたものです。group 要素にCSSでプロパティ値を指定したクラス(style1)と、Circle 要素にクラス(dash1)を別々に設定することも出来ます。またFill に放射グラデーションを入れてます。<b>Fill:url(#Gradient2);</b><br /><br />HTML文と同じように、効率的に整理されることでファイルサイズが小さくなります。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="500">
<desc>CSS style attribute</desc>
<title>CSS style attribute</title>

<style type="text/css">
<![CDATA[

.style1 {fill:navy; fill-opacity:0.7; 
	 stroke:red; 
	 stroke-opacity:0.7; 
	 stroke-width:20;
	 stroke-opacity:0.75;fill:url(#Gradient2);
	}

.dash1  {stroke-dasharray:7.5 8.2;}


.style2 {stroke:green; 
	 stroke-width:20;
	 stroke-dasharray:2 7.42;
	 stroke-dashoffset:4;
	 fill:none;
	 fill:url(#Gradient1);
	}

.style3 {stroke:blue;
	 stroke-width:40;
	 stroke-dasharray:3 6.42; 
	 fill:yellow;
	 fill-opacity:0.5;
	}

.style4 {stroke:url(#Gradient1);
	 stroke-width:30;
	 stroke-dasharray:30 20;
	 stroke-dashoffset:15;
	 fill:none;
	 fill:url(#Gradient3);
	}

.style5 {stroke-width:25;
	 stroke-dasharray:25 25;
	 stroke-dashoffset:12.5;
	}

.txt {font-family:Impact; /*Arial;*/
      font-size:14;
      fill:url(#Gradient3);
     }
	
]]&gt;
</style>

<defs>
<g id="grid">

  <line x1="0" y1="250" 
	x2="850" y2="250" fill="none"
	stroke-width="500" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="400" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

<radialGradient id="Gradient1"  
		cx="50%" cy="50%" r="3%" 
		spreadMethod="reflect">

<stop offset="0%" stop-color="blue" stop-opacity="1"/>
<stop offset="100%" stop-color="yellow" stop-opacity="1"/>
</radialGradient>

<radialGradient id="Gradient2"  
		cx="50%" cy="50%" r="10%" 
		spreadMethod="reflect">

<stop offset="0%" stop-color="lime" stop-opacity="1"/>
<stop offset="100%" stop-color="red" stop-opacity="1"/>

</radialGradient>

<radialGradient id="Gradient3"  
		cx="50%" cy="50%" r="100%" 
		spreadMethod="reflect">

<stop offset="0%" stop-color="gold" stop-opacity="1"/>
<stop offset="100%" stop-color="navy" stop-opacity="1"/>

</radialGradient>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- circle 1 //-->

<g class="style1">
 <circle class="dash1" cx="100" cy="100" r="75" />
</g>

<!-- circle 2 //-->

<g class="style2">
 <circle cx="300" cy="100" r="75" />
</g>

 <circle class="style3" cx="300" cy="100" r="75"  />

<!-- rectangle 3 //-->

<g class="style4">

  <rect x="450" y="30"  
	width="150" height="150" />

  <rect x="500" y="80"  
	width="50" height="50" />
</g>

<!-- rectangle4 //-->

<g class="style5">

  <rect x="680" y="30"  
	width="150" height="150"
	stroke="white" />

  <rect x="705" y="55"  
	width="100" height="100"
	style="stroke:red;
	fill:green" />

  <rect x="730" y="80"  
	width="50" height="50"
	style="stroke:blue;
	fill:url(#Gradient2)" />
</g>

<g class="txt">
 <!-- Text goes here //-->
</g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushCss.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 7 : Group element &amp; Use element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/chapter-7-group-element-use-el.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.113</id>

    <published>2008-07-14T00:08:25Z</published>
    <updated>2008-07-14T04:12:45Z</updated>

    <summary> Group element(グループ要素)と Use element (Use...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Group emement" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="group" label="group" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="use" label="use" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
<em>Group element(グループ要素)と Use element (Use 要素) を利用する</em>
</p>
<p>
Group 要素は描いた図形をグループ化する役割があります。 Use 要素は、ID を持つ各オブジェクトを xlink:href 属性を使ってリンクによって何度でも使うことができます。これらの2つの要素は構造的に重要な役割を持ち、とても便利なので頻繁に使われます。<br /><br />
<strong> &lt;use xlink=&quot;ID&quot; .... /&gt; </strong>
</p>]]>
        <![CDATA[<p>
<textarea name="code" class="xml" rows="15" cols="100">
<use xlink:href="URI"
         x="x-axis cordinate"
         y="y-axis cordinate"
         width="width"
         height="height"
         style="style attribute" />
</textarea>
<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/g.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。(FireFoxでは、現時点ではstroke-dasharray がサポートされていないようなので円のストロークが丸い状態になります。）</small>
</p>
<p>
左側の3つの円と四角の図形は、Group 要素を使ってグループ内のオブジェクトにスタイル属性を指定して描写しています。グループ内のスタイル属性の各プロパティ値を Fill:navy;や Fill-opacity:0.3; というように指定しても、図形で fill:red;fill-opacity:1 と指定されるとこちらが優先されます。右の2種類の顔のオブジェクトは&lt;defs&gt; で定義しているオブジェクトのID を指定して、use xlink:href でリンクさせて描写したものです。各図形にID を設定してますので、必要に応じて別々にリンクさせることも出来ます。use 要素で設定する x, y はリンクさせるオブジェクトのx, y 属性で指定したオリジナルの位置からの移動させる値になります。
<br /><br />
IEで、Adobe SVG Viewer をインストールしてあれば、Altキーを押したまま上の画面をマウスでドラッグすれば動きます。また、Ctrlキーを押してクリックでズームイン、Ctrl + Shift キーを押してクリックするとズームアウトすることができます。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>

<p>
下のコードは上のSVGファイルのコードです。
</p>

<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>defs. of group and use element, with attributes</desc>
<title>group and use element</title>
<defs>
<g id="grid">

  <line x1="0" y1="265" 
	x2="850" y2="265" fill="none"
	stroke-width="530" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>

<!-- smile 1 //-->
<g id="smile1">

  <circle id="smile1_1"
	  cx="85" cy="50" r="22" 
	  stroke-width="10"
	  stroke-dasharray="48 91" 
	  stroke-dashoffset="20"
	  stroke-linecap="round"
	   />

  <circle id="smile1_2"
	   cx="155" cy="50" r="22" 
	  stroke-width="10"
	  stroke-dasharray="48 91" 
	  stroke-dashoffset="28"
	  stroke-linecap="round"
	   />

  <circle id="smile1_3"
	  cx="120" cy="85" r="40" 	  
	  stroke-width="10"
	  stroke-dasharray="1 50 1 50 90 50" 
	  stroke-dashoffset="22"
	  stroke-linecap="round"
	  fill="none" />

</g>

<!-- smile 2 //-->

<g id="smile2">
 <g id="smile2_1">
  <circle cx="700" cy="50" r="22" 
	  stroke-width="10"
	  stroke-dasharray="58 81" 
	  stroke-dashoffset="30"
	  stroke-linecap="round"
	  fill="none" />
 </g>
 <g id="smile2_2">
  <circle cx="750" cy="50" r="22" 
	  stroke-width="10"
	  stroke-dasharray="45 112" 
	  stroke-dashoffset="22.5"
	  stroke-linecap="round"
	  fill="none" />
 </g>
 <g id="smile2_3">
  <circle cx="720" cy="85" r="40" 
	  stroke-width="10"
	  stroke-dasharray="1 50 1 50 90 50" 
	  stroke-dashoffset="22"
	  stroke-linecap="round"
	  fill="none" />
 </g>
</g>

</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<g fill="navy">
 <circle cx="50" cy="30" r="25" />
 <circle cx="100" cy="30" r="25"
	 fill="red" />
 <rect x="125" y="5" 
	width="50" height="50" />
</g>

<g style="fill:navy;fill-opacity:0.3">
 <circle cx="50" cy="200" r="25" />
 <circle cx="100" cy="200" r="25" 
	 style="fill:red;fill-opacity:1" />
 <rect x="125" y="175" 
	width="50" height="50" />
</g>

<!-- smile 1 - 1 //-->

<rect x="235" y="10" width="370" height="295" stroke="blue" stroke-width="2.5" fill="none" />

<g style="fill:navy;fill-opacity:0.3">
 <circle cx="50" cy="385" r="25" />
  <g style="fill:red;fill-opacity:1">
   <circle cx="100" cy="385" r="25" />
   <rect x="125" y="360" 
	 width="50" height="50" />
  </g>
</g>

<!-- smile 1 - 2 //-->

 <g stroke="orange">
  <use xlink:href="#smile1" x="180" y="0"/>
 </g>

 <g style="fill:gray;stroke:blue">
  <use xlink:href="#smile1_1" x="400" y="0"/>
  <use xlink:href="#smile1_2" x="400" y="0"/>
    <g style="stroke:red">
     <use xlink:href="#smile1_3" x="400" y="0"/>
    </g>
 </g>

<!-- smile 2 - 1 //-->

 <g stroke="green">
  <use xlink:href="#smile2" />
 </g>

<!-- smile 2 - 2 //-->

 <g stroke="navy">
  <use xlink:href="#smile2" x="-400" y="300" />
 </g>

<!-- smile 2 - 3 //-->

 <g stroke="SpringGreen">
  <use xlink:href="#smile2_1" x="-50" y="250"/>
  <use xlink:href="#smile2_2" x="-50" y="250"/>
    <g stroke="Magenta">
     <use xlink:href="#smile2_3" x="-50" y="250"/>
    </g>
 </g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 6 : Ellipse element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/ellipse-element-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.111</id>

    <published>2008-07-12T21:30:17Z</published>
    <updated>2008-07-14T00:07:11Z</updated>

    <summary> Ellipse element(楕円要素)で描く Ellipse 要素を使った...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Ellipse element" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="ellipseelement" label="Ellipse element" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
<em>Ellipse element(楕円要素)で描く</em>
</p>
<p>
Ellipse 要素を使った面白いデザインの形を描いてみたいと思います。
<br /><br />
Ellipse element の属性(attribute)は、cx, cy, rx, ry の4つの属性があります。
<br /><br />
cx = Ellipseの 中心のX軸 (<u>C</u>enter)<br />
cy = Ellipseの 中心のY軸 (<u>C</u>enter)<br />
rx = Ellipseの X軸の半径 (<u>R</u>adius)<br />
ry = Ellipseの Y軸の半径 (<u>R</u>adius)<br />
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="ellipse.png" src="http://www.samurai-logic.com/svg/img/ellipse.png" width="602" height="304" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>]]>
        <![CDATA[<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/ellipse.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
左のEllipse は、stroke-linecap:butt; （指定されてないので初期値）でストロークがダッシュ間隔で描かれています。2つ目のEllipse は、stroke-linecap:round; ですので丸みが付いてます。またstroke-dasharray:10 20 30 20; と20px間隔で、10pxと30px で交互にストロークが描かれています。右の2つは、複数のEllipse をstroke-dasharray を巧みに使って描かれています。<br /><br />
IEで、Adobe SVG Viewer をインストールしてあれば、Altキーを押したまま上の画面をマウスでドラッグすれば動きます。また、Ctrlキーを押してクリックでズームイン、Ctrl + Shift キーを押してクリックするとズームアウトすることができます。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>

<p>
下のコードは上のSVGファイルのコードです。
</p>

<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="520">
<desc>shapes of line element</desc>
<title>rect element</title>
<defs>
<g id="grid">

  <line x1="0" y1="250" 
	x2="850" y2="250" fill="none"
	stroke-width="500" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>
</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- ellipse 1 //-->

  <ellipse cx="100" cy="100" 
	   rx="37" ry="80" 
	   fill="yellow" 
	   fill-opacity="0.4"
  	   stroke="black" 
	   stroke-width="20"
	   stroke-dasharray="5 5"
	   stroke-dashoffset="2.5" />

<!-- ellipse 2 //-->

  <ellipse cx="300" cy="100" 
	   rx="80" ry="37" 
	   fill="blue" 
	   fill-opacity="1"
  	   stroke="red" 
	   stroke-width="8"
	   stroke-dasharray="10 20 30 20"
	   stroke-dashoffset="-25"
	   stroke-linecap="round" />

<!-- ellipses 3 //-->

  <ellipse cx="525" cy="100" 
	   rx="80" ry="25" 
	   fill="gold" 
	   fill-opacity="0.5"
  	   stroke="lime" 
	   stroke-width="8"
	   stroke-dasharray="128 48"
	   stroke-dashoffset="-24.5"
	   stroke-linecap="round" />

  <ellipse cx="525" cy="100" 
	   rx="25" ry="80" 
	   fill="gold" 
	   fill-opacity="0.5"
  	   stroke="lime" 
	   stroke-width="8"
	   stroke-opacity="1"
	   stroke-dasharray="128 48"
	   stroke-dashoffset="64"
	   stroke-linecap="round" />

<!-- ellipses 4 //-->

  <ellipse cx="730" cy="100" 
	   rx="100" ry="10" 
	   fill="none" 
  	   stroke="navy" 
	   stroke-dasharray="130 19 40 19 120 19 40 19"
	   stroke-dashoffset="-37"
	   stroke-width="9" />

  <ellipse cx="760" cy="100" 
	   rx="10" ry="80" 
	   fill="none" 
  	   stroke="navy" 
	   stroke-width="9"
	   stroke-dasharray="145 18.5"
	   stroke-dashoffset="-90.5"
	   stroke-linecap="round" />

  <ellipse cx="700" cy="100" 
	   rx="10" ry="80" 
	   fill="none" 
  	   stroke="navy" 
	   stroke-width="9"
	   stroke-dasharray="145 18.5"
	   stroke-dashoffset="-90.5"
	   stroke-linecap="round" />
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 5 : Rect element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/rect-element-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.110</id>

    <published>2008-07-12T08:31:36Z</published>
    <updated>2008-07-14T00:06:41Z</updated>

    <summary> Rectangle element(四角形要素)で描く rect 要素を使った...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Rect element" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="rectangleelement" label="rectangle element" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
<em>Rectangle element(四角形要素)で描く</em><br /><br /><br />
rect 要素を使った面白いデザインの形を描いてみたいと思います。<br /><br />
rectangle element の属性(attribute)は、x, y, width, height の4つの基本属性に、 rx, ry のオプショナル属性があります。<br /><br />
</p>
<p>
x = X軸（Rectangle の左上のコーナーの位置）<br />
y = Y軸（Rectangle の左上のコーナーの位置）<br />
width = Rectangle の幅<br />
height = Rectangle の高さ<br />
rx = Rectangle のX軸の丸み(optional attribute)<br />
ry = Rectangle のY軸の丸み(optional attribute)<br />
</p>
<p>
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="rect.png" src="http://www.samurai-logic.com/svg/img/rect.png" width="603" height="304" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>]]>
        <![CDATA[<p>
<embed id="line1" height="530" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/shape3_html.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
左の2つのRectangles は、Line 要素やCircle 要素のページで説明したようにストロークをstroke-dasharray で間隔を入れる方法で描いています。<br /><br />
3番目のRectangleは、2つのrectangle を描いています。両方ともFill の色はなしで、青と黒のストロークをstroke-dasharrayを使って描いています。右のRectangleは同じように3つ描いています。一見、とても複雑な模様に見えますがコード自体はとても小さいです。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは、Fill の色を transparent とCSSのように透明設定することも出来ます。これはFill="none"と同じです。stroke の色の初期値はありませんので色を指定しないときはストロークの色はありません。
<textarea name="code" class="xml" rows="15" cols="100">

fill="transparent"
fill="none"

stroke="transparent"  <-- 意味なし

</textarea>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="530">
<desc>shapes of line element</desc>
<title>line element</title>
<defs>
<g id="grid">

  <line x1="0" y1="250" 
	x2="850" y2="250" fill="none"
	stroke-width="500" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="530" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>
</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- rectangle 1 //-->

  <rect x="50" y="20" 
	width="100" height="180"
	rx="10" ry="10"
	style="stroke:darkblue;
	stroke-width:15;
	stroke-dasharray:10 20;
	stroke-dashoffset:7.5;
	stroke-opacity:0.75;
	fill:none;
	stroke-linecap:round" />

<!-- rectangle 2 //-->

  <rect x="200" y="20"  
	width="200" height="175"
	rx="70" ry="70"
	style="stroke:yellow;
	stroke-width:70;
	stroke-dasharray:10 60;
	stroke-dashoffset:10;
	stroke-opacity:0.7;
	fill:gray;
	stroke-linecap:round" />

<!-- rectangle 3 //-->

  <rect x="450" y="30"  
	width="150" height="150"
	style="stroke:black;
	stroke-width:30;
	stroke-dasharray:30 20;
	stroke-dashoffset:15;
	fill:none" />

  <rect x="500" y="80"  
	width="50" height="50"
	style="stroke:blue;
	stroke-width:30;
	stroke-dasharray:30 20;
	stroke-dashoffset:15;
	fill:none" />


<!-- rectangle4 //-->

  <rect x="680" y="30"  
	width="150" height="150"
	style="stroke:white;
	stroke-width:25;
	stroke-dasharray:25 25;
	stroke-dashoffset:12.5" />

  <rect x="705" y="55"  
	width="100" height="100"
	style="stroke:red;
	stroke-width:25;
	stroke-dasharray:25 25;
	stroke-dashoffset:12.5;
	fill:green" />

  <rect x="730" y="80"  
	width="50" height="50"
	style="stroke:blue;
	stroke-width:25;
	stroke-dasharray:25 25;
	stroke-dashoffset:12.5;
	fill:yellow" />
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 4 : Circle element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/circle-element-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.109</id>

    <published>2008-07-12T04:18:57Z</published>
    <updated>2008-07-14T00:05:56Z</updated>

    <summary> 前回のLine要素に引き続き、今回はCircle 要素を使って面白いデザインを...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Circle element" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="circleelement" label="circle element" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
前回のLine要素に引き続き、今回はCircle 要素を使って面白いデザインをした形を描いてみたいと思います。<br /><br />Circle 要素の属性(アトリビュート)には、cx, cy, r があります。<br /><br />
cx = 円の中心のX軸の値<br />
cy = 円の中心のY軸の値<br />
 r  = 円の半径(radius)の値<br />
</p>
]]>
        <![CDATA[<p>
Circle 要素の cx, cy, r の属性の他のStyle 属性のプロパティ値はCSS の書き方もサポートされています。以下のコードは２つとも同じ円を描きます。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<circle cx="100" cy="100" r="75" 

	stroke="darkblue" 
	stroke-width="20"
	stroke-dasharray="15 16.4" 
	stroke-dashoffset="7.5"
	stroke-opacity="0.75"
	fill="red" 
	fill-opacity="0.75"
/>

 <circle cx="100" cy="100" r="75" 

       style="stroke:darkblue;   // <------Style attribute
	  stroke-width:20;
	  stroke-dasharray:15 16.4;
	  stroke-dashoffset:7.5;
	  stroke-opacity:0.75;
	  fill:red;
	  fill-opacity:0.75;" 
/>
</textarea>
</p>
<p>
<embed id="line1" height="500" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/shape2_html.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。</small>
</p>
<p>
左の円は、少し透明度のある(fill-opacity:0.75;) 赤色の円に青いストロークが間隔を開けて描かれています(stroke-dasharray:15 16.4:)。15px の長さのストロークに16.4px の隙間の間隔があります。<br /><br />
計算の仕方は...半径は、75px ですので、75 × 2 × 3.14 = 471 と円周の距離が求められます。もし15個の間隔でストロークを描きたいのであれば、471 ÷ 15 = 31.4 となりますので、その31.4 を 2つに分けます。上の円のstroke-dasharray は、15 16.4  にしています。もっと細くしたければstroke-dasharray:1 30.4; とすれば30.4px の間隔で1pxのストロークが15個描かれます。<br /><br />
右の２つは円を３つ描いて人の笑顔のようなものを描いてみました。目と口は同じ円です。<br /><br />SVGがとても強力なグラフィックツールと言われる一つ目の理由はここにあります。テキストのファイルサイズは非常に小さく収まり、拡大しても変わりません。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="500">
<desc>shapes of line element</desc>
<title>line element</title>
<defs>
<g id="grid">

  <line x1="0" y1="250" 
	x2="850" y2="250" fill="none"
	stroke-width="500" 
	stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />

  <line x1="425" y1="0" 
	x2="425" y2="400" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="0.5 9.5" />
</g>
</defs>

<!-- grids //-->

 <use xlink:href="#grid" />

<!-- circle 1 //-->

 <circle cx="100" cy="100" r="75" 
	stroke="darkblue" 
	stroke-width="20"
	stroke-dasharray="15 16.4" 
	stroke-dashoffset="7.5"
	stroke-opacity="0.75"
	fill="red" 
	fill-opacity="0.75"/>

<!-- circle 2 //-->

 <circle cx="300" cy="100" r="75" 
	stroke="orange" 
	stroke-width="20"
	stroke-dasharray="2 7.42" 
	stroke-dashoffset="4"
	fill="none" />

 <circle cx="300" cy="100" r="75" 
	stroke="blue" 
	stroke-width="40"
	stroke-dasharray="3 6.42" 
	stroke-dashoffset="0"
	fill="none" />

<!-- smile 1 //-->

<circle cx="485" cy="50" r="22" 
	stroke="blue" 
	stroke-width="10"
	stroke-dasharray="48 91" 
	stroke-dashoffset="20"
	stroke-linecap="round"
	fill="none" />

<circle cx="555" cy="50" r="22" 
	stroke="blue" 
	stroke-width="10"
	stroke-dasharray="48 91" 
	stroke-dashoffset="28"
	stroke-linecap="round"
	fill="none" />


<circle cx="520" cy="85" r="40" 
	stroke="orange" 
	stroke-width="10"
	stroke-dasharray="1 50 1 50 90 50" 
	stroke-dashoffset="22"
	stroke-linecap="round"
	fill="none" />

<!-- smile 2 //-->

<circle cx="700" cy="50" r="22" 
	stroke="orange" 
	stroke-width="10"
	stroke-dasharray="58 81" 
	stroke-dashoffset="30"
	stroke-linecap="round"
	fill="none" />

<circle cx="750" cy="50" r="22" 
	stroke="orange" 
	stroke-width="10"
	stroke-dasharray="45 112" 
	stroke-dashoffset="22.5"
	stroke-linecap="round"
	fill="none" />


<circle cx="720" cy="85" r="40" 
	stroke="red" 
	stroke-width="10"
	stroke-dasharray="1 50 1 50 90 50" 
	stroke-dashoffset="22"
	stroke-linecap="round"
	fill="none" />
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 3 : Line element SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/line-element-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.108</id>

    <published>2008-07-11T23:16:50Z</published>
    <updated>2008-07-14T00:05:18Z</updated>

    <summary>  Line 要素を使って面白いデザインをした形を描いてみたいと思います。 Li...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Line element" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="lineelement" label="line element" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[ <p>
Line 要素を使って面白いデザインをした形を描いてみたいと思います。<br /><br />
Line 要素の属性(アトリビュート)には、x1,x2,y1,y2 があります。<br /><br />
<span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="xy.png" src="http://www.samurai-logic.com/svg/img/xy.png" width="411" height="287" class="mt-image-left" style="float: left; margin: 0 20px 20px 0;" /></span>
</p>
<p>
この始点(x1, y1) と、終点(x2, y2) を指定することで線を描くことが出来ます。スタイル属性のストロークの幅のプロパティ値(stroke-width property)は、初期値が1px になりますので指定されてなければ 1px で描かれます。
</p>
<p>
下に紹介しているのはLine 要素を多様に使って描いたSVGファイルです。グリッドもLine要素を使って描いています。（通常、グリッドはパターン要素を使って描かれています）
</p>]]>
        <![CDATA[<hr style="clear:both">
<p>
<embed id="line1" height="485" width="855" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/shape1_html.svg" />
</p>
<p>
<br />
<small>W3Cで標準化されている要素、スタイル属性がサポートされているブラウザ、またはSVG Viewerプラグインをインストールしてください。 </small>
</p>
<p>
左のLine は、グリッドの背面に描かれています。これは、コードに中でグリッドよりも先に線が描かれているためです。２番目のLine はstroke-dasharray を使ったバーコードのようなLine です。３番目のLine は、stroke-linecap を丸くしてstroke-dasharray を使って描いたLine です。右の図形は、Line を２つ描いています。<br /><br />
</p>
<p>
下のコードは、LIne要素を使ってグリッドを描いたコードです。stroke-dasharrayを使用して、幅10px (1px stroke幅を 9px) 間隔のグリッドを描いています。&lt;defs&gt;タグの中で定義してから、&lt;use xlink:href=&quot;#grid&quot; /&gt; と use xlink を使って描いています。ここでは一度しか使っていませんが、同じ形の図形を何度も使用する場合に使うためのものです。一度、定義しておけば use 要素を使って多様に利用することが可能になりSVG に欠かせない要素です。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<defs>
<g id="grid">

  <line x1="0" y1="240" 
	x2="850" y2="240" fill="none"
	stroke-width="480" 
	stroke="Gainsboro"
	stroke-dasharray="1 9" />

  <line x1="425" y1="0" 
	x2="425" y2="400" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="1 9" />
</g>
</defs>
</textarea>
</p>
<p>
下のコードは上のSVGファイルのコードです。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="480">
<desc>shapes of line element</desc>
<title>line element</title>
<defs>
<g id="grid">

  <line x1="0" y1="240" 
	x2="850" y2="240" fill="none"
	stroke-width="480" 
	stroke="Gainsboro"
	stroke-dasharray="1 9" />

  <line x1="425" y1="0" 
	x2="425" y2="400" fill="none"
	stroke-width="850" stroke="Gainsboro"
	stroke-dasharray="1 9" />
</g>
</defs>

  <line x1="20" y1="20" 
	x2="120" y2="180" 
	fill="none" stroke="blue"
	stroke-width="10" 
	stroke-linecap="round" />

<!-- if the line comes first, grids will overwrite on the line //-->

 <use xlink:href="#grid" />

 <g id="figure1">

  <line x1="230" y1="100" 
	x2="330" y2="100" 
	stroke="black"
	stroke-width="100"
	stroke-dasharray="1 1 1 1 1 2 2 2 2 1 1 1 4 1 1 2 2 2 1 1 1 1 1 1 1 1"
	fill="none" />

  <line x1="440" y1="150"
	x2="620" y2="20"
	fill="none"
	stroke="DarkMagenta"
	stroke-width="20"
	stroke-dasharray="1 25"
	stroke-linecap="round" />

  <line x1="650" y1="75"
	x2="850" y2="75"
	fill="none" stroke="DarkSeaGreen"
	stroke-width="100"
	stroke-dasharray="10 10"
	stroke-opacity="0.7" />

  <line x1="650" y1="75"
	x2="850" y2="75"
	fill="none" stroke="Firebrick"
	stroke-width="100"
	stroke-dasharray="10 10 10 40"
	stroke-dashoffset="-10"
	stroke-opacity="0.7" />	 

 
 </g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 2 : SVG Fill &amp; Stroke properties</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/svg-fill-stroke-properties.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.107</id>

    <published>2008-07-09T07:30:16Z</published>
    <updated>2008-07-14T00:04:54Z</updated>

    <summary><![CDATA[ Fill プロパティ&amp; Stroke プロパティの値を指定して描写する...]]></summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Fill &amp; Stroke" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="fillstroke" label="Fill stroke" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
Fill プロパティ&amp; Stroke プロパティの値を指定して描写するインテリア色とストローク色を設定します。下にサンプル(SVGファイル)と各プロパティ値のテーブル表を作りました。
</p>
<p>
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
</p>]]>
        <![CDATA[<p>
<embed id="fill_stroke" height="410" width="850" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/fillstroke_html.svg" />
</p>
<p>
上の左にある円は、Circleの r 属性(半径)のみに値を設定した場合に描かれる円です。X軸Y軸の位置もFill,Strokeの色等が指定されていませんので、指定されていない値は初期値で描かれてます。下のようなコードを書いても同じような黒い円なります。
</p>
<textarea name="code" class="xml" rows="15" cols="100">

<circle cx="0" cy="0" r="150" fill="#000" fill-opacity="1" stroke="#000" stroke-width="1"/>

</textarea>
<p>
四角い図形は、&lt;rect&gt;要素の各属性やスタイル属性を指定して描いたものです。x軸、y軸、幅、高さ、fillの色、strokeの色、strokeの幅等に値を設定して描きます。stroke-dasharray は"25 25" と指定されてますので、25px 間隔で 25px の長さのストロークが描かれます。もしこれを、stroke-dasharray="25 25 5 5" と指定すれば、 25px 間隔で 25px の長さのストロークの次に5px 間隔で 5px の長さのストロークが描かれます。これを利用してストロークのラインだけ(line要素)で、バーコードを描くことも出来ます。stroke-dashoffset でストロークの始まりの位置が指定されます。この場合、-12.5px 後にずらした位置から描かれます。stroke-linecap は、図のように、round、butt、square の３種類のラインの両端の形が設定出来ます。また、基本単位はpx ですが、他にも、<em>em、ex、pt、pc、cm、mm</em>などの単位も使うことが出来ます。
</p>
<textarea name="code" class="xml" rows="15" cols="100">
  <rect x="175"
	y="10" 
	width="150" 
	height="150"
	fill="darkblue" 
	stroke="yellow" 
	stroke-width="15"
	stroke-dasharray="25 25" 
	stroke-dashoffset="-12.5"
	stroke-linecap="round"/> 
</textarea>
 <p>
インテリア色を白にしたい場合は、fill="#fff"、fill="#ffffff"、fill="white"、fill="rgb(100%,100%.100%)"、fill="rgb(255,255,255)"　と書くことも出来ます。色の名称は、W3Cで指定されているものは使えます。
<br /><br />
色の名称はこちらを参考：<a href="http://www.samurai-logic.com/inkscape2/color.html" target="_blank">Name, Hex, RGB of Color</a>
</p>
<p>
<table><caption><em>Fill プロパティ</em></caption>
<tr><th>プロパティ</th><th>プロパティ値の説明</th><th>値の指定</th><th>スタイル属性を使った指定</th><th>初期値</th><th>アニメーション</th></tr>
<tr><td>Fill</td><td>インテリアの色を設定<br /></td><td>fill="white"<br />fill="#ffffff"<br />fill="rgb(255,255,255)"<br />fill="rgb(100%,100%,100%)"</td><td>style="fill:white"</td><td>Black</td><td>可(Yes)</td></tr>

<tr><td>Fill-opacity</td><td>インテリアの色の透明度を設定<br />0 ～ 1の範囲</td><td>fill-opacity="0.5"</td><td>style="fill-opacity:0.5"</td><td>1</td><td>可(Yes)</td></tr>

<tr><td>Fill-rule</td><td>図形の内側-外側を交差する線によって設定<br />nonzero<br />evenodd<br />inherit</td><td>fill-rule="nonzero"</td><td>style="fill-rule:nonzero"</td><td>nonzero</td><td>可(Yes)</td></tr>
</table>
</p>

<p>
<table><caption><em>Stroke プロパティ</em></caption>
<tr><th>プロパティ</th><th>プロパティ値の説明</th><th>値の指定</th><th>スタイル属性を使った指定</th><th>初期値</th><th>アニメーション</th></tr>
<tr><td>stroke</td><td>ストロークの色</td><td>stroke="#000"</td><td>style="stroke:black"</td><td>なし(none)</td><td>可(Yes)</td></tr>
<tr><td>stroke-width</td><td>ストロークの幅</td><td>stroke-width="5"</td><td>style="stroke-width:5"</td><td>1</td><td>可(Yes)</td></tr>
<tr><td>stroke-opacity</td><td>ストロークの透明度<br />0～1の範囲</td><td>stroke-opacity="0.5"</td><td>style="stroke-opacity:0.5"</td><td>1</td><td>可(Yes)</td></tr>
<tr><td>stroke-linecap</td><td>ストロークの端の形<br />butt<br />round<br />square<br />inherit</td><td>stroke-linecap="butt"</td><td>style="stroke-linecap:butt"</td>
<td>butt</td><td>可(Yes)</td></tr>
<tr><td>stroke-linejoin</td><td>ストロークの角の形<br />miter<br />round<br />bevel<br />inherit</td><td>stroke-linejoin="miter"</td><td>style="stroke-linejoin:miter"</td>
<td>miter</td><td>可(Yes)</td></tr>
<tr><td>stroke-dasharray</td><td>ストロークのダッシュのパターン設定<br />none<br />inherit</td><td>stroke-dasharray="1 10"</td><td>style="stroke-dasharray:1 10"</td>
<td>なし(none)</td><td>可(Yes)</td></tr>
<tr><td>stroke-dashoffset</td><td>ストロークのダッシュのオフセット設定<br />inherit</td><td>stroke-dashoffset="-5"</td><td>style="stroke-dashoffset:-5"</td>
<td>0</td><td>可(Yes)</td></tr>
<tr><td>stroke-miterlimit</td><td>ストロークの角の限界比率</td><td>stroke-miterlimit="1"</td><td>style="stroke-miterlimit:1"</td>
<td></td><td>可(Yes)</td></tr>
</table>
</p>

<p>
下のコードは、上のSVGファイルのコードです。&lt;g&gt; のGroup要素や、Transformを使用したコーディーネートシステムを利用しています。それらの要素は大変重要な位置付けがされています。後の記事で具体的な説明を加えていきます。
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
         "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:xhtml="http://www.w3.org/1999/xhtml"
			 width="850" height="400">
<desc>fill stroke figures</desc>
<title>fill stroke figures</title>
<defs>
  <rect id="bg" x="0" y="0" width="850" height="400" fill="#f9f9f9" />
  <rect id="rect1" width="175" height="50" style="fill:pink; stroke:blue;stroke-width:20;stroke-opacity:0.7"/>

  <g id="r1" style="stroke-linejoin:round">
   <use xlink:href="#rect1" transform="translate(620,20)" />
    <g id="r2" style="stroke-linejoin:bevel">
     <use xlink:href="#rect1" transform="translate(620,110)" />
      <g id="r3" style="stroke-linejoin:miter">
       <use xlink:href="#rect1" transform="translate(620,200)" />
        <g id="r4" style="stroke-miterlimit:1">
         <use xlink:href="#rect1" transform="translate(620,290)" />
        </g>
      </g>	
    </g>
  </g>

</defs>

<use xlink:href="#bg" />
<use xlink:href="#r1" />

  <text
     x="650"
     y="95"
     font-family="Arial"
     font-size="15">stroke-linejoin:round</text>
  <text
     x="650"
     y="185"
     font-family="Arial"
     font-size="15">stroke-linejoin:bevel</text>
  <text
     x="650"
     y="275"
     font-family="Arial"
     font-size="15">stroke-linejoin:miter</text>
  <text
     x="650"
     y="365"
     font-family="Arial"
     font-size="15">stroke-miterlimit:1  (0-1)</text>

 <g id="figure1">

  <circle r="150" />

  <rect x="175"
	y="10" 
	width="150" 
	height="150"
	fill="darkblue" 
	stroke="yellow" 
	stroke-width="15"
	stroke-dasharray="25 25" 
	stroke-dashoffset="-12.5"
	stroke-linecap="round"/> 
  <line x1="400"
	y1="20"
	x2="400"
	y2="170"
	stroke="#000"
	stroke-width="30"
	stroke-linecap="butt" />
  <line x1="480"
	y1="20"
	x2="480"
	y2="170"
	stroke="darkgreen"
	stroke-width="30"
	stroke-linecap="round" />
  <line x1="560"
	y1="20"
	x2="560"
	y2="170"
	stroke="red"
	stroke-width="30"
	stroke-linecap="square" />

  <text
     x="75"
     y="230"
     font-family="Arial"
     font-size="15"
     text-anchor="middle">&lt;circle r=&quot;150&quot; /&gt;</text>
  <text
     x="380"
     y="210"
     font-family="Arial"
     font-size="15">butt</text>
  <text
     x="460"
     y="210"
     font-family="Arial"
     font-size="15">round</text>
  <text
     x="540"
     y="210"
     font-family="Arial"
     font-size="15">square</text>

  <text
     x="380"
     y="250"
     font-family="Arial"
     font-size="15">&lt;line x1=&quot;400&quot;
	y1=&quot;20&quot;</text>
  <text
     x="380"
     y="270"
     font-family="Arial"
     font-size="15">x2=&quot;400&quot;
	y1=&quot;170&quot;</text>
  <text
     x="380"
     y="290"
     font-family="Arial"
     font-size="15">stroke=&quot;#000&quot;
	stroke-width=&quot;30&quot;</text>
  <text
     x="380"
     y="310"
     font-family="Arial"
     font-size="15">stroke-linecap=&quot;butt&quot; /&gt;</text>

  <text
     x="150"
     y="230"
     font-family="Arial"
     font-size="15">&lt;rect x=&quot;10&quot;
	y=&quot;10&quot;</text>
  <text
     x="150"
     y="250"
     font-family="Arial"
     font-size="15">
	width=&quot;70&quot; 
	height=&quot;70&quot;</text>

  <text
     x="150"
     y="270"
     font-family="Arial"
     font-size="15">
	fill=&quot;darkblue&quot;
	stroke=&quot;yellow&quot;</text>
  <text
     x="150"
     y="290"
     font-family="Arial"
     font-size="15">
	stroke-width=&quot;15&quot;</text>
  <text
     x="150"
     y="310"
     font-family="Arial"
     font-size="15">
	stroke-dasharray=&quot;25 25&quot; </text>
  <text
     x="150"
     y="330"
     font-family="Arial"
     font-size="15">
	stroke-linecap=&quot;round&quot; </text>
  <text
     x="150"
     y="350"
     font-family="Arial"
     font-size="15">
	stroke-dashoffset=&quot;-12.5&quot;/ &gt;</text>

 </g>
</svg>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushJScript.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

<entry>
    <title>Chapter 1 : About SVG</title>
    <link rel="alternate" type="text/html" href="http://www.samurai-logic.com/svg/2008/07/about-svg.html" />
    <id>tag:www.samurai-logic.com,2008:/svg//4.106</id>

    <published>2008-07-08T04:41:13Z</published>
    <updated>2008-08-25T04:19:55Z</updated>

    <summary> IEでSVGを見るためにはプラグインが必要です。ここで紹介するSVGは、W3C...</summary>
    <author>
        <name>WebMaster</name>
        
    </author>
    
        <category term="Introduction" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="svg" label="svg" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://www.samurai-logic.com/svg/">
        <![CDATA[<p>
IEでSVGを見るためにはプラグインが必要です。ここで紹介するSVGは、W3CのWeb標準に則ったもので最も普及しているAdobe SVG Viewer 等で見ることができます。
<br /><br />
<strong>SVG Viewer:</strong><br /><br />
<a href='http://www.adobe.com/svg/viewer/install/mainframed.html'><img border='0' alt='Adobe SVG Viewer' src='http://www.samurai-logic.com/svg/img/svgdownload.gif' align='middle' width='88' height='31' /></a> 

<a href="http://www.mozilla.com/firefox/" target="_blank"><img border="0" src="http://www.samurai-logic.com/svg/img/firefox.gif" width="84" height="30"></a>

<a href="http://jp.opera.com/download/index.dml?custom=yes" target="_blank"><img border="0" src="http://www.opera.com/img/operalogo.gif" width="84" height="30"></a>
</p>

<p>
SVG(Scalable Vector Graphics)は、W3Cによってデザイン、開発された強力なオープンソースのベクターグラフィック言語です。Web標準化され、数多くの機能を持ったテキストベースのXML文法を使って記述されます。
</p>
<p>
<em>ビットマップ形式</em><br />
ビットマップグラフィックス(Bitmap graphics)のクラスに属するものををラスターグラフィックス(Raster graphics)と呼びます。ラスターグラフィックスは画像のピクセル(Pixel=Picture element)のマトリックス情報を格納する形式で描写されます。よってラスターイメージは、画像が拡大されたとき描写される画素数（ピクセル数）が少なくなるため画質が落ちます。
<br /><br />
<table><tr><caption>主なビットマップ形式(Bitmap Graphic)</caption></tr>
<tr><th>拡張子</th><th>Name(正式名称)</th></tr>
<tr><td>JPEG(.jpg)</td><td>Joint Photographic Experts Group</td></tr>
<tr><td>GIF(.gif)</td><td>Graphics Interchange Format</td></tr>
<tr><td>PNG(.png)</td><td>Portable Network Graphics</td></tr>
</table>
</p>
<p>
ベクターグラフィックスはXML文法で、イメージやフォントの形の位置、大きさ、色などを明確なXML文法を元に指定して描写されますので、拡大されても画質が落ちることは基本的<strong><sup>*1</sup></strong>にありません。
</p>
<p>
<strong><sup>*1</sup></strong><small>円の描写には円周率が用いられますが、円周率を3.14...から最後まで正確に求めることは不可能ですので完全な円を描くことはできません。そのような理由から計算される&pi;は一定の範囲に納められてますのでカーブの画質の限界はあります。</small>
</p>
<p>
下の画像は円を描いたものです。円は"circle"タグを使って描きます。
</p>]]>
        <![CDATA[<p>
<embed id="circle1" height="300" width="800" pluginspace="http://www.adobe.com/svg/viewer/install/" type="image/svg+xml" src="http://www.samurai-logic.com/svg/svg/vector.svg" />
</p>
<p>
上のSVG画像は、IE+Adove SVG Viewerプラグインで、Altキーを押したままマウスでドラッグさせると動かすことが出来ます。またCtrlキーを押したままクリックでズームイン、Ctrl+Shiftを押してクリックでズームアウトします。(FIreFoxでは、特定の属性がサポートされていないようです。）
</p>
<p>
<textarea name="code" class="xml" rows="15" cols="100">

// SVG1.0
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
                      "http://www.w3.org/TR/SVG/DTD/svg10.dtd">

 // SVG tag
<svg width="600" height="300">

 <g id="circle">　// g--->group element

  <circle
     cx="125"
     cy="125"
     r="50"
     stroke="blue"
     stroke-width="75"
     stroke-dasharray="2 8.5"
     fill="yellow"
     fill-opacity="0.75" />
  
  <text
     x="125"
     y="230"
     font-family="Arial"
     font-size="15"
     text-anchor="middle">circle with dasharray stroke</text>

 </g>
</svg>
</textarea>
</p>
<p>
このコードは上の円とテキストを描いたXMLコードです。XML文の中にSVGタグを入れて、その中で図形やテキストなどのコードを記入します。<br />
&lt;circle ...&gt;&lt;/circle&gt; &lt;---要素(エレメント)<br />
cx="125" cy="125" r="50" &lt;---"Circle"要素の属性(アトリビュート)<br /><br />
テキストタグの中の、circle with dasharray stroke をコンテンツと呼びます。<br /><br />
<u>"Circle"要素の各属性のプロパティ値</u><br />
cx属性のプロパティ値 = 125 (円の中心のX軸 (指定された範囲内の左からの距離))<br />
cy属性のプロパティ値 = 125 (円の中心のY軸 (指定された範囲内の上からの距離))<br />
r属性のプロパティ値 = 50 (円の半径)<br /><br />
strokeプロパティの値 = Blue<br />
stroke-widthプロパティの値 = 75<br />
strokeプロパティの値 = Blue<br /><br />
......
またこれらのstyleに関する属性は、style属性にまとめて書くことが出来ます。

<textarea name="code" class="xml" rows="15" cols="100">
  <circle
     cx="125"
     cy="125"
     r="50"
     style="stroke:blue; stroke-width:75; stroke-dasharray:2 8.5; fill:yellow; fill-opacity:0.75" />
</textarea>
</p>
<p>
<em>Animation</em><br />
シンプルなアニメーションは、SMIL animation で動かしたり色を変化させたりすることが出来ます。またJavaScript に少し似た ECMAScript と呼ばれるプログラム言語でブラウザ上でゲームや複雑なアニメーションを実現することが出来ます。ECMAは、European Computer Manufacturers Association を略した呼び名です。
</p>
<p>
<textarea name="code" class="JScript" rows="15" cols="100">
<script type="text/ecmascript">
<![CDATA[
// ecmascript 
var temp=""
    function changeLine(x1, x2, y1, y2) { .....   
                            }
]]&gt;
</script>
</textarea>
</p>

<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shCore.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushXml.js"></script>
<script class="javascript" src="http://www.samurai-logic.com/technical_code/code_js/shBrushJScript.js"></script>
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://www.samurai-logic.com/technical_code/code_js/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>]]>
    </content>
</entry>

</feed>
