Hi
-
Im brand new to processing, but Ive hacked around a few other scripting languages before so things seem really nice at processing.
what I am trying to do, is make a generative logo for my company (www.bigman3d.com)
I want to define generative colour artwork 100x100, then mask that with one of the triangle shapes
then repeat for each shape, building up the design piece by piece.
-
problem is, using either the mask() or blend() the code works in the processing app, but not online
Here is the processing for HTML that doesnt mask
Here is the processing pde version that creates a perfectly masked triangle
Here is the difference, both side by side
Here is the associated processing.init.js file
http://processingjs.org/learning
Ive found that by linking to a locally stored processing-1.3.0.js found on this page I just get a blank screen
http://processingjs.org/download
-
If anyone could shine any light on this It would be massively appreciated, I have exactly the same problem with the .mask() function working in the processing app but not in the .js version
-
cheers
Tom
-
Im brand new to processing, but Ive hacked around a few other scripting languages before so things seem really nice at processing.
what I am trying to do, is make a generative logo for my company (www.bigman3d.com)
I want to define generative colour artwork 100x100, then mask that with one of the triangle shapes
then repeat for each shape, building up the design piece by piece.
-
problem is, using either the mask() or blend() the code works in the processing app, but not online
Here is the processing for HTML that doesnt mask
- <html>
- <head>
- <title>Processing.js - Basic Example</title>
- <script language="javascript" src="processing.init.js"></script>
- <script language="javascript" src="processing.js"></script>
- </head>
- <body bgcolor="#000000">
- <script type="application/processing">
- /*
- Generative Tangram using processing
- seems there is a bug with the javascript version, cos this works nice on the default processing
- */
- // Global variables
- // Create a blank image for each colour and alpha, 100x100 pixels with RGB color
- PImage shapeA_RGB = createImage(100,100,RGB);
- PImage shapeA_ALPHA = createImage(100,100,RGB);
- PImage shapeA_ARGB = createImage(100,100,RGB);
- PImage shapeB_RGB = createImage(100,100,RGB);
- PImage shapeB_ALPHA = createImage(100,100,RGB);
- PImage shapeC_RGB = createImage(100,100,RGB);
- PImage shapeC_ALPHA = createImage(100,100,RGB);
- PImage shapeD_RGB = createImage(100,100,RGB);
- PImage shapeD_ALPHA = createImage(100,100,RGB);
- PImage shapeE_RGB = createImage(100,100,RGB);
- PImage shapeE_ALPHA = createImage(100,100,RGB);
- PImage shapeF_RGB = createImage(100,100,RGB);
- PImage shapeF_ALPHA = createImage(100,100,RGB);
- PImage shapeG_RGB = createImage(100,100,RGB);
- PImage shapeG_ALPHA = createImage(100,100,RGB);
- // Setup the Processing Canvas
- void setup(){
- size( 100, 100 );
- strokeWeight( 0 );
- fill(255,255,255);
- frameRate( 15 );
- }
- // Main draw loop
- void draw(){
- noStroke();
- strokeWeight( 0 );
- // Capture shapeA (triangle at the top) RGB
- background(0);
- fill(random(255),random(255),random(255));
- quad(0, 0, 100, 0, 100, 100, 0, 100) ;
- loadPixels();
- PImage shapeA_RGB = get();
- // Capture shapeA (triangle at the top) ALPHA
- background(0);
- fill(255);
- triangle(0, 0, 50, 50, 100, 0) ;
- loadPixels();
- PImage shapeA_ALPHA = get();
- // Draw shapeB triangle2 (left)
- //fill( random(255), random(255), random(255));
- //triangle(0, 0, 50, 50, 0, 100) ;
- // Draw shapeC triangle3 (middle)
- //fill( random(255), random(255), random(255));
- //triangle(50, 50, 75, 25, 75, 75) ;
- // Draw shapeD rhombus on the right
- //fill( random(255), random(255), random(255));
- //quad(75, 25, 100, 0, 100, 50, 75, 75) ;
- // Draw shapeE triangle5 (bottom right)
- //fill( random(255), random(255), random(255));
- //triangle(100, 50, 50, 100, 100, 100) ;
- // Draw shapeF triangle6 (bottom left)
- //fill( random(255), random(255), random(255));
- //triangle(0, 100, 25, 75, 50, 100) ;
- // Draw shapeG square near the bottom
- //fill( random(255), random(255), random(255));
- //quad(25, 75, 50, 50, 75, 75, 50, 100) ;
- // lets draw shape A
- background(0);
- image(shapeA_RGB,0,0);
- //image(shapeA_ALPHA,0,0);
- //blend(shapeA_ALPHA,0,0,100,100,0,0,100,100,MULTIPLY);
- exit();
- }
- void mousePressed()
- {
- redraw();
- }
- </script><canvas width="100px" height="100px"></canvas>
- <pre>
- </pre>
- </body>
- </html>
Here is the processing pde version that creates a perfectly masked triangle
- /*
- Generative Tangram using processing
- seems there is a bug with the javascript version, cos this works nice on the default processing
- */
- // Global variables
- // Create a blank image for each colour and alpha, 100x100 pixels with RGB color
- PImage shapeA_RGB = createImage(100,100,RGB);
- PImage shapeA_ALPHA = createImage(100,100,RGB);
- PImage shapeA_ARGB = createImage(100,100,RGB);
- PImage shapeB_RGB = createImage(100,100,RGB);
- PImage shapeB_ALPHA = createImage(100,100,RGB);
- PImage shapeC_RGB = createImage(100,100,RGB);
- PImage shapeC_ALPHA = createImage(100,100,RGB);
- PImage shapeD_RGB = createImage(100,100,RGB);
- PImage shapeD_ALPHA = createImage(100,100,RGB);
- PImage shapeE_RGB = createImage(100,100,RGB);
- PImage shapeE_ALPHA = createImage(100,100,RGB);
- PImage shapeF_RGB = createImage(100,100,RGB);
- PImage shapeF_ALPHA = createImage(100,100,RGB);
- PImage shapeG_RGB = createImage(100,100,RGB);
- PImage shapeG_ALPHA = createImage(100,100,RGB);
- // Setup the Processing Canvas
- void setup(){
- size( 100, 100 );
- strokeWeight( 0 );
- fill(255,255,255);
- frameRate( 15 );
- }
- // Main draw loop
- void draw(){
- noStroke();
- strokeWeight( 0 );
- // Capture shapeA (triangle at the top) RGB
- background(0);
- fill(random(255),random(255),random(255));
- quad(0, 0, 100, 0, 100, 100, 0, 100) ;
- loadPixels();
- PImage shapeA_RGB = get();
- // Capture shapeA (triangle at the top) ALPHA
- background(0);
- fill(255);
- triangle(0, 0, 50, 50, 100, 0) ;
- loadPixels();
- PImage shapeA_ALPHA = get();
- // Draw shapeB triangle2 (left)
- //fill( random(255), random(255), random(255));
- //triangle(0, 0, 50, 50, 0, 100) ;
- // Draw shapeC triangle3 (middle)
- //fill( random(255), random(255), random(255));
- //triangle(50, 50, 75, 25, 75, 75) ;
- // Draw shapeD rhombus on the right
- //fill( random(255), random(255), random(255));
- //quad(75, 25, 100, 0, 100, 50, 75, 75) ;
- // Draw shapeE triangle5 (bottom right)
- //fill( random(255), random(255), random(255));
- //triangle(100, 50, 50, 100, 100, 100) ;
- // Draw shapeF triangle6 (bottom left)
- //fill( random(255), random(255), random(255));
- //triangle(0, 100, 25, 75, 50, 100) ;
- // Draw shapeG square near the bottom
- //fill( random(255), random(255), random(255));
- //quad(25, 75, 50, 50, 75, 75, 50, 100) ;
- // lets draw shape A
- background(0);
- image(shapeA_RGB,0,0);
- //image(shapeA_ALPHA,0,0);
- blend(shapeA_ALPHA,0,0,100,100,0,0,100,100,MULTIPLY);
- exit();
- }
- void mousePressed()
- {
- redraw();
- }
Here is the difference, both side by side
Here is the associated processing.init.js file
- if(window.addEventListener){window.addEventListener("load",function(){var scripts=document.getElementsByTagName("script");for(var i=0;i<scripts.length;i++){if(scripts[i].type=="application/processing"){var src=scripts[i].src,canvas=scripts[i].nextSibling;if(src&&src.indexOf("#")){canvas=document.getElementById(src.substr(src.indexOf("#")+1));}else{while(canvas&&canvas.nodeName.toUpperCase()!="CANVAS")canvas=canvas.nextSibling;}if(canvas){Processing(canvas,scripts[i].text);}}}},false);}
http://processingjs.org/learning
Ive found that by linking to a locally stored processing-1.3.0.js found on this page I just get a blank screen
http://processingjs.org/download
-
If anyone could shine any light on this It would be massively appreciated, I have exactly the same problem with the .mask() function working in the processing app but not in the .js version
-
cheers
Tom
1