{"id":642,"date":"2012-11-15T03:34:04","date_gmt":"2012-11-15T03:34:04","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=642"},"modified":"2012-11-15T03:34:04","modified_gmt":"2012-11-15T03:34:04","slug":"splashing-in-puddles","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/15\/splashing-in-puddles\/","title":{"rendered":"Splashing in Puddles"},"content":{"rendered":"<p>Seeing the formation of stacked or expending circles made me think of the formation of waves and bubble. Therefore I made a sketch of a puddle that you can poke or run your finger through with your mouse. <\/p>\n<p><script type=\"application\/processing\">\r\n\/\/Info: http:\/\/processingjs.org\/reference\r\n\/\/ Project 1 \r\n\/\/ Playing With Water\r\n\/\/ By: Alex Clemens\r\n\r\n\/\/ Global Variables\r\nint BG_width = 700;\r\nint BG_height = 400;\r\nint limitRipples = 3;\r\nint shouldCreate = 0;\r\nint ripples = 0;\r\nint maxRipples = 15;\r\n\r\n\/\/ RIPPLES\r\nint[] ripX = new int[ maxRipples ];\r\nint[] ripY = new int[ maxRipples ];\r\nint[] ripDiam = new int [ maxRipples ];\r\nint[] ripDiam2 = new int[ maxRipples ];\r\nint[] ripDiam3 = new int[ maxRipples ];\r\nint[] ripFade = new int [ maxRipples ];\r\n\r\nint wakes = 0;\r\nint maxWakes = 20;\r\n\/\/ Wake\r\nint[] wakeX = new int[ maxWakes ];\r\nint[] wakeY = new int[ maxWakes ];\r\nint[] wakeDiam = new int [ maxWakes ];\r\nint[] wakeFade = new int [ maxWakes ];\r\n\r\ncolor BG_Color = color ( 172, 172, 255 );   \/\/blue, tint of purple\r\ncolor BubbleColor = color ( 202, 202, 255 );\/\/ white, tint blue\r\ncolor BubbleBorder = color ( 200, 200 );\r\n\/\/ color RippleColor = color ( 157, 157, 223 );\r\nint Ripple_R = 157;\r\nint Ripple_G = 157;\r\nint Ripple_B = 233;\r\n\/\/ color RippleBlend = color ( 172, 172, 225, 200 );\r\nint RBlend_R = 172;\r\nint RBlend_G = 172;\r\nint RBlend_B = 225;\r\n\r\n\r\nboolean showWake = false;\r\n\r\n\r\n\r\nvoid setup()\r\n{\r\n  int i;\r\n  \r\n  size ( BG_width, BG_height );\r\n  background ( BG_Color );\r\n  frameRate(60); \r\n  smooth();\r\n  \r\n  for( i = 0; i < maxRipples; i += 1 )\r\n  {\r\n    ripY[i] = ripX[i] = -1;\r\n  }\r\n  \r\n  for( i = 0; i < maxWakes; i += 1 )\r\n  {\r\n    wakeY[i] = wakeX[i] = -1;\r\n  }\r\n  \r\n}\r\n\r\n\r\nvoid draw()\r\n{\r\n  int i, j, diam;\r\n  background ( BG_Color );\r\n  \r\n  \r\n  noFill();\r\n  strokeWeight( 8 );\r\n  \r\n  for( i = 0; i < maxRipples; i += 1 )\r\n  {\r\n    if ( ripX[i] < 0)\r\n    {\r\n      ;\r\n    }\r\n    else \r\n    {\r\n        stroke( RBlend_R, RBlend_G, RBlend_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], ripDiam[i] - 8, ripDiam[i] - 8 );\r\n        stroke( Ripple_R, Ripple_G, Ripple_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], ripDiam[i], ripDiam[i] );\r\n        stroke( RBlend_R, RBlend_G, RBlend_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], ripDiam[i] + 8, ripDiam[i] + 8);\r\n        \r\n      ripDiam[i] += 10;\r\n      ripDiam2[i] = ripDiam[i] * 2 \/ 3;\r\n      ripDiam3[i] = ripDiam2[i] * 2 \/ 3;\r\n      ripFade[i] -= 2;\r\n      if( ripFade[i] < 0 )\r\n      {\r\n        ripFade[i] = 0;\r\n      }\r\n      for( j = 0; j < 2; j += 1 )\r\n      {\r\n        if( j == 0 )\r\n        { diam = ripDiam2[i]; }\r\n        else diam = ripDiam3[i]; \r\n        \r\n        stroke( RBlend_R, RBlend_G, RBlend_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], diam - 8, diam - 8 );\r\n        stroke( Ripple_R, Ripple_G, Ripple_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], diam, diam );\r\n        stroke( RBlend_R, RBlend_G, RBlend_B, ripFade[i]);\r\n        ellipse( ripX[i], ripY[i], diam + 8, diam + 8);\r\n      }\r\n    }\r\n  }\r\n  \r\n  if( showWake )\r\n  {\r\n    i = mouseX + ( mouseX - pmouseX );\r\n    j = mouseY + ( mouseY - pmouseY );\r\n    \r\n    wakes = wakes % maxWakes;\r\n  \r\n    wakeX[wakes] = i;\r\n    wakeY[wakes] = j;\r\n    wakeFade[wakes] = 25;\r\n    wakeDiam[wakes] = (( mouseX - pmouseX ) + ( mouseY - pmouseY )) \/ 3;\r\n  \r\n    wakes += 1;\r\n    \r\n    \/\/ prevent too many ripples\r\n    if( mouseX != pmouseX && mouseY != pmouseY );\r\n    {\r\n    if( shouldCreate == limitRipples )\r\n    {\r\n    shouldCreate = 0;\r\n    ripples = ripples % maxRipples;\r\n  \r\n    ripX[ripples] = mouseX;\r\n    ripY[ripples] = mouseY;\r\n    ripFade[ripples] = 60;\r\n    ripDiam[ripples] = ripDiam2[ripples] = ripDiam3[ripples] = 3;\r\n   \r\n    ripples += 1;\r\n    }\r\n    \r\n    else\r\n    {\r\n      shouldCreate += 1;\r\n    }\r\n    }\r\n  }\r\n \r\n  noStroke();\r\n  for( i = 0; i < maxWakes; i += 1 )\r\n  {\r\n    if ( wakeX[i] < 0)\r\n    {\r\n      ;\r\n    }\r\n    else \r\n    {\r\n      fill( 255, wakeFade[i] );\r\n      ellipse( wakeX[i], wakeY[i], wakeDiam[i], wakeDiam[i] );\r\n      wakeFade[i] = wakeFade[i] - 4;\r\n      wakeDiam[i] = wakeDiam[i] - 4;\r\n    }\r\n  }\r\n}\r\n\r\nvoid mousePressed()\r\n{\r\n  \r\n  \/\/ prevent too many ripples\r\n  ripples = ripples % maxRipples;\r\n  \r\n  ripX[ripples] = mouseX;\r\n  ripY[ripples] = mouseY;\r\n  ripFade[ripples] = 90;\r\n  ripDiam[ripples] = ripDiam2[ripples] = ripDiam3[ripples] = 3;\r\n  \r\n  ripples += 1;\r\n  \r\n}\r\n\r\nvoid mouseDragged()\r\n{\r\n  showWake = true;\r\n}\r\n\r\nvoid mouseReleased()\r\n{\r\n  showWake = false;\r\n  \r\n  \/\/ prevent too many ripples\r\n  ripples = ripples % maxRipples;\r\n  \r\n  ripX[ripples] = mouseX;\r\n  ripY[ripples] = mouseY;\r\n  ripFade[ripples] = 60;\r\n  ripDiam[ripples] = ripDiam2[ripples] = ripDiam3[ripples] = 2;\r\n  \r\n  ripples += 1;\r\n  \r\n}\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Seeing the formation of stacked or expending circles made me think of the formation of waves and bubble. Therefore I made a sketch of a puddle that you can poke or run your finger through with your mouse.<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/642"}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=642"}],"version-history":[{"count":3,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/642\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}