Loading...
Logo
Processing Forum
Hi guys,

Probably, it's a silly question and it has been discussed 100 times, but I honestly can't find an answer, guys.
I really need your help... again :)

I have this beautiful sketch lovely Chrisir ( http://forum.processing.org/user/chrisir) helped me with. Which I am incredibly grateful for :)

Now I'm arranging a digital gallery to display this beautiful artworks for my university presentation (either online or only as an interactive display)

I'm doing flash animated gallery in flash.
Is there any way to play my sketch inside this animation?

 1.  Translate Processing Code into Flash code?
 2.  Input Java file into Flash animation as a scene/movie clip/etc.?
 3.  Put a button in Flash Animation that links to the java file.

Any solution is perfect for me as long as it works. Any other suggestions are very welcomed.

Thank you very much.


Here is the code:

Copy code
  1. *
    OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/66366*@*        */
    /* !do not delete the line above, required for linking your tweak if you re-upload */
    PImage img1;
    PImage img2;
    PImage img3;
    //
    int cellsize = 2; // Dimensions of each cell in the grid
    int columns, rows;   // Number of columns and rows in our system
    //
    color myColorWhite = color(255);  // save white color
    color myColorBlack = color(0);  // save black color
    void setup() {
     size(725, 560, P3D);
     img1 = loadImage("img1.png");  // Load the image
     img2 = loadImage("img2.png"); // load it
     img3 = loadImage("img3.png"); // load it
     //
     img1.loadPixels();
     img2.loadPixels();
     img3.loadPixels();
     //
     println("image data:");
     print("img1: " + img1.width+ " x ");
     println(img1.height);
     print("img2: " + img2.width+ " x ");
     println(img2.height);
     print("img3: " + img3.width+ " x ");
     println(img3.height);
     //
     columns = img1.width / cellsize;  // Calculate # of columns
     rows = img1.height / cellsize;  // Calculate # of rows
     // frameRate(1);
     // noLoop();
    } // func
    void draw() {
     background(0);
     ///
     // Begin loop for columns
     for ( int i = 0; i < columns; i++) {
       // Begin loop for rows
       for ( int j = 0; j < rows; j++) {
         //
         // do some calculations ************************
         int x = i*cellsize + cellsize/2;  // x position
         int y = j*cellsize + cellsize/2;  // y position
         int loc = x + y*img1.width;  // Pixel array location
         color c = img1.pixels[loc];  // Grab the color
         // Calculate a z position as a function of mouseX and pixel brightness (in img2)
         float z = (mouseX / float(width)) * brightness(img2.pixels[loc]) - 20.0; // use it
         //
         // Draw the lines ****************************
         // Grab the color & compare to white
         if (img3.pixels[loc] == myColorWhite) {
           // if white:
           stroke(c);  // set to white
           // line (x + 200, y + 100, -20, x + 200, y + 100, 20 ); // draw a line
           line (x + 200, y + 100, -20, x + 200, y + 100, z ); // draw a line
         } // if
         else if (img3.pixels[loc] == myColorBlack) {
           // do nothing
         }
         else
         {
           // do nothing
         }
         //
         // Draw the rects ****************************
         // Translate to the location, set fill and stroke, and draw the rect
         pushMatrix();
         translate(x + 200, y + 100, z);
         fill(c, 204);
         noStroke();
         rectMode(CENTER);
         rect(0, 0, cellsize, cellsize);
         popMatrix();
       } // for
     } // for
    } // func draw
    //
Thank you very much for your help guys!
 





Replies(2)

Have you looked at processingjs? Not flash, but javascript. You could link to it from flash.
I don't know why but your code is in one line only, making it hard to copy and paste :-)
Thanks V.K.

here is the Normal code. Sorry.
 

Copy code
  1. /* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/66366*@*        */
  2. /* !do not delete the line above, required for linking your tweak if you re-upload */
  3. PImage img1;      
  4. PImage img2;
  5. PImage img3;
  6. //
  7. int cellsize = 2; // Dimensions of each cell in the grid
  8. int columns, rows;   // Number of columns and rows in our system
  9. //
  10. color myColorWhite = color(255);  // save white color 
  11. color myColorBlack = color(0);  // save black color 
  12. void setup() {
  13.   size(725, 560, P3D);
  14.   img1 = loadImage("img1.png");  // Load the image
  15.   img2 = loadImage("img2.png"); // load it
  16.   img3 = loadImage("img3.png"); // load it
  17.   //
  18.   img1.loadPixels();
  19.   img2.loadPixels();
  20.   img3.loadPixels();
  21.   //
  22.   println("image data:");
  23.   print("img1: " + img1.width+ " x ");
  24.   println(img1.height);
  25.   print("img2: " + img2.width+ " x ");
  26.   println(img2.height); 
  27.   print("img3: " + img3.width+ " x ");
  28.   println(img3.height);
  29.   //
  30.   columns = img1.width / cellsize;  // Calculate # of columns
  31.   rows = img1.height / cellsize;  // Calculate # of rows
  32.   // frameRate(1);
  33.   // noLoop();
  34. } // func
  35. void draw() {
  36.   background(0);
  37.   ///
  38.   // Begin loop for columns
  39.   for ( int i = 0; i < columns; i++) {
  40.     // Begin loop for rows
  41.     for ( int j = 0; j < rows; j++) {
  42.       //
  43.       // do some calculations ************************
  44.       int x = i*cellsize + cellsize/2;  // x position
  45.       int y = j*cellsize + cellsize/2;  // y position
  46.       int loc = x + y*img1.width;  // Pixel array location
  47.       color c = img1.pixels[loc];  // Grab the color
  48.       // Calculate a z position as a function of mouseX and pixel brightness (in img2)
  49.       float z = (mouseX / float(width)) * brightness(img2.pixels[loc]) - 20.0; // use it
  50.       //
  51.       // Draw the lines ****************************
  52.       // Grab the color & compare to white
  53.       if (img3.pixels[loc] == myColorWhite) {  
  54.         // if white:
  55.         stroke(c);  // set to white
  56.         // line (x + 200, y + 100, -20, x + 200, y + 100, 20 ); // draw a line       
  57.         line (x + 200, y + 100, -20, x + 200, y + 100, z ); // draw a line
  58.       } // if     
  59.       else if (img3.pixels[loc] == myColorBlack) {
  60.         // do nothing
  61.       }
  62.       else
  63.       {
  64.         // do nothing
  65.       }
  66.       //
  67.       // Draw the rects ****************************
  68.       // Translate to the location, set fill and stroke, and draw the rect
  69.       pushMatrix();
  70.       translate(x + 200, y + 100, z);
  71.       fill(c, 204);
  72.       noStroke();
  73.       rectMode(CENTER);
  74.       rect(0, 0, cellsize, cellsize);
  75.       popMatrix();
  76.     } // for
  77.   } // for
  78. } // func draw
  79. //
Thanks for this processingjs reference. :)
Does it mean that i will be able to link in a web browser only, or will i be able to have my sketch as a part of the whole animation as one *.app?
Hope it's clear what i'm asking here.

Thank you. I'm going to research this processingjs now.