<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/sketches/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    
    <link href="http://www.janthor.com/sketches/index.php?/feeds/atom10.xml" rel="self" title="Sketches" type="application/atom+xml" />
    <link href="http://www.janthor.com/sketches/"                        rel="alternate"    title="Sketches" type="text/html" />
    <link href="http://www.janthor.com/sketches/rss.php?version=2.0"     rel="alternate"    title="Sketches" type="application/rss+xml" />
    <title type="html">Sketches</title>
    <subtitle type="html"></subtitle>
    <icon>img/halfishtar.png</icon>
    <id>http://www.janthor.com/sketches/</id>
    <updated>2013-03-03T10:48:18Z</updated>
    <generator uri="http://www.s9y.org/" version="1.5.5">Serendipity 1.5.5 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/19-How-to-change-the-font-of-the-Windows-console-with-Python.html" rel="alternate" title="How to change the font of the Windows console with Python" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2012-12-18T19:52:04Z</published>
        <updated>2013-03-03T10:48:18Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=19</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=19</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/19-guid.html</id>
        <title type="html">How to change the font of the Windows console with Python</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">The de­fault font for the con­sole on Win­dows is some basic raster font with­out much sup­port for more ex­ot­ic Uni­code code points. Which kind of sucks for com­mand line pro­grams, if they are deal­ing with Uni­code data and for­eign lan­guages. It is pos­si­ble to change the con­sole font to “Lu­ci­da Con­sole”, which sup­ports a lot more code points, or, if it is in­stalled, to “Con­so­las”, which sup­ports even more code points, by click­ing on the icon in the upper left cor­ner of the con­sole and choos­ing to change the prop­er­ties. But we can’t se­ri­ous­ly ex­pect the user of a script to go through the trou­ble of chang­ing the font of the con­sole man­u­al­ly.</p>
<p class="follow">Is it pos­si­ble to change the font of the con­sole in­side a Python script run­ning on said con­sole? Usu­al­ly, the most nat­u­ral thing to do would be to look at the mod­ule <tt>win32console</tt>, but un­for­tu­nate­ly, it doesn’t im­ple­ment the need­ed call to <tt>SetCurrentConsoleFontEx</tt>. Too bad, but ba­si­cal­ly just a mere in­con­ve­nience, since we can al­ways do stuff like this using the <tt>ctypes</tt> mod­ule (with the ad­di­tion­al bonus that since Python 2.5, <tt>ctypes</tt> is part of the Stan­dard Li­brary, so we don’t have to rely on the avail­abil­i­ty of an ex­ter­nal li­brary). The fol­low­ing code shows how it is done:</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/19-How-to-change-the-font-of-the-Windows-console-with-Python.html#extended">Continue reading "How to change the font of the Windows console with Python"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/18-Using-Adobe-Open-Type-Fonts-Ornaments-In-XeTeX.html" rel="alternate" title="Using Adobe Open Type Fonts Ornaments In XeTeX" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2012-08-12T13:01:47Z</published>
        <updated>2013-03-03T10:49:16Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=18</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=18</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/18-guid.html</id>
        <title type="html">Using Adobe Open Type Fonts Ornaments In XeTeX</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">Once upon a time, or­na­ments, ding­bats, flour­ish­es, sym­bols and other em­bel­lish­ments were put in spe­cial pi fonts, with the sym­bols mapped to or­di­nary let­ters. For ex­am­ple, in Zapfi­no Extra Or­na­ments, you could type a cap­i­tal let­ter X and get a nice flour­ish, which had noth­ing at all to do with the let­ter X.</p>
<p class="follow">With the ad­vent of Open Type and Uni­code, some sym­bols where put in the Pri­vate Use Area of Uni­code. For ex­am­ple, Adobe Gara­mond Pro has three flour­ish­es at the code points <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+E09D</span>, <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+E09E</span> and <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+E09F</span>. That’s a lot bet­ters, since it avoids se­man­tic clash­es (don’t con­fuse search en­gines and other bots by typ­ing an “X” if you don’t mean “X”), and it also de­grades more grace­ful­ly if the in­tend­ed font isn’t avail­able (in which a “can’t print this” sym­bol is a bet­ter choice than the rather mis­lead­ing let­ter “X”).</p>
<p class="follow">Still, it is far from per­fect, since it turns the Pri­vate Use Area into some kind of font-ven­dor-spe­cif­ic swamp de­void of any in­ter­op­er­abil­i­ty and mean­ing. After all, any in­for­ma­tion about what <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+E09D</span> <i>means</i> is lost, since it could be an or­na­ment, a sym­bol (with a rather spe­cif­ic mean­ing), some rare lig­a­ture or some other ty­po­graph­i­cal fea­ture like a sub­script or a small cap­i­tal. So an even bet­ter ap­proach would be to in­ter­pret or­na­ments as some kind of <i>stylis­tic</i> vari­a­tion of a de­fault or­na­ment, like the bul­let point <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+2022</span>. A search en­gine or any other kind of bot would see the let­ter <span style="font-family:'Courier New';font-size: 83%; background-color:#eef;">U+2022</span> and would know (more or less) what it is sup­posed to mean, and the dif­fer­ent or­na­ments could be ac­cessed as an Open Type fea­ture.</p>
 <br /><a href="http://www.janthor.com/sketches/index.php?/archives/18-Using-Adobe-Open-Type-Fonts-Ornaments-In-XeTeX.html#extended">Continue reading "Using Adobe Open Type Fonts Ornaments In XeTeX"</a>
            </div>
        </content>
        <dc:subject>TeX</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/17-Three.js-and-Stella-like-polyhedrons.html" rel="alternate" title="Three.js and Stella-like polyhedrons" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2012-05-15T19:15:45Z</published>
        <updated>2013-03-03T10:50:09Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=17</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=17</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/17-guid.html</id>
        <title type="html">Three.js and Stella-like polyhedrons</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">With a frame­work like Three.js, it is pret­ty easy to dis­play the faces of sim­ple poly­he­drons using WebGL. But a poly­he­dron, con­sid­ered less as a phys­i­cal and more as a topo­log­i­cal ob­ject, con­sists not only of its faces. In­stead often its ver­tices and edges are equaly in­ter­est­ing, and it would be nice to have an easy way to dis­play them, per­haps as­sign­ing them dif­fer­ent col­ors, to dis­tin­guish dif­fer­ent kinds of ver­tices or dif­fer­ent kinds of edges. With­in the pro­gram Stel­la, ver­tices can be dis­played as small balls and edges as thin tubes, and I wrote a func­tion to be used in con­junc­tion with Three.js which makes it a bit eas­i­er to con­struct sim­i­lar graph­i­cal ob­jects, fol­low­ing a sim­i­lar vi­su­al style, with­in WebGL.</p>
<p class="follow">In the fol­low­ing ex­am­ples, I’ll as­sume that we have set up all the usual Three.js stuff with ren­der­ers and vir­tu­al cam­eras and mouse con­trols and lights and that we have de­fined a <span class="ijs">Scene</span>-ob­ject. Fur­ther­more, I’ll as­sume that we im­port­ed my helper file <a href="http://www.janthor.com/lib/JAN3D.js">JAN3D.js</a> which con­tains the func­tion <span class="ijs">JAN3D.stel­la()</span> (among other stuff; I also in­clud­ed <span class="ijs">JAN3D.Tiny­Track­ball­Con­trols</span>). I’ll show, using four ex­am­ples, how to use this func­tion.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/17-Three.js-and-Stella-like-polyhedrons.html#extended">Continue reading "Three.js and Stella-like polyhedrons"</a>
            </div>
        </content>
        <dc:subject>Javascript</dc:subject>
<dc:subject>WebGL</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/16-Making-the-AnaglyphWebGLRenderer-a-bit-more-protruding.html" rel="alternate" title="Making the AnaglyphWebGLRenderer a bit more protruding" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2012-04-15T21:57:22Z</published>
        <updated>2013-03-03T10:51:39Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=16</wfw:comment>
    
        <slash:comments>4</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=16</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/16-guid.html</id>
        <title type="html">Making the AnaglyphWebGLRenderer a bit more protruding</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">The WebGL-frame­work Three.js I men­tioned in the pre­vi­ous entry has a nice vari­a­tion of its ren­der­er which ren­ders scenes as red-cyan anaglyphs. So using Three.js, you ba­si­cal­ly get anaglyphs for free with­out any ad­di­tion­al work on your part (an anaglyph is an image where you need glass­es with red and cyan glass­es to get a stereo­scop­ic, three-di­men­sion­al view).</p>
<p class="follow">I tried to con­struct a lit­tle scene using this abil­i­ty, but what I dis­liked was that the scene, as an anaglyph, was too dis­tant and ap­peared to be po­si­tioned be­hind the screen. I had a scene with sev­er­al con­cen­tric cir­cles of spheres, and I want­ed them to ap­pear to in­ter­sect the plane of the screen, with the cen­ter of the cir­cles co­in­cid­ing with the screen. And since I found no way of doing it, I plugged two new pa­ram­e­ters into Anaglyph­We­bGLRen­der­er, called the new ver­sion Pro­truding­Anaglyph­Web­GLRen­der­er and put it in a file <a href="http://www.janthor.com/lib/ProtrudingAnaglyphWebGLRenderer.js">Pro­truding­Anaglyph­Web­GLRen­der­er.js</a>.</p>
 <br /><a href="http://www.janthor.com/sketches/index.php?/archives/16-Making-the-AnaglyphWebGLRenderer-a-bit-more-protruding.html#extended">Continue reading "Making the AnaglyphWebGLRenderer a bit more protruding"</a>
            </div>
        </content>
        <dc:subject>Javascript</dc:subject>
<dc:subject>WebGL</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/15-Modified-TrackballControls-for-Three.js.html" rel="alternate" title="Modified TrackballControls for Three.js" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2012-04-14T22:30:05Z</published>
        <updated>2013-03-03T11:01:39Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=15</wfw:comment>
    
        <slash:comments>8</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=15</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/15-guid.html</id>
        <title type="html">Modified TrackballControls for Three.js</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">WebGL is a tech­nol­o­gy that al­lows web browsers to dis­play graph­ics using the fast rou­tines of the graph­ics card, and Three.js is a frame­work which makes work­ing with WebGL a lot eas­i­er. Among many other things, Three.js pro­vides “con­trols”, Javascript ob­jects which han­dle the in­ter­ac­tion be­tween mouse events and the WebGL can­vas. One such con­trol is Track­ball­Con­trols. It maps mouse drag­ging ges­tures on an imag­i­nary track­ball and ro­tates the scene ac­cord­ing­ly. I have used it to make mod­els of poly­he­dra ro­tat­able for my view­ers: <a href="http://www.janthor.com/skizzen/index.php?/archives/268-Stubsmuetter-und-Tribonacci.html">Stub­smüt­ter und Trib­anoc­ci</a> (a link to the Ger­man sec­tion of this blog).</p>
<p class="follow">Per de­fault, the imag­i­nary Track­ball fills the en­tire avail­able brows­er win­dow. This is less than ideal if the ac­tu­al WebGL can­vas is just a tiny il­lus­tra­tion with­in a larg­er text:</p>
 <br /><a href="http://www.janthor.com/sketches/index.php?/archives/15-Modified-TrackballControls-for-Three.js.html#extended">Continue reading "Modified TrackballControls for Three.js"</a>
            </div>
        </content>
        <dc:subject>Javascript</dc:subject>
<dc:subject>WebGL</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/14-Mixing-HTML-and-TeX-in-a-StyledTextCtrl-in-wxPython.html" rel="alternate" title="Mixing HTML and TeX in a StyledTextCtrl in wxPython" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-11-03T18:13:19Z</published>
        <updated>2013-03-03T10:53:45Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=14</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=14</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/14-guid.html</id>
        <title type="html">Mixing HTML and TeX in a StyledTextCtrl in wxPython</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">I have writ­ten my very own ed­i­tor with syn­tax high­light­ing to write these sketch­es. This is far less im­pres­sive than it might ap­pear on a first glance: wxWid­gets, and there­fore also wx­Python, pro­vide ac­cess to the Scin­til­la li­brary via the Styled­TextC­trl el­e­ment, and this el­e­ment can dis­play HTML source code and style the dif­fer­ent el­e­ments in dif­fer­ent col­ors. Scin­til­la pro­vides “lex­ers” for dif­fer­ent lan­guages, parsers which are able to de­ter­mine which frag­ments of a doc­u­ment are key­words, iden­ti­fiers, string lit­er­als, nu­mer­i­cal lit­er­als, op­er­a­tors, com­ments and so on, and to­kens from dif­fer­ent cat­e­gories can be styled dif­fer­ent­ly. So “writ­ing my own ed­i­tor” in fact just means “glu­ing to­geth­er some stan­dard pieces”. It looks like this:</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/14-Mixing-HTML-and-TeX-in-a-StyledTextCtrl-in-wxPython.html#extended">Continue reading "Mixing HTML and TeX in a StyledTextCtrl in wxPython"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>TeX</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/13-The-girl-version-of-the-On-the-population-dynamics-of-Puella-Magi-Madoka-Magica-essay.html" rel="alternate" title="The girl version of the “On the population dynamics of “Puella Magi Madoka Magica”” essay" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-10-23T21:32:30Z</published>
        <updated>2013-03-03T10:54:44Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=13</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/13-guid.html</id>
        <title type="html">The girl version of the “On the population dynamics of “Puella Magi Madoka Magica”” essay</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">I’m not com­ple­tely con­tent with the ap­pearan­ce of the pre­ce­ding sketch, and so I de­ci­ded to try to pret­ti­fy it a bit. I re­pla­ced all the equa­ti­ons ge­ne­ra­ted by <a href="http://www.forkosh.com/mimetexmanual.html">mi­me­tex</a> as GIF images with texts I pipe through <a href="http://www.mathjax.org/">Ma­th­Jax</a>, so if you have Ja­va­script disa­bled, you’ll see all equa­ti­ons as \(\LaTeX\) plain­text. Fur­ther­mo­re, I re­pla­ced all the screen­caps I took from Open­Of­fice or Excel and re­pla­ced them with with pret­ty <a href="http://matplotlib.sourceforge.net/">mat­plot­lib</a> plots; and I also re-did all the pre­vious mat­plot­lib plots. And I tried to en­han­ce the lay­out of the page a bit, and added more stills from the se­ries. So this is my se­cond take, the con­tent re­mains un­ch­an­ged, but I at­temp­ted to make the ap­pearan­ce more fit­ting for a se­ries about cute girls.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/13-The-girl-version-of-the-On-the-population-dynamics-of-Puella-Magi-Madoka-Magica-essay.html#extended">Continue reading "The girl version of the “On the population dynamics of “Puella Magi Madoka Magica”” essay"</a>
            </div>
        </content>
        <dc:subject>Anime</dc:subject>
<dc:subject>Math</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/12-On-the-population-dynamics-of-Puella-Magi-Madoka-Magica.html" rel="alternate" title="On the population dynamics of “Puella Magi Madoka Magica”" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-10-16T18:32:41Z</published>
        <updated>2013-03-03T10:55:05Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=12</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/12-guid.html</id>
        <title type="html">On the population dynamics of “Puella Magi Madoka Magica”</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">This sketch is de­vot­ed to the pop­u­la­tion dy­nam­ics of the fic­tion­al world de­pict­ed by the Japanese an­i­mat­ed TV se­ries “Puel­la Magi Mado­ka Mag­i­ca”. As such, it is in­evitable going to re­veal at least one major plot point. So if you are plan­ning to watch this show, I sug­gest that you post­pone read­ing this sketch until you are done watch­ing it. You have been warned: there will be spoil­ers.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/12-On-the-population-dynamics-of-Puella-Magi-Madoka-Magica.html#extended">Continue reading "On the population dynamics of “Puella Magi Madoka Magica”"</a>
            </div>
        </content>
        <dc:subject>Anime</dc:subject>
<dc:subject>Math</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/11-Why-I-wont-update-Orbit-Classic-for-Firefox-4.html" rel="alternate" title="Why I won’t update Orbit Classic for Firefox 4" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-05-10T20:32:43Z</published>
        <updated>2013-03-03T10:59:52Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=11</wfw:comment>
    
        <slash:comments>7</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/11-guid.html</id>
        <title type="html">Why I won’t update Orbit Classic for Firefox 4</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">I hes­i­tat­ed up­dat­ing Fire­fox to ver­sion 4.0, since I feared it might break a lot of ex­ten­sions I use. Well, it cer­tain­ly broke my theme Orbit Clas­sic. But now that I made the tran­si­tion, I de­cid­ed that I won’t main­tain Orbit Clas­sic any longer. With Fire­fox&#160;4.0, I’m happy with the de­fault theme – all the more since it’s pos­si­ble to cram all the chrome tight­ly to­geth­er, so there isn’t much left to style any­way. It’s the com­pact­ness of Google Chrome com­bined with the awe­some ex­ten­si­bil­i­ty and flex­i­bil­i­ty of Fire­fox.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/11-Why-I-wont-update-Orbit-Classic-for-Firefox-4.html#extended">Continue reading "Why I won’t update Orbit Classic for Firefox 4"</a>
            </div>
        </content>
        <dc:subject>Deprecation Warning</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/8-Cascading-Drop-Shadows.html" rel="alternate" title="Cascading Drop-Shadows" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-05-04T20:36:00Z</published>
        <updated>2013-03-03T10:56:47Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=8</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=8</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/8-guid.html</id>
        <title type="html">Cascading Drop-Shadows</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">In <a href="http://www.janthor.com/interferences/index.php?p=68">chap­ter 4</a> of “In­ter­fer­ences”, I’m using sev­er­al lay­ers stacked on top of each other with cu­mu­la­tive drop shad­ows. Of course I have writ­ten a Python ex­ten­sion for Inkscape to gen­er­ate such cas­cad­ing shad­ows au­to­mat­i­cal­ly.</p>
<p class="follow">Let’s start with a sim­ple ex­am­ple: five round­ed rect­an­gles stacked upon each other.</p>
 <br /><a href="http://www.janthor.com/sketches/index.php?/archives/8-Cascading-Drop-Shadows.html#extended">Continue reading "Cascading Drop-Shadows"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>SVG</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/7-Two-step-text-to-path-transformation.html" rel="alternate" title="Two-step text to path transformation" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-04-22T19:10:00Z</published>
        <updated>2013-03-03T10:57:01Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=7</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=7</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/7-guid.html</id>
        <title type="html">Two-step text to path transformation</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">In the pre­vi­ous sketch, I pre­sent­ed an Inkscape ex­ten­sion which con­vert­ed texts to paths, re­plac­ing du­pli­cate paths with use el­e­ments. This ex­ten­sion did call Inkscape it­self, re­quir­ing a some­what du­bi­ous hack.</p>
<p class="follow">It is pos­si­ble to avoid this hack, al­though the al­ter­na­tive ver­sion (which I am going to present in this sketch) is slight­ly more round­about: the al­t­ner­na­tive ex­ten­sion needs to be called two times.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/7-Two-step-text-to-path-transformation.html#extended">Continue reading "Two-step text to path transformation"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>SVG</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/6-Fonts,-Texts,-Paths-and-Uses.html" rel="alternate" title="Fonts, Texts, Paths and Uses" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-04-21T19:09:00Z</published>
        <updated>2013-03-03T10:57:22Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=6</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=6</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/6-guid.html</id>
        <title type="html">Fonts, Texts, Paths and Uses</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">Using fancy fonts with SVG faces some pit­falls. One prob­lem is that font foundries are not fond of see­ing their font data ex­posed for ev­ery­one to fetch across the pond. Until re­cent­ly, using com­mer­cial fonts on the web was next to im­pos­si­ble, and the sup­port for fonts is still in its in­fan­cy, and usu­al­ly re­quires some model where fonts are pro­vid­ed in a heav­i­ly en­crypt­ed and pro­tect­ed way, in­com­pat­i­ble with SVG. It is hard to imag­ine any font foundry would allow their valu­able fonts to be pub­lished as font for­mats com­pat­i­ble with SVG.</p>
<p class="follow">It’s pos­si­ble to cir­cum­vent this prob­lem by stick­ing to free fonts. But we im­me­di­ate­ly run into the next prob­lem: lack­ing SVG font sup­port in many browsers.</p>
<p class="follow">An ob­vi­ous so­lu­tion is to re­place all tex­tu­al data with­in a SVG file with paths. If a user agent can dis­play SVG at all, it will be able to dis­play path data, so that’s a fall­back that will al­ways work (if SVG works at all).</p>
<p class="follow">Un­for­tu­nate­ly, we loose the tex­tu­al in­for­ma­tion. That’s bad for search­ing, it’s bad for in­dex­ing, it’s un­friend­ly to­wards dis­abled users, and it might cause prob­lems down the road if we want to mod­i­fy files later on. It’s there­fore ad­vis­able to du­pli­cate text el­e­ments and to put one copy into a hid­den layer, while the other copy is trans­formed into path data.</p>
<p class="follow">But there is an­oth­er draw­back: re­plac­ing text with paths in­creas­es the file size con­sid­er­ably. Part of this in­crease in size in un­avoid­able: after all, we are stor­ing glyphs as paths, and this glyph data in­evitably some­how must be trans­port­ed to the user, whether it is in the form of an aux­il­iary OTF file or some ad­di­tion­al paths in­creas­ing the size of the main SVG file.</p>
<p class="follow">But an­oth­er part of this in­crease in file size <i>is</i> per­fect­ly avoid­able. A font file con­tains the glyph def­i­ni­tion for the let­ter, say, <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">LATIN SMALL LETTER E</span>, just once. A text con­vert­ed to a group of paths may con­tain the cor­re­spond­ing data sev­er­al times, one copy for each oc­cur­rence of the let­ter “e”. Even if we ac­cept the ne­ces­si­ty of the first oc­cur­rence of this data, all sub­se­quent oc­cur­rences are su­per­flu­ous. We can sub­stan­tial­ly com­press our file if we re­place all later oc­cur­rences of this let­ter with ref­er­ences to the path def­i­ni­tion of the first oc­cur­rence, by re­plac­ing the sub­se­quent <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">path</span> el­e­ments with <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">use</span> el­e­ments; or, using the ter­mi­nol­o­gy of Inkscape: by re­plac­ing them with linked clones. I have writ­ten an Inkscape ex­ten­sions which does ex­act­ly this.</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/6-Fonts,-Texts,-Paths-and-Uses.html#extended">Continue reading "Fonts, Texts, Paths and Uses"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>SVG</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/5-Inkscape-calling-Inkscape.html" rel="alternate" title="Inkscape calling Inkscape" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-04-20T19:08:00Z</published>
        <updated>2013-03-03T10:57:39Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=5</wfw:comment>
    
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=5</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/5-guid.html</id>
        <title type="html">Inkscape calling Inkscape</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">The ca­pa­bil­i­ties of Inkscape can be ex­tend­ed with user scripts, but in a rather pe­cu­liar way: un­like other pro­grams which allow user scripts, Inkscape doesn’t ex­pose an API to a script en­vi­ron­ment. In­stead, it pipes the con­tent of the cur­rent SVG file to any ar­bi­trary user pro­gram reg­is­tered with an INX file, and this pro­gram is free to do with said file what­ev­er it wants, after which it should spew the file back via std­out to Inkscape.</p>
<p class="follow">This means that an Inkscape ex­ten­sion has the most amount of free­dom imag­in­able in what it can do to the SVG file in ques­tion: it can do what­ev­er a Tur­ing ma­chine can do, and trans­form the input in ar­bi­trary and com­plete­ly out­landish ways. On the other hand, the ex­ten­sion can’t ac­cess any of the in­ter­nals of Inkscape and is com­plete­ly on its own.</p>
<p class="follow">Well, al­most. Inkscape at least pro­vides the <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">id</span>s of the cur­rent­ly se­lect­ed ob­jects as ad­di­tion­al input op­tions, and the file it­self con­tains some hints about the cur­rent state of Inkscape (for ex­am­ple, which layer is cur­rent­ly ac­tive). But an ex­ten­sion can’t use some of Inkscape’s ef­fects. An ex­ten­sion might call other ex­ten­sions, but oth­er­wise, all ef­fects and meth­ods and tricks and pro­ce­dures it wants to use, it has to pro­vide it­self.</p>
<p class="follow">Which is some­times kind of an­noy­ing, since Inkscape ships with a lot of use­ful tools an ex­ten­sion might want to uti­lize. For ex­am­ple, an ex­ten­sion might want to split a path into its com­po­nents as one step with­in a larg­er pro­ce­dure. Such a split­ting of a path into com­po­nents isn’t too com­pli­cat­ed: take the path data, scan for oc­cur­rences of <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">&quot;M&quot;</span> or <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">&quot;m&quot;</span>, and split along them. But you also have to take into con­sid­er­a­tion that in the case of a lower case <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">&quot;m&quot;</span>, the rel­a­tive co­or­di­nates of the first ver­tex must be re­placed with ab­so­lute co­or­di­nates, which means you have to scan the path data back­wards until you reach an ab­so­lute co­or­di­nate, and com­pute your cur­rent po­si­tion for­ward from there. Not ter­ri­bly hard to do, but an­noy­ing enough if you know that some­body else al­ready did it be­fore.</p>
<p class="follow">Or per­haps you want to trans­form a text into a path, as the ex­ten­sion does we’ll dis­cuss in the fol­low­ing entry. That re­quires read­ing the ap­pro­pri­ate font, trans­form­ing glyphs to paths, deal­ing with kern­ing and a lot of com­pli­cat­ed and ad­vanced stuff, and stuff some­body al­ready solved in a com­plete­ly sat­is­fac­to­ry man­ner, since Inkscape it­self al­ready has a com­mand to trans­form texts to paths. So it is de­sir­able if we some­how could call Inkscape com­mands from with­in an Inkscape ex­ten­sion.</p>

<p class="first">I wrote a Python mod­ule which ex­tends the <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">Effect</span> class of the stan­dard <span style="font-family: 'Courier New';color: #00007f;font-size:10pt;">inkex</span> mod­ule in such a way that this is, in­deed, pos­si­ble.</p>
 <br /><a href="http://www.janthor.com/sketches/index.php?/archives/5-Inkscape-calling-Inkscape.html#extended">Continue reading "Inkscape calling Inkscape"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>SVG</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/10-A-Python-script-to-convert-ICO-to-CUR-files.html" rel="alternate" title="A Python script to convert ICO to CUR files" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-04-14T20:13:22Z</published>
        <updated>2013-03-03T10:57:55Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=10</wfw:comment>
    
        <slash:comments>14</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=10</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/10-guid.html</id>
        <title type="html">A Python script to convert ICO to CUR files</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">Need­ing a cur­sor as a CUR file (since that’s the only for­mat that works cross brows­er), I opened my cur­sor PNG file in The Gimp and tried to save it with a CUR ex­ten­sion, only for The Gimp to tell me that it doesn’t know that ex­ten­sion – which came as a nasty sur­prise to me, since The Gimp has no prob­lem sav­ing files in the ICO for­mat. As it turns out, Ir­fan­View, while being able to dis­play CUR files, can’t save them ei­ther. And Im­ageMag­ick, while un­der­stand­ing this for­mat, has no op­tion to de­fine a hotspot for the cur­sor (the hotspot is the one pixel with­in the cur­sor that de­fines where, ex­act­ly, you are when point­ing with the cur­sor).</p>
<p class="follow">My next idea was to look on the Wikipedia page for the CUR for­mat to see whether there are some open source (or at least free) ed­i­tors list­ed. And there I stum­bled upon the first good news of my quest: ap­par­ent­ly, the ICO for­mat and the CUR for­mat (at least in their clas­si­cal ver­sions) are ex­treme­ly sim­i­lar. With­in the main head­er of the file, I just have to change a sin­gle Byte to switch for­mats, and with­in an image table, there are two Bytes which ei­ther store some ICO-rel­e­vant in­for­ma­tion or the lo­ca­tion of the hotspot. And that’s it: if the ICO file con­tains just a sin­gle image, there are but three Bytes at fixed lo­ca­tions I have to change.</p>
<p class="follow">So I saved my PNG as an ICO with The Gimp and wrote a lit­tle Python script to con­vert this file to a CUR file. My ini­tial script was only three lines long (read the bytes into mem­o­ry, change three of them, write them back to disk), but I added a bit of the usual com­mand line op­tions boil­er­plate plus error han­dling, and the re­sult is the fol­low­ing:</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/10-A-Python-script-to-convert-ICO-to-CUR-files.html#extended">Continue reading "A Python script to convert ICO to CUR files"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>

    </entry>
    <entry>
        <link href="http://www.janthor.com/sketches/index.php?/archives/3-P3-Penrose-Tilings.html" rel="alternate" title="P3 Penrose Tilings" />
        <author>
            <name>Jan Thor</name>
                    </author>
    
        <published>2011-04-13T16:55:00Z</published>
        <updated>2013-03-03T10:58:03Z</updated>
        <wfw:comment>http://www.janthor.com/sketches/wfwcomment.php?cid=3</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.janthor.com/sketches/rss.php?version=atom1.0&amp;type=comments&amp;cid=3</wfw:commentRss>
    
    
        <id>http://www.janthor.com/sketches/index.php?/archives/3-guid.html</id>
        <title type="html">P3 Penrose Tilings</title>
        <content type="xhtml" xml:base="http://www.janthor.com/sketches/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p class="first">For <a href="http://www.janthor.com/interferences/index.php?p=52">page 52</a> of my <a href="http://www.janthor.com/interferences">In­ter­fer­ences Comic</a>, I want­ed to use a Pen­rose tiling, name­ly, the P3 ver­sion of the Pen­rose tiling. A quick search on the web for Pen­rose tilings as SVG files un­earthed a file that used an L-sys­tem to draw a P3 Pen­rose tiling, but that was not what I want­ed: not only did I want a fin­ished tiling, I also want­ed the tiles to have two col­ors: one color for the “fat” rhombs and one color for the “thin” rhombs. So I wrote my own code in Python. Here is what the re­sult looks like:</p> <br /><a href="http://www.janthor.com/sketches/index.php?/archives/3-P3-Penrose-Tilings.html#extended">Continue reading "P3 Penrose Tilings"</a>
            </div>
        </content>
        <dc:subject>Python</dc:subject>
<dc:subject>SVG</dc:subject>

    </entry>

</feed>