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

<channel>
	<title>Colabrativ, Inc. &#187; SVG</title>
	<atom:link href="http://www.colabrativ.com/tag/svg/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.colabrativ.com</link>
	<description>An Experiment Documentation and Electronic Notebook Provider</description>
	<lastBuildDate>Tue, 28 Oct 2014 04:44:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Scalable Vector Graphics Pattern Examples</title>
		<link>http://www.colabrativ.com/scalable-vector-graphics-svg-pattern-examples/</link>
		<comments>http://www.colabrativ.com/scalable-vector-graphics-svg-pattern-examples/#comments</comments>
		<pubDate>Wed, 26 Feb 2014 19:23:23 +0000</pubDate>
		<dc:creator>Marc Whitlow</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Scalable Vector Graphics]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://www.colabrativ.com/?p=845</guid>
		<description><![CDATA[Scalable Vector Graphics (SVG) is a markup language for creating two dimensional graphic images. It is commonly used in HTML in combination with CSS and Javascript. If you are new to SVG, I would suggest visiting the W3schools.com SVG Tutorial. &#8230; <a href="http://www.colabrativ.com/scalable-vector-graphics-svg-pattern-examples/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.w3.org/Graphics/SVG/" target="_blank">Scalable Vector Graphics</a> (SVG) is a markup language for creating two dimensional graphic images.  It is commonly used in HTML in combination with CSS and Javascript.  If you are new to SVG, I would suggest visiting the <a href="http://www.w3schools.com/svg/" target="_blank">W3schools.com SVG Tutorial</a>. </p>
<p>An SVG pattern is used to fill any SVG element such as a circle, line or rectangle.  In this post I will give several examples of SVG patterns, and describe how they are constructed.  The technical documentation on SVG 1.1 (Second Edition) can be found at <a href="http://www.w3.org/TR/SVG11/pservers.html" target="_blank">http://www.w3.org/TR/SVG11/pservers.html</a>.</p>
<h3>Basic Setup of an SVG Pattern</h3>
<p>The pattern is defined in a <code>defs</code> element in an <code>svg</code> element, and referenced in the <code>fill</code> attribute of the SVG element using a <code>url</code> link to the pattern.  Shown below is a simple dot pattern.  The dot pattern is made up of a <code>circle</code> element in a <code>pattern</code> element.</p>
<table>
<tr>
<td>
      <svg height="21" width="45" version="1.1" xmlns="http://www.w3.org/2000/svg"><circle cx="30" cy="11" r="8" style="stroke:none; fill:red;" /></svg><br />
<span style="font-size:8pt;">Scale&nbsp;=&nbsp;2X</span>
    </td>
<td>The circle element in this example has a radius of 4 (r=&#8221;4&#8243;) and is centered at 5,5 (cx=&#8221;5&#8243; and cy=&#8221;5&#8243;).  The image of the filled circle has been enlarged two-fold. </p>
<p><code>&lt;circle x="1" y="1" cx="5" cy="5" r="4" style="stroke:none; fill:red;" /&gt;</code>
    </td>
</tr>
<tr>
<td>
      <svg height="24" width="45" version="1.1" xmlns="http://www.w3.org/2000/svg"><rect x="19" y="1" width="22" height="22" style="stroke-width:1; stroke:black; fill:none;" /><circle cx="30" cy="12" r="8" style="stroke: none; fill: red;" /></svg><br />
<span style="font-size:8pt;">Scale&nbsp;=&nbsp;2X</span>
    </td>
<td>Circle element in <code>pattern</code> element:  The circle element above is placed in a pattern element that has a width and height of 11 (<code>width="11" height="11"</code>).  The pattern has the Id (<code>id="dots-4-11"</code>) used to link to in other SVG elements, and <code>patternUnits="userSpaceOnUse"</code> attributes.  I have put a box around the pattern in the figure to our left that is not part of the dots-4-11 pattern. </p>
<p><code>&lt;pattern id="dots-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;circle cx="5" cy="5" r="4" style="stroke:none; fill:red;" /&gt;<br />
&lt;/pattern&gt;</code>
    </td>
</tr>
<tr>
<td>
      <svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><defs>
<pattern id="dots-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse"><circle cx="5" cy="5" r="4" style="stroke:none; fill:red;" /></pattern></defs>  <rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#dots-4-11);" /></svg>
    </td>
<td>Using the dots-4-11 pattern in an SVG rectangle element (&lt;rect&gt;):  A pattern is repeated both vertically and horizontally to completely fill SVG element they are referenced in.  The dots-4-11 pattern is placed in a <code>defs</code> element above the the SVG &lt;rect&gt; element that will use it.  In the 50 x 60 &lt;rect&gt; element, the dots-4-11 pattern is linked to the pattern in the style attribute using the link url(#dots-4-11).  A 1 pixel boarder has been add to the &lt;rect&gt; element (<code>stroke-width:1; stroke:black;</code>).</p>
<p><code>&lt;svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;defs&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;pattern id="dots-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;circle cx="5" cy="5" r="4" style="stroke:none; fill:red;" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/pattern&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;/defs&gt;</p>
<p>&nbsp;&nbsp;&nbsp;&lt;rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#dots-4-11);" /&gt;<br />
&lt;/svg&gt;</code>
    </td>
</tr>
</table>
<h3>SVG Diagonal Dot Pattern</h3>
<table>
<tr>
<td>
      <svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><defs>
<pattern id="diagonal-dots-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><circle cx="5" cy="5" r="4" style="stroke:none; fill:blue;" /></pattern></defs>  <rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#diagonal-dots-4-11);" /></svg>
    </td>
<td>We can take the circles-4-11 pattern above, and rotated it by 45&deg; to produce a diagonal circle pattern using the pattern attribute patternTransform (<code>patternTransform="rotate(45)"</code>).</p>
<p><code>&lt;pattern id="diagonal-dots-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;circle cx="5" cy="5" r="4" style="stroke:none; fill:blue;" /&gt;<br />
&lt;/pattern&gt;</code>
    </td>
</tr>
</table>
<h3>SVG Diagonal Circle Pattern</h3>
<table>
<tr>
<td>
      <svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><defs>
<pattern id="diagonal-circles-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><circle cx="5" cy="5" r="4" style="stroke-width:2; stroke:green; fill:none;" /></pattern></defs>  <rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#diagonal-circles-4-11);" /></svg>
    </td>
<td>We can take the dots-4-11 pattern above, and set stroke-width, stroke and fill to 2, green and none, respectively (<code>stroke-width:4; stroke:green; fill:none;</code>) to create green circles.</p>
<p><code>&lt;pattern id="diagonal-circles-4-11" x="0" y="0" width="11" height="11" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;circle cx="5" cy="5" r="4" style="stroke-width:2; stroke:green; fill:none;" /&gt;<br />
&lt;/pattern&gt;</code>
    </td>
</tr>
</table>
<h3>SVG Diagonal Stripes Pattern</h3>
<table>
<tr>
<td>
      <svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><defs>
<pattern id="diagonal-stripes-4-8" x="0" y="0" width="8" height="8" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect x="0" y="0" width="4" height="8" style="stroke:none; fill:purple;" /></pattern></defs>  <rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#diagonal-stripes-4-8)" /></svg>
    </td>
<td>To create a diagonally striped pattern, we fill one half the pattern with a purple rectangle (<code>&lt;rect&gt;</code>), and then rotate the pattern by 30&deg; (<code>patternTransform="rotate(30)"</code>).</p>
<p><code>&lt;pattern id="diagonal-stripes-4-8" x="0" y="0" width="8" height="8" patternUnits="userSpaceOnUse" patternTransform="rotate(30)"&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;rect x="0" y="0" width="4" height="8" style="stroke:none; fill:purple;" /&gt;<br />
&lt;/pattern&gt;</code>
    </td>
</tr>
</table>
<h3>SVG Grid Pattern</h3>
<table>
<tr>
<td>
      <svg height="50" width="60" version="1.1" xmlns="http://www.w3.org/2000/svg"><defs>
<pattern id="grid-4-10" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse"><rect x="0" y="0" width="10" height="4" style="stroke:none; fill:orange;" /><rect x="3" y="3" width="4" height="10" style="stroke:none; fill:orange;" /></pattern></defs>  <rect x="1" y="1" height="48" width="58" style="stroke-width:1; stroke:black; fill:url(#grid-4-10)" /></svg>
    </td>
<td>To create a grid pattern, we create a plus sign in the pattern using two 4 x 10 rectangles (<code>&lt;rect&gt;</code>), one running horizontally (<code>width="10" height="4"</code>) and the other running vertically (<code>width="4" height="10"</code>) through the 10 x 10 pattern. </p>
<p><code>&lt;pattern id="grid-4-10" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse"&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;rect x="0" y="0" width="10" height="4" style="stroke:none; fill:orange;" /&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;rect x="3" y="3" width="4" height="10" style="stroke:none; fill:orange;" /&gt;<br />
&lt;/pattern&gt;</code></p>
<p>A grid can be changed into a plaid pattern by changing the <code>fill-opacity</code> to 0.5.
    </td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.colabrativ.com/scalable-vector-graphics-svg-pattern-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
