<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/2.0.4" -->
<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/"
	>

<channel>
	<title>Gtk2Hs</title>
	<link>http://haskell.org/gtk2hs</link>
	<description>A GUI Library for Haskell based on Gtk</description>
	<pubDate>Sat, 28 Jun 2008 03:05:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>SVG Cairo goodness</title>
		<link>http://haskell.org/gtk2hs/archives/2006/01/09/svg-cairo-goodness/</link>
		<comments>http://haskell.org/gtk2hs/archives/2006/01/09/svg-cairo-goodness/#comments</comments>
		<pubDate>Mon, 09 Jan 2006 13:40:16 +0000</pubDate>
		<dc:creator>Duncan</dc:creator>
		
	<category>cairo</category>
	<category>Development</category>
		<guid isPermaLink="false">http://haskell.org/gtk2hs/?p=59</guid>
		<description><![CDATA[I&#8217;ve been hacking on binding the libsvg-cairo library as an add-on to the existing cairo bindings. It&#8217;s actually quite a nice small API.

Gtk2Hs can already load SVG files, but only as fixed size bitmaps. With this API we get a proper vector method. Since the drawing is done via cairo in the Render monad we [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hacking on binding the libsvg-cairo library as an add-on to the existing cairo bindings. It&#8217;s actually quite a nice small API.</p>
<p><a href="http://haskell.org/gtk2hs/gallery/SVG/svgviewer1" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/SVG/svgviewer1.thumb.png" class="gallery_image"  alt="[img]"  /></a></p>
<p>Gtk2Hs can already load SVG files, but only as fixed size bitmaps. With this API we get a proper vector method. Since the drawing is done via cairo in the Render monad we can apply any 2D transformation. These screenshots are of a simple svg viewer. It&#8217;s only 30 lines of code overall. The following snippet is what does the actual drawing.</p>
<blockquote><p><code>win &lt;- drawingAreaGetDrawWindow canvas<br />
let (width, height) = sizeSVG svg<br />
(width', height') &lt;- drawingAreaGetSize canvas<br />
renderWithDrawable win $ do<br />
&nbsp;&nbsp;scale (realToFrac width' / realToFrac width)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(realToFrac height' / realToFrac height)<br />
&nbsp;&nbsp;renderSVG svg<br />
</code></p></blockquote>
<p>You can see that we setup the scaling transformation before rendering the svg picture. We scale the image so that it fits the size of the canvas. So as we resize the window the image scales nicely.</p>
<p><a href="http://haskell.org/gtk2hs/gallery/SVG/svgviewer2" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/SVG/svgviewer2.thumb.png" class="gallery_image"  alt="[img]"  /></a>
</p>
]]></content:encoded>
			<wfw:commentRSS>http://haskell.org/gtk2hs/archives/2006/01/09/svg-cairo-goodness/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Getting started with Cairo</title>
		<link>http://haskell.org/gtk2hs/archives/2005/11/10/getting-started-with-cairo/</link>
		<comments>http://haskell.org/gtk2hs/archives/2005/11/10/getting-started-with-cairo/#comments</comments>
		<pubDate>Thu, 10 Nov 2005 14:37:17 +0000</pubDate>
		<dc:creator>Axel</dc:creator>
		
	<category>Announcements</category>
	<category>cairo</category>
		<guid isPermaLink="false">http://haskell.org/gtk2hs/?p=57</guid>
		<description><![CDATA[Using ghci is a great way of experimenting with Cairo. You might experience problems due to the way ghci and Gtk2Hs both require to be run concurrently. I&#8217;ve created a little code snippet that opens a dialog box, displays the given Cairo action and waits for you to click the Close button.
The run function will [...]]]></description>
			<content:encoded><![CDATA[<p>Using <code>ghci</code> is a great way of experimenting with Cairo. You might experience problems due to the way <code>ghci</code> and Gtk2Hs both require to be run concurrently. I&#8217;ve created a little <a href="http://darcs.haskell.org/gtk2hs/demo/cairo/CairoGhci.hs">code snippet</a> that opens a dialog box, displays the given Cairo action and waits for you to click the Close button.</p>
<p>The <code>run</code> function will execute the given Cairo statements and will then continue to run the Gtk main loop until the dialog is actually removed from screen. This function can conveniently be used to test various Cairo commands. For example, try:<br />
<code><br />
run (moveTo 200 200 >> lineTo 0 0 >> stroke)<br />
</code></p>
<p>If straight lines are too boring, you can do this:<br />
<code><br />
run (moveTo 200 200 >> setLineWidth 20 >> curveTo 200 0 100 200 0 0 >> stroke)<br />
</code></p>
<p>To render text, you need to create a layout first:<br />
<code><br />
run (moveTo 20 20 >> rotate (pi/4) >> createLayout "Haskell and Cairo is cool." >>= showLayout)<br />
</code></p>
<p>Note that the return value of <code>createLayout</code> is passed to <code>showLayout</code>.</p>
]]></content:encoded>
			<wfw:commentRSS>http://haskell.org/gtk2hs/archives/2005/11/10/getting-started-with-cairo/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Koch rules</title>
		<link>http://haskell.org/gtk2hs/archives/2005/09/02/koch-rules/</link>
		<comments>http://haskell.org/gtk2hs/archives/2005/09/02/koch-rules/#comments</comments>
		<pubDate>Fri, 02 Sep 2005 19:59:42 +0000</pubDate>
		<dc:creator>Paolo Martini</dc:creator>
		
	<category>cairo</category>
		<guid isPermaLink="false">http://haskell.org/gtk2hs/?p=51</guid>
		<description><![CDATA[Some people complained about the images on the previous post being a little similar, or mirrored to each other.  So I picked up the book boegel suggested (a wonderful reading so far, in some sense it reminds me of the GEB), and I tried writing a more complex L-System - these are the nice [...]]]></description>
			<content:encoded><![CDATA[<p>Some people complained about the images on the previous <a href="http://haskell.org/gtk2hs/archives/2005/09/01/random-is-sexy/">post</a> being a little <em>similar</em>, or <em>mirrored</em> to each other.  So I picked up the <a href="http://algorithmicbotany.org/papers/abop/abop.pdf">book</a> <a href="http://www.haskell.org/hawiki/KennethHoste">boegel</a> <a href="http://haskell.org/gtk2hs/archives/2005/08/31/the-potential-of-pratical-haskell-2nd-edition/#comments">suggested</a> (a wonderful reading so far, in some sense it reminds me of the <a href="http://en.wikipedia.org/wiki/G%C3%B6del,_Escher,_Bach">GEB</a>), and I tried writing a more complex <a href="http://en.wikipedia.org/wiki/L-system">L-System</a> - these are the nice results <strong>using the exactly same grammar every time</strong> (yes I know, it still grows <em>downwards</em>&#8230;):</p>
<p><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_13" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_13.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_14" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_14.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_15" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_15.thumb.png" class="gallery_image"  alt="[img]"  /></a><br />
<a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_16" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_16.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_17" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_17.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_18" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_18.thumb.png" class="gallery_image"  alt="[img]"  /></a></p>
<p>I also managed to draw Koch&#8217;s LSystems, (thanks <a href="http://haskell.org/hawiki/BastiaanZapf">basti</a>!) here&#8217;s the <a href="http://www.google.com/search?q=kock%20curve">Koch&#8217;s Curve:</a></p>
<p><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Koch" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Koch.thumb.png" class="gallery_image"  alt="[img]"  /></a></p>
<p>&#8230;and the <a href="http://www.google.com/search?q=kock%20snowflake">Koch&#8217;s Snowflake</a>:</p>
<p><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Koch2" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Koch2.thumb.png" class="gallery_image"  alt="[img]"  /></a></p>
<p>Next on the todo list: add weights to rules to &#8220;manipulate&#8221; randomness! <img src='http://haskell.org/gtk2hs/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRSS>http://haskell.org/gtk2hs/archives/2005/09/02/koch-rules/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Random is sexy</title>
		<link>http://haskell.org/gtk2hs/archives/2005/09/01/random-is-sexy/</link>
		<comments>http://haskell.org/gtk2hs/archives/2005/09/01/random-is-sexy/#comments</comments>
		<pubDate>Thu, 01 Sep 2005 23:36:47 +0000</pubDate>
		<dc:creator>Paolo Martini</dc:creator>
		
	<category>cairo</category>
		<guid isPermaLink="false">http://haskell.org/gtk2hs/?p=50</guid>
		<description><![CDATA[Hiya, this was a fun night, I can&#8217;t stop playing with cairo code, yay!  I hacked non-determinism inside the LSystem module - now the same grammar, if contains multiple rules for the same variable, will produce different images in every render!
Another step towards making a cool, and complete, Haskell version of  Chris Coyne&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Hiya, this was a fun night, I can&#8217;t stop playing with cairo code, yay!  I hacked <em>non-determinism</em> inside the LSystem module - now the same grammar, if contains multiple rules for the same variable, will produce different images in every render!</p>
<p>Another step towards making a cool, and complete, Haskell version of  Chris Coyne&#8217;s <a href="http://www.ozonehouse.com/ContextFree/">Context-Free</a>  Now, some new porn (notice that I&#8217;m using the same grammar every time)</p>
<p><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_7" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_7.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_8" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_8.thumb.png" class="gallery_image"  alt="[img]"  /></a><br />
<a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_9" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_9.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_10" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_10.thumb.png" class="gallery_image"  alt="[img]"  /></a><br />
<a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_11" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_11.thumb.png" class="gallery_image"  alt="[img]"  /></a><a href="http://haskell.org/gtk2hs/gallery/Cairo-demo/Cairo_demo_12" class="gallery_href" ><img src="http://haskell.org/gtk2hs/albums/Cairo-demo/Cairo_demo_12.thumb.png" class="gallery_image"  alt="[img]"  /></a></p>
<p>I&#8217;m dedicating this images to <a href="http://www.advogato.org/person/seb128/">Sebastien Bacher</a>, who&#8217;s packaging GNOME for Ubuntu&#8230; alone!  And <em>&#8220;due to peer pressure&#8221;</em> <b>*cough*</b> he packaged cairo 1.0.0 like 10 mins after its release, thank you, seb! <img src='http://haskell.org/gtk2hs/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRSS>http://haskell.org/gtk2hs/archives/2005/09/01/random-is-sexy/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
