{"id":2398,"date":"2013-11-10T16:50:04","date_gmt":"2013-11-10T16:50:04","guid":{"rendered":"https:\/\/blog.ecotronics.ch\/wordpress\/?p=2398"},"modified":"2013-11-10T17:31:18","modified_gmt":"2013-11-10T17:31:18","slug":"animierte-archimedesspirale-in-processing","status":"publish","type":"post","link":"https:\/\/blog.ecotronics.ch\/wordpress\/?p=2398","title":{"rendered":"Animierte Archimedesspirale in Processing"},"content":{"rendered":"<p><div id=\"attachment_2410\" style=\"width: 90px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/11\/ArchimedesSpirale.png\"><img aria-describedby=\"caption-attachment-2410\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/11\/ArchimedesSpirale.png\" alt=\"Archimedesspirale\" width=\"80\" height=\"80\" class=\"size-full wp-image-2410\" \/><\/a><p id=\"caption-attachment-2410\" class=\"wp-caption-text\">Spirale<\/p><\/div>Max kam mit diesem Code in Pascal und es tauchte sofort die Frage auf, ob sich der Code auch in andere Sprachen \u00fcbersetzen l\u00e4sst. Am ehesten in Frage kam daf\u00fcr <a target=\"_blank\" href=\"http:\/\/www.processing.org\/\">Processing<\/a>, eine Entwicklungsumgebung speziell f\u00fcr visuelles Design, die ich bei meinen Arduino-Projekten kennengelernt habe.<br \/>\nHier der Processing-Code dazu:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: groovy; title: ; notranslate\" title=\"\">\r\n\/*\r\nAnimated archimedean spiral\r\nTranslated from Pascal into processing by Silvia Rothen, Switzerland\r\n*\/\r\n\r\nint myHeight = 700;\r\nint myWidth = 700;\r\nint cx = 0;\r\nint cy = 0;\r\nfloat FValueA = 3.0;\r\nfloat FValueB = 1.4;\r\nfloat angle = 0.0;\r\nfloat x1 = 0.0;\r\nfloat x2 = 0.0;\r\nfloat y1 = 0.0;\r\nfloat y2 = 0.0;\r\nint myDelay = 25;\r\nint lastTime = 0;\r\nboolean odd = false;\r\nint refresh = 0;\r\nboolean continued = true;\r\n\r\n\r\nvoid setup() {\r\n  size(myWidth, myHeight);\r\n  strokeWeight(3);\r\n  fill(255, 255, 255);\r\n  stroke(255, 255, 255, 5);\r\n  background(0, 0, 0);\r\n  cx = myWidth \/ 2;\r\n  cy = myHeight \/ 2;\r\n  frameRate(1000\/myDelay);\r\n}\r\n\r\n\/* toggle drawing with left mouse button \r\n   restart drawing with right mouse button\r\n*\/\r\nvoid mousePressed() {\r\n  if ( mouseButton == LEFT) {\r\n    continued = !continued;\r\n  }\r\n  if ( mouseButton == RIGHT) {\r\n    FValueB = 1.4;\r\n    background(0, 0, 255);\r\n    stroke(255);\r\n    x1 = 0.0;\r\n    x2 = 0.0;\r\n    y1 = 0.0;\r\n    y2 = 0.0;\r\n    continued = true;\r\n  } \r\n}\r\n\r\n\r\nvoid draw() {\r\n  if (continued) {\r\n    FValueB = FValueB + 0.001;\r\n    refresh = refresh + 1;\r\n    background(0, 0, 204);\r\n  \r\n    stroke(255, 255, 0);\r\n    for (int i = 42; i &gt;= 0; i = i-1) {\r\n      angle = FValueB * i;\r\n      x2 = cx + (FValueA + FValueB * angle) * cos(angle);\r\n      y2 = cy + (FValueA + FValueB * angle) * sin(angle);\r\n      if (i == 42) {\r\n        x1 = x2;\r\n        y1 = y2;\r\n      } else {\r\n        line(x1,y1,x2,y2);\r\n        x1 = x2;\r\n        y1 = y2;\r\n      }\r\n    }\r\n  }\r\n}\r\n<\/pre>\n<p>Und hier sieht man die Animation live (vorausgesetzt, man kann Java-Applets im Browser laufen lassen):<br \/>\n<iframe loading=\"lazy\" width=\"628\" height=\"680\" scrolling=\"no\" frameborder=\"0\" src=\"http:\/\/www.openprocessing.org\/sketch\/119848\/embed\/?width=t00&#038;height=600&#038;border=true\"><\/iframe><\/p>\n<p>Sie ist das erste publizierte Skript in meinem <a href=\"http:\/\/www.openprocessing.org\/user\/33650\" target=\"_blank\">Processing-Benutzerprofil<\/a>. Mit einem Mausklick links friert man die Animation ein und mit einem Mausklick rechts beginnt man wieder von vorne. Herzlichen Dank an Max und seine <a href=\"http:\/\/www.softwareschule.ch\/maxbox.htm\" target=\"_blank\">maXbox<\/a>, er hat mich auf dieses Skript aufmerksam gemacht.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><p id=\"caption-attachment-2410\" class=\"wp-caption-text\">Spirale<\/p>\n<p>Max kam mit diesem Code in Pascal und es tauchte sofort die Frage auf, ob sich der Code auch in andere Sprachen \u00fcbersetzen l\u00e4sst. Am ehesten in Frage kam daf\u00fcr Processing, eine Entwicklungsumgebung speziell f\u00fcr visuelles Design, die ich bei meinen Arduino-Projekten kennengelernt habe. Hier der Processing-Code dazu:<\/p>\n<p>&nbsp;<\/p>\n<p> \/* Animated archimedean spiral [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":2410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[253,3],"tags":[251,250,298,284,252],"_links":{"self":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2398"}],"collection":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2398"}],"version-history":[{"count":18,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2398\/revisions"}],"predecessor-version":[{"id":2417,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2398\/revisions\/2417"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/2410"}],"wp:attachment":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}