<?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>From Accessibility to Zope &#187; SVG</title>
	<atom:link href="http://blog.mauveweb.co.uk/category/svg/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mauveweb.co.uk</link>
	<description>experiments in contemporary web development</description>
	<lastBuildDate>Thu, 18 Aug 2011 23:26:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bubble Background Animation</title>
		<link>http://blog.mauveweb.co.uk/2008/10/11/bubble-background-animation/</link>
		<comments>http://blog.mauveweb.co.uk/2008/10/11/bubble-background-animation/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 14:44:31 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Artwork]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=182</guid>
		<description><![CDATA[I was pondering concepts for interesting web designs when the idea occurred to me that an animated bubble effect might lend a peaceful ambience to a webpage. I experimented with placing a Javascript-controlled SVG animation into the background of a page. You might like to judge for yourself whether this is successful or not (SVG-enabled [...]]]></description>
			<content:encoded><![CDATA[<p>I was pondering concepts for interesting web designs when the idea occurred to me that an animated bubble effect might lend a peaceful ambience to a webpage. I experimented with placing a Javascript-controlled <acronym title="Scalable Vector Graphics">SVG</acronym> animation into the background of a page. You might like to <a href="http://mauveweb.co.uk/bubbles/">judge for yourself</a> whether this is successful or not (<acronym title="Scalable Vector Graphics">SVG</acronym>-enabled browser required and a reasonably fast CPU recommended).</p>
<p>If you were around at the dawn of dynamic <acronym title="HyperText Markup Language">HTML</acronym> you will probably have stumbled across amateur websites who thought it was really rather stylish to add a Javascript snow or bubble effect over the top of the page content.</p>
<p>Fortunately, those days are gone. By and large, it seems that amateur webmasters today know that just a nice colour scheme and a consistent, simple style trump a jumble of styles, javascript effects and stock animated GIFs that we all remember too well. Nice graphic design is done for you if you just install a blog and browse existing themes. Some may not even remember effects like <a href="http://www.dynamicdrive.com/dynamicindex3/bubble.htm">this</a> (Warning: Not safe for work or indeed any other time you require functioning eyeballs).</p>
<p>It's well-known that animations draw the user's attention in webpages. That doesn't mean we always want to avoid them: sometimes we want to direct the user's attention in one direction or another, particularly when the page is being updated dynamically with Javascript. This is not one of those special cases. Since the goal of this experiment is to build a fully-animated webpage, we will have to ignore that inconvenient little fact. However, this suggests we need to keep the animation as unintrusive as possible. Keeping it nice and slow may help, and it should certainly be in the background and not the foreground.</p>
<p><acronym title="Scalable Vector Graphics">SVG</acronym> is useful for this kind of effect because it has a feature (&lt;svg:use&gt;) for manipulating independent clones of a symbol. It is therefore simple to draw the original shape using an <acronym title="Scalable Vector Graphics">SVG</acronym> editor, and the Javascript merely needs to manage instances of the clones.</p>
<p>Using Inkscape, I drew up a bubble looks like this:</p>
<div style="background-color: #2771a1; padding: 5px; text-align: center;"><img src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/bubble.png" alt="Bubble" /></div>
<p>There's a certain knack to drawing bubbles like this, of course. Air bubbles in water are colourless, but they are reflective due to total internal reflection. The amount of reflection increases as the angle of incidence increases, up to the critical angle, at which all light is reflected. At a water-air boundary the critical angle is 48.6° so actually the bubble should appear totally reflective from about 75% of the radius.</p>
<p>If this sends you into a bit of a panic as you struggle to remember your school physics lessons, don't worry. I'm not recommending a mathematically accurate implementation of <a href="http://en.wikipedia.org/wiki/Fresnel_equations">Fresnel's Equations</a>. With a lot of art (not just on computers), an appreciation of the physics can go a long way towards adding realism. But a 100% accurate simulation is not necessary for an effect to seem convincing &#8211; trial and error is much easier. The gradient as I've drawn it is not accurate but looks alright. Similarly, bubbles have two specular highlights corresponding to the water-air boundary and the air-water boundary.</p>
<p>As an aside, one day it may be possibly to depict fully reflective and refractive bubbles. Using <acronym title="Scalable Vector Graphics">SVG</acronym>'s incredible feDisplacementMap filter, you could distort the background using a pre-computed "lens" image. But that is unlikely to run at interactive speeds today, even if the filters required were fully and accurately supported, which they are not. The bubbles I've drawn are intended to be a compromise between rendering simplicity and attractiveness.</p>
<p>The bubble system (really just <a href="http://mauveweb.co.uk/bubbles/bubbles.svg">the <acronym title="Scalable Vector Graphics">SVG</acronym> on its own</a>) animates 20 clones of the bubble symbol. Again, this is based on some physical principles. The smaller bubbles are subject to less drag so have a higher terminal velocity, bubbles grow slightly as they rise and the pressure decreases and so on. One of the most effective things is that the bubbles drift with a random walk: they can randomly drift to one side or the other. They don't go straight up nor do they oscillate sinusoidally like the classic DynamicDrive script. For the most effective animation, bubbles would drift with the currents but this is simpler and reasonably effective.</p>
<p>I am quite pleased with the results. To really rid ourselves of the legacy of Javascript-animated <acronym title="Graphics Interchange Format">GIF</acronym> images, it would be important for this effect to tie in with the graphic design of the page, which I haven't shown.</p>
<p>I don't think this is realistically ready for production websites: Internet Explorer cannot display <acronym title="Scalable Vector Graphics">SVG</acronym>, for one thing, and the intensive CPU requirement is also a problem. But I do think that sharp <acronym title="Scalable Vector Graphics">SVG</acronym> graphics allow us to produce a wholly better standard of animation than what was possible before. With this, I think it's possible to make a bubble animation complement rather than detract from a web page.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2008/10/11/bubble-background-animation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SVG Buttons</title>
		<link>http://blog.mauveweb.co.uk/2008/10/09/svg-buttons/</link>
		<comments>http://blog.mauveweb.co.uk/2008/10/09/svg-buttons/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 23:39:22 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=168</guid>
		<description><![CDATA[With SVG filters, it's easier than ever to create stylish graphical buttons for the web.
Using images for buttons is a much more pragmatic approach than attempting to style buttons with CSS, at least until widespread support for CSS3's draft-but-stable border-image property is available.
Up until a couple of years ago, I had generally created buttons using [...]]]></description>
			<content:encoded><![CDATA[<p>With <acronym title="Scalable Vector Graphics">SVG</acronym> filters, it's easier than ever to create stylish graphical buttons for the web.</p>
<p>Using images for buttons is a much more pragmatic approach than attempting to style buttons with <acronym title="Cascading Style Sheets">CSS</acronym>, at least until widespread support for <acronym title="Cascading Style Sheets">CSS3</acronym>'s draft-but-stable border-image property is available.</p>
<p>Up until a couple of years ago, I had generally created buttons using a <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> script that glued them together:</p>
<p><img src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/add_to_basket.png" alt="Example of Add To Basket button" /></p>
<p>This was a useful when working with <acronym title="eXtensible Stylesheet Language">XSL</acronym>, allowing me to simply call a template to include an arbitrary button text, rather than linking to a static button image.</p>
<p>Because I now use Django for most of my sites, this technique is no longer relevant. Because I'm not now producing templates to transform an arbitrary <acronym title="eXtensible Markup Language">XML</acronym> model, but producing templates to render specific models, I know when writing the template what buttons it will require. A typical button, designed for editing convenience, would look like this:</p>
<p><img src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/but_add_basket.png" alt="Example of Add To Basket button" /></p>
<p>This button is a rounded rectangle with a gradient. The label is typed twice to give it a slightly inset look. Even though you have to retype the label twice to change a button, it takes only a few seconds to change the label and adjust the width of the rectangle to fit.</p>
<p>Inkscape 0.46 provided access to a wide range of <acronym title="Scalable Vector Graphics">SVG</acronym> filters, making the process even simpler. Buttons are now never more complicated than a rectangle, a label, and the <acronym title="Scalable Vector Graphics">SVG</acronym> filters to make them look pretty and three-dimensional:</p>
<p><img src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/view-products.png" alt="Example of View Products button" /></p>
<p>Changing a button is as simple as it can be. Or is it?</p>
<p>I sometimes like to connect adjacent buttons into one strip, something which will be familiar to Mac <acronym title="Operating System">OS</acronym> X users:</p>
<p><img src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/snapping-buttons1.png" alt="Example of connected buttons" /></p>
<p><acronym title="Scalable Vector Graphics">SVG</acronym> filters can make this a doddle too. By using <acronym title="Scalable Vector Graphics">SVG</acronym> filters to create all of the graphical effects, including the rounded corners, these buttons can be dragged together and automatically connect with one another. The filter is applied to the layer, and the above buttons are editable simply as rectangles.</p>
<p>Try it: <a href="http://blog.mauveweb.co.uk/wp-content/uploads/2008/10/magic_snapping_buttons.svg">Download the <acronym title="Scalable Vector Graphics">SVG</acronym></a> (Inkscape 0.46+ recommended).</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2008/10/09/svg-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVG Goo</title>
		<link>http://blog.mauveweb.co.uk/2008/08/31/svg-goo/</link>
		<comments>http://blog.mauveweb.co.uk/2008/08/31/svg-goo/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 15:20:04 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Artwork]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=155</guid>
		<description><![CDATA[It's a well known computer graphics technique that blobby shapes can be drawn as the isosurface of a scalar field.
It's actually possible to create a similar effect using SVG filters:

The field is created using Gaussian-blurred circles. Where these soft edges overlap, the alpha channels are composited and this creates the necking effect which is key [...]]]></description>
			<content:encoded><![CDATA[<p>It's a well known computer graphics technique that blobby shapes can be drawn as the isosurface of a scalar field.</p>
<p>It's actually possible to create a similar effect using <acronym title="Scalable Vector Graphics">SVG</acronym> filters:</p>
<p><img class="size-full wp-image-159" title="goo" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/08/goo.png" alt="Blobby, ketchuppy shapes" width="500" height="495" /></p>
<p>The field is created using Gaussian-blurred circles. Where these soft edges overlap, the alpha channels are composited and this creates the necking effect which is key to blobby shapes like this.</p>
<p>The thresholding is done using a high-contrast filter on the alpha channel. The specular highlight was added just to emphasise the gooey, ketchup-y effect.</p>
<p>If you have a copy of Inkscape, it's fun to play with dragging the circles. Feel free to <a href="http://blog.mauveweb.co.uk/wp-content/uploads/2008/08/goo.svg">download the <acronym title="Scalable Vector Graphics">SVG</acronym></a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2008/08/31/svg-goo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVG filters with Inkscape 0.46</title>
		<link>http://blog.mauveweb.co.uk/2008/04/19/svg-filters-with-inkscape-046/</link>
		<comments>http://blog.mauveweb.co.uk/2008/04/19/svg-filters-with-inkscape-046/#comments</comments>
		<pubDate>Sat, 19 Apr 2008 11:40:01 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Artwork]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=138</guid>
		<description><![CDATA[One of the most stunningly powerful features of the recently release Inkscape 0.46 is the ability to design SVG filters. SVG filters are a section of the SVG language for connecting simple, well-defined raster operations and applying those to rasterised vector shapes in the document.
What this entails is that it's possibly to take very simple [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most stunningly powerful features of the recently release <a href="http://www.inkscape.org/">Inkscape 0.46</a> is the ability to design <acronym title="Scalable Vector Graphics">SVG</acronym> filters. <acronym title="Scalable Vector Graphics">SVG</acronym> filters are a section of the <acronym title="Scalable Vector Graphics">SVG</acronym> language for connecting simple, well-defined raster operations and applying those to rasterised vector shapes in the document.</p>
<p>What this entails is that it's possibly to take very simple vector shapes, bung on a filter, and get some very pretty artwork <strong>which can still be edited as paths.</strong></p>
<p>Inkscape's 0.45 release saw the implementation of its first filter: Gaussian blur. On its own, Gaussian blur was an incredible useful filter, offering soft edges and powerful shading techniques. But with the collection of other filters provided, it also provides a building block for constructing some very complicated and useful graphical operations that could previously only be done with a raster tool like The Gimp.</p>
<p>Unfortunately, you will need a fairly deep knowledge of 2D image processing to make use of <acronym title="Scalable Vector Graphics">SVG</acronym> filters. Fortunately I have one of these. Allow me to walk you through creating a filter in Inkscape 0.46.</p>
<p>I want to start with an example of a graphic I created way way back with Inkscape 0.38.</p>
<p><img class="alignnone size-full wp-image-136" title="original" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/original.png" alt="Original Mauveweb logo" width="450" height="113" /></p>
<p>I created this graphic by drawing a blob, adding some text (in a font called "Balcony Angels") and then painstakingly drawing out the highlights (specular lighting) as partially-transparent white paths. It's also got a drop shadow.</p>
<p>Let's start again in Inkscape 0.46. I'm using the star tool with a bit of randomness to start me out with a blob. The wording is just normal text but I've tweaked the kerning a little this time. Also notice the gradient. Depending on how you wire up your filters you can preserve the colours and using a bit of gradient will always help to give a word-art logo like this a bit more richness.</p>
<p><img class="alignnone size-full wp-image-140" title="plain" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/plain.png" alt="" width="450" height="133" /></p>
<p>To add lighting, you need a height map. The simplest way to create a height map is by applying a <strong>gaussian blur</strong>. <acronym title="Scalable Vector Graphics">SVG</acronym> uses the alpha channel to represent the height map. Without a blur you can imagine that the height is 0% outside the shape and 100% inside &#8211; like a cliff or a plateau. With a blur you have a partially transparent edge, so it smoothly rises from the 0 to the 100%, like rolling hills. I usually apply the blur to the alpha channel as the colour channels aren't relevant.</p>
<p><img class="alignnone size-full wp-image-142" title="blur" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/blur.png" alt="" width="450" height="158" /></p>
<p>You can only see a 3D shape appear when we wire up a lighting filter. <strong>Specular lighting</strong> is what we're shooting for. The output of specular lighting is just the highlights so make sure the document background is set to opaque black before you start experimenting.</p>
<p><img class="alignnone size-full wp-image-143" title="specular_on_black" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/specular_on_black.png" alt="" width="450" height="149" /></p>
<p>Specular lighting is very sensitive to some of the settings you're using.</p>
<ul>
<li><strong>Surface scale</strong> &#8211; here's where we say what the 100% height of the height map actually is. Generally you should stick to small positive numbers. Try 10. The gradient of the bumpy edges can be thought of as this number over the blur radius. If you've got 10px of blur, and a surface scale of 10, your bumpy edges should have a 1:1 gradient.</li>
<li><strong>Constant</strong> &#8211; this number combines two ideas: how bright the light source is, and how much light the object reflects. 0 means that the light is off, so that's not what you want. Numbers between 0 and 1 mean the object reflects a fraction of the light, or the light is dim. Numbers over 1 mean that the light is brighter. It's all relative, obviously.</li>
<li><strong>Exponent</strong> &#8211; this is the glossiness of the surface. The higher the exponent, the tighter the highlights. Metals have quite low exponents &#8211; say 10. 30ish gives a soft plastic. Higher gives the effect of ceramics and polished surfaces.</li>
<li><strong>Light Source</strong> &#8211; start with distant light, azimuth 225, elevation 25 and experiment from there. That will give you the kind of lighting from the top-left that mimics the user interface of most computers.</li>
</ul>
<p>The outer halo, if you're wondering, is where the light catches off the bottom of the slope. We can clip that away at the same time as we apply it to the shape. To do this, we use an <strong>atop</strong> filter. The top input is the highlights, the bottom is the source graphic. <strong>Atop</strong> draws the highlights only over the source graphic. This is equivalent to (specular <strong>in</strong> source alpha) <strong>over</strong> source grahic.</p>
<p><img class="alignnone size-full wp-image-141" title="specular" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/specular.png" alt="" width="450" height="133" /></p>
<p>We can also add the outline from the original. If we added it before the filtering, it would have also been shaded because the outline would be part of the alpha channel that we bumpmapped. We need a raster outline. We can do this using the <strong>morphology</strong> filter.</p>
<p>We dilate the source alpha channel and <strong>composite</strong> the original over the top. Voila:</p>
<p><img class="alignnone size-full wp-image-145" title="morphology" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/morphology.png" alt="" width="450" height="137" /></p>
<p>And then there's a slight drop shadow. <strong>Gaussian blur</strong> the same <strong>morphology</strong> filter, add a couple of pixels of <strong>offset</strong>. Then <strong>composite</strong> the previous stage back on top of it.</p>
<p><img class="alignnone size-full wp-image-146" title="shadow" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/shadow.png" alt="" width="450" height="139" /></p>
<p>If the shadow &#8211; or indeed the highlights are too bright, you can make them slightly transparent with a <strong>colour matrix</strong> filter. The fourth row of the colour matrix is the alpha channel, and the fourth column of that row is how much of the alpha channel to pass through. Change it to any number between 0 and 1 to make it partially transparent.</p>
<p>I've got one last trick up my sleeve, and it's the most complicated one.</p>
<p>I'm going to decrease the exponent on the specular filter a little to give me bigger highlights. Then I want to <em>increase the contrast on the alpha channel.</em> This can be done with a <strong>colour matrix</strong> filter. I set the last row to (0, 0, 0, 4.0, -1.5). This means that the alpha channel will be mapped a -&gt; 4a &#8211; 1.5. This will to some extent remove the partial shades in the specular highlight and give me a more cartoon effect:</p>
<p><img class="alignnone size-full wp-image-148" title="final" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/final.png" alt="" width="450" height="139" /></p>
<p>This is how the final filter is wired:</p>
<p><a rel="attachment wp-att-149" href="http://blog.mauveweb.co.uk/2008/04/19/svg-filters-with-inkscape-046/filter_wiring/"><img class="alignnone size-medium wp-image-149" title="filter_wiring" src="http://blog.mauveweb.co.uk/wp-content/uploads/2008/04/filter_wiring-300x288.jpg" alt="Screenshort of the wiring for the Mauveweb logo filter" width="300" height="288" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2008/04/19/svg-filters-with-inkscape-046/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fruit and Veg</title>
		<link>http://blog.mauveweb.co.uk/2006/11/21/fruit-and-veg/</link>
		<comments>http://blog.mauveweb.co.uk/2006/11/21/fruit-and-veg/#comments</comments>
		<pubDate>Tue, 21 Nov 2006 15:39:21 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Artwork]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/2006/11/21/fruit-and-veg/</guid>
		<description><![CDATA[Was playing around with Inkscape last night and ended up doodling some clip art of some fruit and veg.
Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>Was playing around with Inkscape last night and ended up doodling some clip art of some fruit and veg.</p>
<p>Enjoy!</p>
<p><img alt="Fruit and Veg" id="image42" src="http://blog.mauveweb.co.uk/wp-content/uploads/2006/11/clipart.png" /></p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/11/21/fruit-and-veg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Batik</title>
		<link>http://blog.mauveweb.co.uk/2006/11/17/apache-batik/</link>
		<comments>http://blog.mauveweb.co.uk/2006/11/17/apache-batik/#comments</comments>
		<pubDate>Fri, 17 Nov 2006 15:42:23 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/2006/11/17/apache-batik/</guid>
		<description><![CDATA[I installed Apache Batik for the first time last night. Batik is a Java library for SVG, particularly rasterising drawings. It did exactly what I needed (converting SVG graphs to PNG) without much fuss, either with installation or integration (I used the commandline rasteriser). I'd just not had a situation where I'd needed something other [...]]]></description>
			<content:encoded><![CDATA[<p>I installed <a href="http://blog.mauveweb.co.uk/Apache%20Batik">Apache Batik</a> for the first time last night. Batik is a Java library for <acronym title="Scalable Vector Graphics">SVG</acronym>, particularly rasterising drawings. It did exactly what I needed (converting <acronym title="Scalable Vector Graphics">SVG</acronym> graphs to <acronym title="Portable Network Graphics">PNG</acronym>) without much fuss, either with installation or integration (I used the commandline rasteriser). I'd just not had a situation where I'd needed something other than Inkscape's commandline before.</p>
<p>I did have to install some nicer ttf fonts as there weren't any installed apart from Lucida in the <acronym title="Java Runtime Environment">JRE</acronym>, but simply using aptitude to install an xfonts package worked.</p>
<p>It was a little slower than I had hoped, unfortunately, even for these very simple graphs, which means that working with this in web apps won't be quite as straightforward. It was much faster doing batches than individual graphs.</p>
<p>Anyway, server-side rasterisation is one obstacle to <acronym title="Scalable Vector Graphics">SVG</acronym> adoption which happily proves relatively simple to overcome.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/11/17/apache-batik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Construction in Inkscape</title>
		<link>http://blog.mauveweb.co.uk/2006/09/25/construction-in-inkscape/</link>
		<comments>http://blog.mauveweb.co.uk/2006/09/25/construction-in-inkscape/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 22:51:25 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Artwork]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/2006/09/25/construction-in-inkscape/</guid>
		<description><![CDATA[Sometimes &#8211; increasingly perhaps &#8211; I find myself using Inkscape for constructing program assets.
Program assets are a different beast to standalone artworks because you start to have to recombine artistic elements in new ways programmatically.
Most of the time, when web programming, you don't really need to generate completely original artwork on the fly, but you [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes &#8211; increasingly perhaps &#8211; I find myself using Inkscape for constructing program assets.</p>
<p>Program assets are a different beast to standalone artworks because you start to have to recombine artistic elements in new ways programmatically.</p>
<p>Most of the time, when web programming, you don't really need to generate completely original artwork on the fly, but you often need to composite some selection of pre-drawn assets. There are a variety of ways to do this, but Inkscape doesn't seem to make any of them very easy for me.</p>
<p><span id="more-17"></span><strong>Composition of minimal <acronym title="Portable Network Graphics">PNGs</acronym><br />
</strong></p>
<p>Export <acronym title="Portable Network Graphics">PNGs</acronym> from Inkscape and composite them elsewhere, using external data or hard-coding to get them all to composite in the right place. This involves working out offsets, either by trial and error or trying to read them off the rulers in Inkscape. But, madly, the rulers and coordinates in Inkscape <a href="http://sourceforge.net/tracker/index.php?func=detail&#038;aid=1560175&#038;group_id=93438&#038;atid=604306">have the <em>y</em>-axis inverted</a>.</p>
<p>You also have to build the document in Inkscape so that the various elements can be exported with the alpha channel &#8211; independently of shapes above and below the one you're trying to export. This means everything has to either be cloned off the page, or drawn on a seperate layer so that it can be independently hidden.</p>
<p>If you're actually attempting to composite <acronym title="Portable Network Graphics">PNGs</acronym> client-side in <acronym title="Internet Explorer">IE</acronym>, you need to use the <acronym title="Portable Network Graphics">PNG</acronym> alpha hack, which isn't universally applicable.</p>
<p><strong>Composition of padded <acronym title="Portable Network Graphics">PNGs</acronym><br />
</strong></p>
<p>Export <acronym title="Portable Network Graphics">PNGs</acronym> that are padded such that they can all be composited using one origin. This can be done in Inkscape, but it still isn't easy, because Inkscape only has the option to export the selection. The trick is to create completely transparent bounding rectangles and use these to store Inkscape's export settings. The resulting graphics are larger in filesize than they might otherwise be, and composition could also be slower.</p>
<p>This <a href="http://www.mauveweb.co.uk/clock/"><acronym title="Dynamic HyperText Markup Language">DHTML</acronym> clock</a> I wrote a while back mainly uses this method.</p>
<p><strong>Export <acronym title="Scalable Vector Graphics">SVG</acronym></strong></p>
<p>Export <acronym title="Scalable Vector Graphics">SVG</acronym> and write a program to import, modify/compose and potentially rasterise. Rasterisation is still tricky. It will be really useful when browsers get more widespread support for <acronym title="Scalable Vector Graphics">SVG</acronym>.</p>
<p>Still, this method requires painstaking care making sure that all the symbols are easy to recombine. It often means using a lot of svg:use elements (clones in Inkscape lingo), or, more easily, rewriting the xlink:href attribute to repoint the link to a different symbol. Doing it this way preserves the affine transform, but creating your own transforms (for a newly created clone, say) is still tricky.</p>
<p>The <a href="http://blog.mauveweb.co.uk/2006/09/18/svg-cities-with-greasemonkey/"><acronym title="Scalable Vector Graphics">SVG</acronym> Cities interface</a> I mentioned recently uses this method.</p>
<p><strong>Draw out all the permutations</strong></p>
<p>Generate lots and lots of permutations using Inkscape, perhaps using a script to accelerate exporting them. This only works if the number of permutations is small, if it's possible to use only a subset of them, or if they can be generated en masse using Inkscape's excellent <em>Tile Clones</em> tool.</p>
<p>This is the approach I'm about to take with this <acronym title="Dynamic HyperText Markup Language">DHTML</acronym> dice widget I'm working on. First I've drawn out my base dice, then I've cloned one face onto the sides of one die.<br />
<span class="imagelink"><img id="image19" alt="Web-based Dice (work in progress)" src="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/dice_under_development.png" /></span></p>
<p>Now I can align the 5 currently unused faces over the 5-side, then modify the links using Inkscape's <acronym title="eXtensible Markup Language">XML</acronym> editor:<br />
<span class="imagelink"><img id="image20" alt="One complete die" src="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/dice_under_development2.png" /></span></p>
<p>Some of the problems I've come across in Inkscape when used for this kind of work include:</p>
<ul>
<ol>
<li>As mentioned, the <em>y</em> coordinates are all wrong so any coordinates you read off the UI have to be mapped y -> (document height &#8211; y)</li>
<li>Inkscape doesn't offer any way to make symbols more invariant. Ungrouping and regrouping works, but is time-consuming.</li>
<li>There isn't an easy way to manage which clones link where, or re-link clones on mass. In fact the only way to re-link clones is with the rather dire <acronym title="eXtensible Markup Language">XML</acronym> editor.</li>
<li>Inkscape doesn't let you group 1 primitive, even though this is both valid and useful.</li>
<li>Inkscape doesn't let you create offscreen symbols for use with clones.</li>
<li>Inkscape doesn't make it easy to set IDs for things.</li>
<li>All IDs generated by Inkscape are meaningless alphanumeric strings. Clones, for example, don't inherit any part of their parent symbol's ID.</li>
<li>Inkscape has a "label" as well as IDs. Label overrides ID in all of Inkscape's <acronym title="User Interface">UI</acronym>, even though they are also meaningless alphanumeric strings, useless in the programming, and they must be set independently of the ID.</li>
</ol>
<ul /></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/09/25/construction-in-inkscape/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SVG Cities with Greasemonkey</title>
		<link>http://blog.mauveweb.co.uk/2006/09/18/svg-cities-with-greasemonkey/</link>
		<comments>http://blog.mauveweb.co.uk/2006/09/18/svg-cities-with-greasemonkey/#comments</comments>
		<pubDate>Mon, 18 Sep 2006 18:55:41 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=11</guid>
		<description><![CDATA[I've been experimenting with using Greasemonkey to rewrite the interface to a game I've been playing recently called Cities. I was trying this because I wanted to test how well a native SVG interface to a web application might work, and it was much easier to work with an existing web application &#8211; one that [...]]]></description>
			<content:encoded><![CDATA[<p>I've been experimenting with using Greasemonkey to rewrite the interface to a game I've been playing recently called <a href="http://cities.totl.net/">Cities</a>. I was trying this because I wanted to test how well a native <acronym title="Scalable Vector Graphics">SVG</acronym> interface to a web application might work, and it was much easier to work with an existing web application &#8211; one that I use &#8211; than developing one as I go.</p>
<p>Here's a screenshot of the standard Cities viewport (with <acronym title="Cascading Style Sheets">CSS</acronym> styles by Bebe):</p>
<p><a class="imagelink" title="Cities HTML View" href="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/cities_html_grab.jpg"><img id="image9" alt="Cities HTML View" src="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/cities_html_grab.thumbnail.jpg" /></a></p>
<p>And this the current status of my viewport implementation:</p>
<p><a class="imagelink" title="My SVG Cities View" href="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/cities_svg_grab.jpg"><img id="image10" alt="My SVG Cities View" src="http://blog.mauveweb.co.uk/wp-content/uploads/2006/09/cities_svg_grab.thumbnail.jpg" /></a></p>
<p><span id="more-11"></span>Cities is a browser-based <acronym title="Massively Multiplayer Online game">MMO</acronym>. It's a slightly off-beat fantasy game with some humourous elements and not very many quests. Many of the rules are based on alignment, which is one of the four classical elements: earth, air, fire and water. It's alright, and quite fun when you get a couple of the alignment quests under your belt and the game starts to open up a bit, but the design isn't very polished and much of the world is fairly large, boring and featureless.</p>
<p>Anyway, it's quite well developed as a web application, and I play a little bit daily, so it's a good candidate for my experiments.I decided to use Greasemonkey after trying some of the Greasemonkey scripts other people have written to add the features they wanted to Cities. The approach I wanted to use was to replace the viewport with an <acronym title="Scalable Vector Graphics">SVG</acronym> OBJECT on my server, and configure the OBJECT with Javascript by parsing the data out of the standard viewport's <acronym title="Document Object Model">DOM</acronym> tree. However, Firefox's Javascript sandbox prevented me from accessing the OBJECT's .contentDocument property because the <acronym title="Scalable Vector Graphics">SVG</acronym> was loaded from a different domain. This is to prevent cross-site scripting vulnerabilities.</p>
<p>The first thing that occurred to me as a workaround would be to host the <acronym title="Scalable Vector Graphics">SVG</acronym> on the Cities Wikimedia Wiki. Then by assigning a value to document.domain (this is allowed iff you're generalising from a subdomain, which the wiki is) you can permit the <acronym title="Cross-site scripting">XSS</acronym>.</p>
<p>But in fact I didn't try this because this would require me to update the version on the Wiki every time I wanted to test a page load. So in fact the approach I took was to load the entire <acronym title="Scalable Vector Graphics">SVG</acronym> with a Greasemonkey <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> request (has to be a <acronym title="Greasemonkey">GM</acronym> <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> &#8211; the vanilla kind also has <acronym title="Cross-site scripting">XSS</acronym> security) and import the <acronym title="Scalable Vector Graphics">SVG</acronym> <acronym title="Document Object Model">DOM</acronym> into the <acronym title="HyperText Markup Language">HTML</acronym> <acronym title="Document Object Model">DOM</acronym>. Firefox in fact renders this combination better than it renders an <acronym title="Scalable Vector Graphics">SVG</acronym> OBJECT, because it can use the native dimensions of the <acronym title="Scalable Vector Graphics">SVG</acronym> from the <acronym title="Scalable Vector Graphics">SVG</acronym> documentElement rather than you having to respecify them as attributes of the OBJECT element.</p>
<p>For the parsing of the <acronym title="Document Object Model">DOM</acronym> tree, I would have liked to have used <acronym title="ECMAscript for XML">E4X</acronym>, but it doesn't appear to work. This could just be a Greasemonkey limitation, because Greasemonkey uses XPCNativeWrapper for security reasons, or it might be that <acronym title="ECMAscript for XML">E4X</acronym> doesn't interoperate well with <acronym title="Document Object Model">DOM</acronym> yet. It didn't occur to me at the time that I could have used <acronym title="eXtensible Stylesheet Language Transformations">XSLT</acronym>, but there was quite a bit of processing involved in configuring the <acronym title="Scalable Vector Graphics">SVG</acronym> <acronym title="Document Object Model">DOM</acronym> tree, so although this might help it would only be of real use in reading the state of the view from the source source <acronym title="Document Object Model">DOM</acronym>. This would be easier than writing <acronym title="Document Object Model">DOM</acronym> javascript to do it, but not as easy as <acronym title="ECMAscript for XML">E4X</acronym>.</p>
<p>Reconfiguring the <acronym title="Document Object Model">DOM</acronym> was mainly rewriting and adding  elements to link to symbols defined within the <acronym title="Scalable Vector Graphics">SVG</acronym> file. No <acronym title="Scalable Vector Graphics">SVG</acronym> paths were constructed in the Javascript, only a few elements.</p>
<p>I've got relatively far but the thing that has halted my progress is the problem of perspective on the viewport. I could make the view isometric, but I could have done that with a collection of absolutely-positioned transparent <acronym title="Portable Network Graphics">PNGs</acronym>.</p>
<p>I could encode some 3D information in <acronym title="eXtensible Markup Language">XML</acronym> and use that to lay out the artwork in the tiles with perspective correction, but that is a <em>lot</em> of work for what is basically an experiment.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/09/18/svg-cities-with-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVG Kubrick Source</title>
		<link>http://blog.mauveweb.co.uk/2006/09/18/svg-kubrick-source/</link>
		<comments>http://blog.mauveweb.co.uk/2006/09/18/svg-kubrick-source/#comments</comments>
		<pubDate>Mon, 18 Sep 2006 18:01:43 +0000</pubDate>
		<dc:creator>mauve</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Open-source]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.mauveweb.co.uk/?p=8</guid>
		<description><![CDATA[One of the first things I wanted to do with Oli's blog was start making minor alterations to the default Kubrick theme (which I really like, incidentally) in my favourite vector graphics editor, Inkscape. However, after searching the web for the source, I eventually found that the original source was a Photoshop file &#8211; one [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first things I wanted to do with <a href="http://worldtour.echit.co.uk/">Oli's blog</a> was start making minor alterations to the default Kubrick theme (which I really like, incidentally) in my favourite vector graphics editor, <a href="http://www.inkscape.org/">Inkscape</a>. However, after searching the web for the source, I eventually found that the original source was a Photoshop file &#8211; one that the GIMP couldn't open.</p>
<p>Frankly, I don't think this is a very good show for an application which purports to be open-source. Anyway, as a result I pulled Wordpress's assets into Inkscape and reconstructed the graphics, as closely as I could, tracing the originals.</p>
<p>The result is <a href="http://www.mauveweb.co.uk/misc/kubrick/">an <acronym title="Scalable Vector Graphics">SVG</acronym> file and a shell script to extract the assets</a>. The assets should all be replaced together because the match isn't quite pixel perfect, but if you do replace them you shouldn't notice the difference.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.mauveweb.co.uk/2006/09/18/svg-kubrick-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

