mirror of
https://github.com/processing/processing4.git
synced 2026-04-22 20:24:45 +02:00
Examples mods for 2.0
This commit is contained in:
@@ -2,20 +2,21 @@
|
||||
* Zoom.
|
||||
*
|
||||
* Move the cursor over the image to alter its position. Click and press
|
||||
* the mouse to zoom and set the density of the matrix by typing numbers 1-5.
|
||||
* This program displays a series of lines with their heights corresponding to
|
||||
* a color value read from an image.
|
||||
* the mouse to zoom. This program displays a series of lines with their
|
||||
* heights corresponding to a color value read from an image.
|
||||
*/
|
||||
|
||||
// @pjs preload must be used to preload media if the program is
|
||||
// running with Processing.js
|
||||
/* @pjs preload="ystone08.jpg"; */
|
||||
|
||||
PImage img;
|
||||
//boolean onetime = true;
|
||||
int[][] imgPixels;
|
||||
float sval = 1.0;
|
||||
float nmx, nmy;
|
||||
int res = 5;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
size(640, 360, P3D);
|
||||
noFill();
|
||||
stroke(255);
|
||||
@@ -28,11 +29,10 @@ void setup()
|
||||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
nmx = nmx + (mouseX-nmx)/20;
|
||||
nmx += (mouseX-nmx)/20;
|
||||
nmy += (mouseY-nmy)/20;
|
||||
|
||||
if(mousePressed) {
|
||||
@@ -42,9 +42,9 @@ void draw()
|
||||
sval -= 0.01;
|
||||
}
|
||||
|
||||
sval = constrain(sval, 1.0, 2.5);
|
||||
sval = constrain(sval, 1.0, 2.0);
|
||||
|
||||
translate(width/2 + nmx * sval-100, height/2 + nmy*sval - 200, -50);
|
||||
translate(width/2 + nmx * sval-100, height/2 + nmy*sval - 100, -50);
|
||||
scale(sval);
|
||||
rotateZ(PI/9 - sval + 1.0);
|
||||
rotateX(PI/sval/8 - 0.125);
|
||||
@@ -64,24 +64,6 @@ void draw()
|
||||
}
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
if(key == '1') {
|
||||
res = 1;
|
||||
}
|
||||
else if (key == '2') {
|
||||
res = 2;
|
||||
}
|
||||
else if (key == '3') {
|
||||
res = 3;
|
||||
}
|
||||
else if (key == '4') {
|
||||
res = 4;
|
||||
}
|
||||
else if (key == '5') {
|
||||
res = 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user