{"id":274,"date":"2013-03-22T10:00:28","date_gmt":"2013-03-22T10:00:28","guid":{"rendered":"http:\/\/blog.knofafo.de\/?p=274"},"modified":"2013-03-22T10:00:28","modified_gmt":"2013-03-22T10:00:28","slug":"gradients-in-ipe","status":"publish","type":"post","link":"https:\/\/blog.knofafo.de\/?p=274","title":{"rendered":"Gradients in IPE"},"content":{"rendered":"<p>I was just trying to understand, how in <a title=\"IPE on SF.net\" href=\"http:\/\/ipe7.sourceforge.net\/\" target=\"_blank\">IPE<\/a> areas can be filled with a gradient. On the <a title=\"IPE Wiki\" href=\"http:\/\/lamut.informatik.uni-wuerzburg.de\/mediawiki\/ipe7\/index.php\/Main_Page\" target=\"_blank\">IPE Wiki<\/a> you can find examples, however no documentation or comments.<!--more--><br \/>\nThe sad thing about the gradients and other complex filling patterns is that you have to write them directly in your XML stylesheet and then apply them to your document via editing the XML code of the object you want to fill. An explanation of how gradients have to be defined is included in the IPE Manuel at <a title=\"IPE: Gradients in Presentations\" href=\"http:\/\/ipe7.sourceforge.net\/manual\/manual_32.html\" target=\"_blank\">http:\/\/ipe7.sourceforge.net\/manual\/manual_32.html<\/a> and <a title=\"IPE Manual on Gradients\" href=\"http:\/\/ipe7.sourceforge.net\/manual\/manual_45.html#id20\" target=\"_blank\">http:\/\/ipe7.sourceforge.net\/manual\/manual_45.html#id20<\/a>. It is accompanied with the suggestion to create a gradient in an SVG editor as Inkscape and then, using <em>svgtoipe<\/em>, to convert the gradient to the IPE format.<br \/>\nI&#8217;d like to give a step-by-step example how I did this. Might this help me to remember the procedure and you to gain an easier access!<\/p>\n<p>Basically I have some lines in my diagram and at certain crossings I want to have a filled semicircle which is filled with a gradient that has the most intense color at the crossing and decays as a gaussian. To this end I write a stylesheet containing the gradient:<br \/>\n<code><br \/>\n&lt;gradient name='puddle' type='radial' coords='0 0 0 0 0 5'&gt;<br \/>\n&lt;stop offset=\"0\" color=\"1 0 0\" \/&gt;<br \/>\n&lt;stop offset=\"0.2\" color=\"1 0.274 0.274\" \/&gt;<br \/>\n&lt;stop offset=\"0.4\" color=\"1 0.722 0.722\" \/&gt;<br \/>\n&lt;stop offset=\"0.6\" color=\"1 0.944 0.944\" \/&gt;<br \/>\n&lt;stop offset=\"0.8\" color=\"1 0.994 0.994\" \/&gt;<br \/>\n&lt;stop offset=\"1\"\u00a0\u00a0 color=\"1\" \/&gt;<br \/>\n&lt;\/gradient&gt;<br \/>\n<\/code><br \/>\nThis gradient is <code>radial<\/code> gradient, the other possibility is an <code>axial<\/code> gradiant. For the the radial gradient you define two circles. The gradient evolves from the surface of the first circle to the second circle. Those circles are defined in the <code>coords<\/code> property as a tuple (x1 y1 r1 x2 y2 r2). x1 and y1 define the first circles center, r1 its radius. Correspondingly the second circle is defined.<\/p>\n<p>Similarly, an axial gradient can be defined by a line (x1 y1 x2 y2).<\/p>\n<p>The gradients colors are defined in the <code>stop<\/code> elements. Those elements have an <code>offset<\/code> property ranging from 0 to 1 to give the relative position where in the gradient the color, defined by the <code>color<\/code> property, appears.<\/p>\n<p>The arc object I want to fill with this gradient has the following XML-code:<br \/>\n<code><br \/>\n&lt;path matrix=\"4 0 0 4 109.156 704\" fill=\"1\" gradient=\"puddle\"&gt;<br \/>\n-5 0 m<br \/>\n5 0 0 -5 0 0 5 0 a<br \/>\n&lt;\/path&gt;<br \/>\n<\/code><\/p>\n<p>Let&#8217;s have a look at these objects! The gradient is rather simple, it contains two circles around the origin, one with a vanishing radius, the outer circle has a radius of 5. The stops are just a crude linearization of a gaussian vanishing at x = 1.<\/p>\n<p>The second object is a bit more complicated. For a general object you have to read the manual very carefully. Here I use an arc, which is defined by <strong>m<\/strong>oving to a starting point (-5, 0) an then following the <strong>e<\/strong>llipse (5 0 0 -5 0 0), I think, clockwise till we reached the point (5 0). However, as this object would appear somewhere near the corner of the whole sheet we have to transform our ellipse with the matrix (4 0 0 4 109.156 704). I&#8217;m not perfectly sure about the minus signs, but in the ellipse&#8217;s definition the first four components define the radii and the excentricities, followed by the center. The transformation matrix consists of four multipliers for radii and excentricities and a shift of the center. This is very important as the gradient has been defined around the origin. We also rescale the radii in a way that the ellipse is defined with 5 being its radius so the gradient completely fills the arc.<br \/>\nThe result is:<br \/>\n<a href=\"http:\/\/blog.knofafo.de\/wp-content\/uploads\/2013\/03\/sketch.png\"><img loading=\"lazy\" src=\"http:\/\/blog.knofafo.de\/wp-content\/uploads\/2013\/03\/sketch.png\" alt=\"sketch\" width=\"536\" height=\"137\" class=\"aligncenter size-full wp-image-281\" srcset=\"https:\/\/blog.knofafo.de\/wp-content\/uploads\/2013\/03\/sketch.png 536w, https:\/\/blog.knofafo.de\/wp-content\/uploads\/2013\/03\/sketch-300x76.png 300w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><\/p>\n<p>The file was created from <a href=\"http:\/\/blog.knofafo.de\/wp-content\/uploads\/2013\/03\/sketch.pdf\">sketch.pdf<\/a> via <code>iperender -png -resolution 150 sketch.pdf sketch.png<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was just trying to understand, how in IPE areas can be filled with a gradient. On the IPE Wiki you can find examples, however no documentation or comments.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[3,31],"tags":[32,38,40],"_links":{"self":[{"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/posts\/274"}],"collection":[{"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":9,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":285,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions\/285"}],"wp:attachment":[{"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.knofafo.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}