How to play this processing scetch inside a flash animation
in
Processing with Other Languages
•
1 year ago
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:
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:
- *
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
//
1