{"id":2623,"date":"2016-06-23T16:37:34","date_gmt":"2016-06-23T16:37:34","guid":{"rendered":"http:\/\/louisc.co.uk\/?p=2623"},"modified":"2016-11-05T11:17:47","modified_gmt":"2016-11-05T11:17:47","slug":"drawing-arcs-and-text-with-the-geomerative-processing-library","status":"publish","type":"post","link":"https:\/\/louisc.co.uk\/?p=2623","title":{"rendered":"Drawing Arcs and Text with the Geomerative Processing Library"},"content":{"rendered":"<div class=\"fusion-fullwidth fullwidth-box hundred-percent-fullwidth non-hundred-percent-height-scrolling\"  style='background-color: rgba(255,255,255,0);background-position: center center;background-repeat: no-repeat;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;'><div class=\"fusion-builder-row fusion-row \"><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t<div id=\"attachment_2647\" style=\"width: 260px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2647\" class=\"wp-image-2647 size-full\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louis_co_uk_waveyArms.gif\" alt=\"Stick Figure Waving Arms\" width=\"250\" height=\"200\" \/><p id=\"caption-attachment-2647\" class=\"wp-caption-text\">Download Code for Mr Wavy Dude below.<\/p><\/div>\n<p>Fist introduced\u00a0in this post\u00a0(, I am currently working on a project titled the &#8220;Kinetic Story Teller&#8221; with friend and artist\u00a0<a href=\"http:\/\/www.tinebech.com\/\" target=\"_blank\">Tine Bech<\/a>. \u00a0This is a visual arts interaction piece and as such I am \u00a0learning <a href=\"https:\/\/www.processing.org\/\" target=\"_blank\">Processing<\/a>. This is another post sharing logging and sharing my learning journey.<\/p>\n<p>The new visual design will re-focus the piece on a concept which was part of the original plan; the idea of flow and waves. These will be waves of information drawn in a playful manner from twitter based on #tags each participant can select.<\/p>\n<p>Back to the task at hand! I found a great library named &#8220;Geomerative&#8221; \u00a0(<span style=\"text-decoration: underline;\"><strong><a href=\"http:\/\/www.ricardmarxer.com\/geomerative\/\" target=\"_blank\">Website<\/a><\/strong><\/span>) by<strong> <a href=\"http:\/\/www.ricardmarxer.com\/\" target=\"_blank\">Ricard Marxer<\/a>.<\/strong>\u00a0 I have struggled to find many similar sketches online other than those included in the examples, so i figured I would share my progress. This post whilst keeping a log for my own future use, I hope may serve as a reference for others\u00a0out there with the same aims as me.<\/p>\n<h2>Geomerative Bezier Lines<\/h2>\n<p>From what I understand thus\u00a0far, the geomerative library allows for the definition of a RShape object. This object is formed of a series of path objects of type RPath. The RShape object provides a range of utility functions for interfacing with and manipulating the generated shape.<\/p>\n<p>In our case once we generate our RShape object, we will want to add a curve, looking though the documentation <a href=\"http:\/\/www.ricardmarxer.com\/geomerative\/documentation\/geomerative\/RShape.html#addBezierTo(geomerative.RPoint, geomerative.RPoint, geomerative.RPoint)\" target=\"_blank\">here<\/a>, we do this by calling:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npublic void addBezierTo(float cp1x,\r\n               float cp1y,\r\n               float cp2x,\r\n               float cp2y,\r\n               float endx,\r\n               float endy)\r\n<\/pre>\n<p>The documentation defines the following parameters:<\/p>\n<p>cp1x &#8211; the x coordinate of the first control point of the bezier.<br \/>\ncp1y &#8211; the y coordinate of the first control point of the bezier.<br \/>\ncp2x &#8211; the x coordinate of the second control point of the bezier.<br \/>\ncp2y &#8211; the y coordinate of the second control point of the bezier.<br \/>\nendx &#8211; the x coordinate of the ending point of the bezier.<br \/>\nendy &#8211; the y coordinate of the ending point of the bezier.<\/p>\n<p>Lets explore what these mean with some drawing examples. Lets begin by creating a simple script drawing a single bezier curve. Here cp1 is green, cp2 blue and end is red.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2629 size-full\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier.jpg\" alt=\"louisc_co_uk_SingleBezier\" width=\"640\" height=\"380\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier-200x119.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier-300x178.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier-400x238.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier-600x356.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_SingleBezier.jpg 640w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>The code for making this:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nimport geomerative.*;\r\n\r\nRShape wave;\r\n\r\nvoid setup()\r\n{\r\n  \/\/ From the examples we must always initialise the library using this command\r\n  RG.init(this);\r\n  \r\n  \/\/Usual Processing Jazz\r\n  size(640 ,380);\r\n  background(255);\r\n  \r\n  \/\/Set up a little for the look and feel\r\n  \/\/fill(255, 102, 0);\r\n  stroke(0);\r\n  strokeWeight(2);\r\n    \r\n  \/\/Now we generate a new RShape object in which to create our wavy shape and \r\n  \/\/assign its reference as wave\r\n  RShape wave = new RShape();\r\n  \r\n  \/\/At the moment the wave object is empty, so lets add a curve:\r\n  wave.addBezierTo(0, 0, 50, 0, 100, 100);\r\n   \r\n  \/\/Lets start to draw away from the edges\r\n  translate(width\/4, height\/4);\r\n  \/\/Draw our wave shape\r\n  wave.draw();\r\n  \r\n  \/\/Create a visual reference for our control points\r\n  strokeWeight(0.5);\r\n  line(0,0,50,0);\r\n  strokeWeight(5);\r\n  stroke(0, 255, 0); \/\/Green\r\n  point(0,0);\r\n  stroke(0, 0, 255); \/\/Blue\r\n  point(50,0);\r\n  stroke(255, 0, 0); \/\/Red\r\n  point(100,100);\r\n}\r\n\r\nvoid draw(){\r\n}\r\n\r\n<\/pre>\n<p>Now in our case we\u00a0would like to start from the bottom, but, moving the coordinates for cp1 down to 0, 100 did not have the desired result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2638 alignnone\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067.jpg\" alt=\"louisc_co_uk_Geromerative1-000067\" width=\"640\" height=\"380\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067-200x119.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067-300x178.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067-400x238.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067-600x356.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000067.jpg 640w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nwave.addBezierTo(0, 100, 50, 0, 100, 100);\r\n<\/pre>\n<p>So, it seems cp1 is exactly that, a control point not a start point. So a little investigation on how to move this point uncovers the function:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\npublic void addMoveTo(float endx,\r\n             float endy)\r\n<\/pre>\n<p>Adding this moves the starting point back to the same value as cp1:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2642 alignnone\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074.jpg\" alt=\"louisc_co_uk_Geromerative1-000074\" width=\"640\" height=\"380\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074-200x119.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074-300x178.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074-400x238.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074-600x356.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000074.jpg 640w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>with:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\nwave.addMoveTo(0, 100);\r\n wave.addBezierTo(0, 100, 50, 0, 100, 100);\r\n\r\n<\/pre>\n<p>Ok so since we have a better idea of what these points do, lets try to extend our shape to make it more &#8216;wave&#8217; like. I have also added some coordinate references to give a better idea of whats going on:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2643 alignnone\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058.jpg\" alt=\"louisc_co_uk_Geromerative1-000058\" width=\"640\" height=\"380\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058-200x119.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058-300x178.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058-400x238.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058-600x356.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000058.jpg 640w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>The code defining our shape now looks like:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\n wave.addMoveTo(0, 100);\r\n wave.addBezierTo(0, 100, 50, 0, 100, 100);\r\n wave.addBezierTo(100, 100, 150, 200, 200, 100);\r\n\r\n<\/pre>\n<p>Finally, lets complete the wave shape by adding a final curve:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2646 alignnone\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118.jpg\" alt=\"louisc_co_uk_Geromerative1-000118\" width=\"640\" height=\"380\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118-200x119.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118-300x178.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118-400x238.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118-600x356.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative1-000118.jpg 640w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>So, we have used the geomerative library to create our first shape which is a series of bezier curves. The next step is to translate this into an object and design in a way to create variations of this curve for each object.<\/p>\n<h1>Download<\/h1>\n<p>Head over to github:<\/p>\n<p>https:\/\/github.com\/louisc\/processing-standalone-sketches<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":2650,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[103,28,30],"tags":[112,113,105,109,110,107,111],"class_list":["post-2623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kinetic-storyteller","category-projects","category-tinkering","tag-design","tag-geomerative","tag-graphics","tag-processing","tag-programming","tag-tine-bech","tag-visuals"],"_links":{"self":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2623"}],"version-history":[{"count":24,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2623\/revisions"}],"predecessor-version":[{"id":2716,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2623\/revisions\/2716"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/media\/2650"}],"wp:attachment":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}