{"id":951,"date":"2018-08-21T21:24:57","date_gmt":"2018-08-21T21:24:57","guid":{"rendered":"http:\/\/martindebie.com\/workshop\/?p=951"},"modified":"2022-01-10T12:50:38","modified_gmt":"2022-01-10T12:50:38","slug":"processing","status":"publish","type":"post","link":"https:\/\/martindebie.com\/workshop\/processing\/","title":{"rendered":"PROCESSING"},"content":{"rendered":"\n<p><a href=\"https:\/\/processing.org\/download\">DOWNLOAD<\/a><\/p>\n\n\n\n<p><iframe loading=\"lazy\" src=\"https:\/\/docs.google.com\/presentation\/d\/e\/2PACX-1vT-su2ecBUzI3G_e8GL0qWK1-f089PUjpbW8UEsEFinGNch6k8Q3f1C3dc0kILSEXy5j6Oquo2V3neE\/embed?start=false&amp;loop=false&amp;delayms=3000\" width=\"960\" height=\"569\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BASIC SHAPES<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ rect (position X, position Y, width, height);\nrect (0,0,20,20);\n\/\/ ellipse (position X, position Y, width, height);\nellipse (50,50,20,20);\n\/\/ line (position X first point, position Y first point, position X second point, position Y second point);\nline (10,10,90,90);\n\/\/ point (position X, position Y);\npoint (70,70);<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-22-at-15.58.22.png\"><img loading=\"lazy\" decoding=\"async\" width=\"214\" height=\"214\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-22-at-15.58.22.png\" alt=\"\" class=\"wp-image-961\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-22-at-15.58.22.png 214w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-22-at-15.58.22-150x150.png 150w\" sizes=\"auto, (max-width: 214px) 100vw, 214px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">COLOR<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ color fill shape gray\nfill(125);\nrect (10,10,40,40);<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/rgb-e1534946408355.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"269\" height=\"246\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/rgb-e1534946408355.jpg\" alt=\"\" class=\"wp-image-963\"\/><\/a><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ color fill shape (Red,Green,Blue);\nfill(0,255,0);\n\/\/ color stroke shape (Red,Green,Blue);\nstroke(255,0,0);\n\/\/ Weight of stroke (pixel)\nstrokeWeight(20);\nrect (10,10,40,40);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Use color selector to select a specific color<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"232\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/selectorColor-300x232.png\" alt=\"\" class=\"wp-image-2259\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/selectorColor-300x232.png 300w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/selectorColor-768x594.png 768w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/selectorColor.png 874w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Custom color mode<\/strong><\/h2>\n\n\n\n<p>You can chose the range of each value of the color at the beginning of your code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Red values from 0 to 100, green from 0 to 500, blue from 0 to 10, and alpha from 0 to 255.\ncolorMode(RGB,100,500,10,255);<\/code><\/pre>\n\n\n\n<p><strong>Other color mode<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"240\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/hsb-300x240.png\" alt=\"\" class=\"wp-image-2260\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/hsb-300x240.png 300w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/hsb-768x614.png 768w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2022\/01\/hsb.png 1000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<p><strong>Hue<\/strong>\u2014The color type, ranges from 0 to 255 by default.<br><strong>Saturation<\/strong>\u2014The vibrancy of the color, 0 to 255 by default.<br><strong>Brightness<\/strong>\u2014The, well, brightness of the color, 0 to 255 by default.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">INTERACTION<\/h2>\n\n\n\n<p>To put interaction into your code you need to use two function &#8220;void setup&#8221; and &#8220;void draw&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/function that execute once at the begin of the code to setup basic element\nvoid setup() {\n size(100, 100);\n background (255);\n}\n\n\/\/function that execute the code inside in loop\nvoid draw() {\n\/\/instead of using static value for position of the ellipse you can use the position of your mouse to define it (variables)\n  ellipse(mouseX, mouseY, 33, 33);\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-medium\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57-300x300.png\" alt=\"\" class=\"wp-image-970\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57-300x300.png 300w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57-150x150.png 150w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57-768x768.png 768w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-23-at-09.54.57.png 794w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">CONDITION<\/h2>\n\n\n\n<p>If you want to increase interaction in your code, you can start to add question into. Put some conditions and one way is to use &#8220;if&#8221; and &#8220;else&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\nsize(400, 400);\nbackground (255);\n}\n\nvoid draw() {\nellipse(mouseX, mouseY, 33, 33);\n\/\/ If i pressed on my mouse my background will be fill in white\nif (mousePressed) {\nbackground (255);\n }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/animgif.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"480\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/animgif.gif\" alt=\"\" class=\"wp-image-980\"\/><\/a><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>void setup() {\n  size(400, 400);\n  background (255);\n}\n\nvoid draw() {\n  if (mousePressed) {\n  fill(242,34,208);\n  }\n  else {\n  noStroke();\n  fill(142,255,15);\n  }\n  ellipse(mouseX, mouseY, 33, 33);\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/anim3gif.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"480\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/anim3gif.gif\" alt=\"\" class=\"wp-image-979\"\/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">IMAGE<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Create object img\nPImage img;\n\/\/boolean value to stop loop\nboolean stop =true;\n\nvoid setup() {\n  size(600, 600);\n  background(0);\n  \/\/ Images must be in the \"data\" directory to load correctly\n  img = loadImage(\"fish.png\");\n}\n\nvoid draw() {\n  if (stop == true) {\n    \/\/ loop to do this action 10 times\n    for (int i=0; i&amp;lt;10; i++) {\n      image(img, random(width-240), random(height-112), 240, 112);\n    }\n    \/\/ switch the value state\n    stop = !stop;\n  }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-09.27.55.png\"><img loading=\"lazy\" decoding=\"async\" width=\"598\" height=\"594\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-09.27.55.png\" alt=\"\" class=\"wp-image-1000\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-09.27.55.png 598w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-09.27.55-150x150.png 150w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-09.27.55-300x298.png 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">CAMERA<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import processing.video.*;\n\nCapture camera; \n\nvoid setup() {\n  size(640, 480);\n  background(0);\n  String&#91;] devices = Capture.list();\n  println(devices);\n  camera = new Capture(this, 640, 480, devices&#91;0]);\n  camera.start();\n}\n\nvoid draw() {\n  if (camera.available()) {\n    camera.read();\n    image(camera, 0, 0);\n    filter(INVERT);\n  }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-20.18.25.png\"><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"473\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-20.18.25.png\" alt=\"\" class=\"wp-image-1002\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-20.18.25.png 634w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-29-at-20.18.25-300x224.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">MICROPHONE<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import processing.sound.*;\n\nAudioIn input;\nAmplitude loudness;\n\nvoid setup() {\n  size(600, 600);\n  background(0);\n  input = new AudioIn(this, 0);\n  input.start();\n  loudness = new Amplitude(this);\n  loudness.input(input);\n}\n\nvoid draw() {\n float volume = loudness.analyze();\n  int size = int(map(volume, 0, 0.5, 1, 600));\n\n  background(0);\n  noStroke();\n  fill(255, 0, 150);\n  ellipse(width\/2, height\/2, size, size);\n\n  println(inputLevel);\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-30-at-13.33.45.png\"><img loading=\"lazy\" decoding=\"async\" width=\"576\" height=\"573\" src=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-30-at-13.33.45.png\" alt=\"\" class=\"wp-image-1005\" srcset=\"https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-30-at-13.33.45.png 576w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-30-at-13.33.45-150x150.png 150w, https:\/\/martindebie.com\/workshop\/wp-content\/uploads\/2018\/08\/Screen-Shot-2018-08-30-at-13.33.45-300x298.png 300w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SIMPLE PAINT<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docplayer.fr\/docs-images\/25\/5530398\/images\/5-0.png\" alt=\"R\u00c3\u00a9sultat de recherche d'images pour &quot;simple paint logiciel&quot;\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Code to create a simple paint with\ncolor couleur = color(255);\nfloat epaisseur = 4;\nint i=0;\n\nvoid setup() {\n  size(700, 700);\n  background(0);\n}\n\nvoid draw() {\n  dessiner();\n  indicateur();\n  colorPicker();\n  gomme();\n  erase();\n  sizeStroke();\n  enregistrer();\n}\n\nvoid gomme() {\n  if (keyPressed == true) {\n    if (key == 'a'|| key == 'A' &amp;amp;&amp;amp; mousePressed == true) {\n      stroke(0);\n      strokeWeight(20);\n      line(pmouseX, pmouseY, mouseX, mouseY);\n    }\n  }\n}\n\nvoid indicateur() {\n  noStroke();\n  fill(couleur);\n  rect(0, 0, 40, 40);\n}\n\nvoid dessiner() {\n  if (mousePressed == true) {\n    strokeWeight(epaisseur);\n    stroke(couleur);\n    line(pmouseX, pmouseY, mouseX, mouseY);\n  }\n}\n\nvoid colorPicker() {\n  if (mousePressed == true &amp;amp;&amp;amp; mouseX &amp;lt;= 40 &amp;amp;&amp;amp; mouseY &amp;lt;= 40) {\n    couleur=color(random(255), random(255), random(255));\n  }\n}\n\nvoid erase() {\n  if (keyPressed == true) {\n    if (key == 'E' || key == 'e') {\n      background(0);\n    }\n  }\n}\n\nvoid sizeStroke() {\n  if (keyPressed == true) {\n    if (key == CODED) {\n      if (keyCode == UP) {\n        epaisseur = epaisseur+0.1;\n      }\n      if (keyCode == DOWN) {\n        epaisseur = epaisseur-0.1;\n        if (epaisseur &amp;lt;= 0.5) epaisseur = 0.5;\n      }\n    }\n  }\n}\n\nvoid enregistrer() {\n  if (keyPressed == true) {\n    if (key == 'S' || key == 's') {\n      save(i+\"dessin.png\");\n      println(\"save\");\n      i++;\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DOWNLOAD BASIC SHAPES COLOR Use color selector to select a specific color Custom color mode&#8230;<\/p>\n","protected":false},"author":1,"featured_media":986,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-951","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/comments?post=951"}],"version-history":[{"count":32,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/951\/revisions"}],"predecessor-version":[{"id":2261,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/posts\/951\/revisions\/2261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/media\/986"}],"wp:attachment":[{"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/media?parent=951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/categories?post=951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/martindebie.com\/workshop\/wp-json\/wp\/v2\/tags?post=951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}