No edit summary |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[user:pd|Pascal Delor]] | ==[[user:pd|Pascal Delor]]== | ||
=== homework 1 === | === homework 1 === | ||
<source lang = "java"> | |||
void setup() | |||
{ | |||
size(400,400); | |||
background(0,0,0); | |||
frameRate(9); | |||
println(frameCount); | |||
println(frameRate); | |||
} | |||
void draw() | |||
{ | |||
PImage image1 = loadImage("park_001.jpg"); | |||
PImage image2 = loadImage("park_002.jpg"); | |||
PImage image3 = loadImage("park_003.jpg"); | |||
PImage image4 = loadImage("park_004.jpg"); | |||
PImage image5 = loadImage("park_005.jpg"); | |||
PImage image6 = loadImage("park_006.jpg"); | |||
PImage image7 = loadImage("park_sieben.jpg"); | |||
PImage image8 = loadImage("park_acht.jpg"); | |||
PImage image9 = loadImage("park_009.jpg"); | |||
if (frameCount % 9 == 1) { | |||
image(image1,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 2) { | |||
image(image2,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 3) { | |||
image(image3,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 4) { | |||
image(image4,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 5) { | |||
image(image5,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 6) { | |||
image(image6,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 7) { | |||
image(image7,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 8) { | |||
image(image8,0,0,400,400); | |||
} | |||
if (frameCount % 9 == 0) { | |||
image(image9,0,0,400,400); | |||
} | |||
println(frameCount % 9); | |||
println(frameCount); | |||
println(frameRate); | |||
} | |||
</source> | |||
==== grid of nine photos - addition to homework 1 ==== | |||
<source lang = "java"> | |||
image(image1,0,0,100,100); | |||
image(image2,100,0,100,100); | |||
image(image3,200,0,100,100); | |||
image(image4,0,100,100,100); | |||
image(image5,100,100,100,100); | |||
image(image6,200,100,100,100); | |||
image(image7,0,200,100,100); | |||
image(image8,100,200,100,100); | |||
image(image9,200,200,100,100); | |||
</source> | |||
=== homework 2 === | === homework 2 === | ||
<source lang = "java"> | |||
// number of max slices | |||
int maxSlices = 256; | |||
Slice[] slice = new Slice[maxSlices]; | |||
// number of start slices | |||
int n = 16; | |||
float step = 2; | |||
PImage img; | |||
void setup() { | |||
smooth(); | |||
background(0); | |||
img = loadImage("farbe_008.jpg"); | |||
img.resize(600,1000); | |||
size(600,600); | |||
for (int i = 0; i < n; i++) { | |||
slice[i] = new Slice(int(i*img.width/n),int(img.width/n),img); | |||
} | |||
println(width); | |||
println(height); | |||
} | |||
void draw() { | |||
// background colour | |||
fill(0); | |||
// create rectangle with width and height of the image | |||
rect(0,0,width,height); | |||
for (int i = 0; i < n; i++) { | |||
slice[i].paint(); | |||
} | |||
} | |||
void mousePressed() { | |||
save("pic.jpg"); | |||
n = int(n*step); | |||
if(n > maxSlices | n < 4){ | |||
step = 1/step; | |||
n = int(n*step*step); | |||
} | |||
for (int i = 0; i < n; i++) { | |||
slice[i] = new Slice(int(i*img.width/n),int(img.width/n),img); | |||
} | |||
} | |||
class Slice { | |||
int xini; | |||
int xSize; | |||
PImage img; | |||
PImage imgSlice; | |||
float vel; | |||
float xVel; | |||
float xPos; | |||
float sign; | |||
float seed; | |||
float iter = 0; | |||
float t = 100; | |||
Slice(int xiniTemp, int xSizeTemp, PImage imgTemp) { | |||
xini = xiniTemp; | |||
xSize = xSizeTemp; | |||
img = imgTemp; | |||
imgSlice = createImage(xSize,img.height,ARGB); | |||
vel = 0; | |||
xVel = 0; | |||
sign = random(-1,1); | |||
sign = sign/abs(sign); | |||
seed = random(0,100); | |||
xPos = 0.5*(width-img.width) + xini + xVel + sign*noise(seed)*img.width/3; | |||
int p = 0; | |||
for (int i = 0; i < img.height; i++) { | |||
for (int j = 0; j < img.width; j++) { | |||
if((j >= xini) & (j < xini + xSize)){ | |||
imgSlice.pixels[p] = img.pixels[j + i*img.width]; | |||
p +=1; | |||
} | |||
} | |||
} | |||
} | |||
// create sliced image | |||
void paint() { | |||
image(imgSlice,xPos,0); | |||
} | |||
} | |||
</source> | |||
=== homework 3 === | === homework 3 === | ||
<source lang = "java"> | |||
PImage[] images = new PImage[12]; | |||
PImage img; | |||
int w=100; | |||
int h; | |||
void setup() { | |||
size(400, 500); | |||
frameRate(10); | |||
background(255); | |||
for (int i = 0 ; i < images.length; i++) | |||
{ | |||
images [i] = loadImage("IMG_0" + (701 + i) + ".JPG"); | |||
img = loadImage("farbe_007.jpg"); | |||
images [i].mask(img); | |||
images [i].resize(100, 100); | |||
println(i); | |||
} | |||
} | |||
void draw() | |||
{ | |||
if(mousePressed){ | |||
int counter = frameCount % 19; | |||
image(images[counter], mouseX - 50, mouseY - 50); | |||
} | |||
} | |||
</source> |
Latest revision as of 11:13, 28 January 2016
Pascal Delor
homework 1
void setup()
{
size(400,400);
background(0,0,0);
frameRate(9);
println(frameCount);
println(frameRate);
}
void draw()
{
PImage image1 = loadImage("park_001.jpg");
PImage image2 = loadImage("park_002.jpg");
PImage image3 = loadImage("park_003.jpg");
PImage image4 = loadImage("park_004.jpg");
PImage image5 = loadImage("park_005.jpg");
PImage image6 = loadImage("park_006.jpg");
PImage image7 = loadImage("park_sieben.jpg");
PImage image8 = loadImage("park_acht.jpg");
PImage image9 = loadImage("park_009.jpg");
if (frameCount % 9 == 1) {
image(image1,0,0,400,400);
}
if (frameCount % 9 == 2) {
image(image2,0,0,400,400);
}
if (frameCount % 9 == 3) {
image(image3,0,0,400,400);
}
if (frameCount % 9 == 4) {
image(image4,0,0,400,400);
}
if (frameCount % 9 == 5) {
image(image5,0,0,400,400);
}
if (frameCount % 9 == 6) {
image(image6,0,0,400,400);
}
if (frameCount % 9 == 7) {
image(image7,0,0,400,400);
}
if (frameCount % 9 == 8) {
image(image8,0,0,400,400);
}
if (frameCount % 9 == 0) {
image(image9,0,0,400,400);
}
println(frameCount % 9);
println(frameCount);
println(frameRate);
}
grid of nine photos - addition to homework 1
image(image1,0,0,100,100);
image(image2,100,0,100,100);
image(image3,200,0,100,100);
image(image4,0,100,100,100);
image(image5,100,100,100,100);
image(image6,200,100,100,100);
image(image7,0,200,100,100);
image(image8,100,200,100,100);
image(image9,200,200,100,100);
homework 2
// number of max slices
int maxSlices = 256;
Slice[] slice = new Slice[maxSlices];
// number of start slices
int n = 16;
float step = 2;
PImage img;
void setup() {
smooth();
background(0);
img = loadImage("farbe_008.jpg");
img.resize(600,1000);
size(600,600);
for (int i = 0; i < n; i++) {
slice[i] = new Slice(int(i*img.width/n),int(img.width/n),img);
}
println(width);
println(height);
}
void draw() {
// background colour
fill(0);
// create rectangle with width and height of the image
rect(0,0,width,height);
for (int i = 0; i < n; i++) {
slice[i].paint();
}
}
void mousePressed() {
save("pic.jpg");
n = int(n*step);
if(n > maxSlices | n < 4){
step = 1/step;
n = int(n*step*step);
}
for (int i = 0; i < n; i++) {
slice[i] = new Slice(int(i*img.width/n),int(img.width/n),img);
}
}
class Slice {
int xini;
int xSize;
PImage img;
PImage imgSlice;
float vel;
float xVel;
float xPos;
float sign;
float seed;
float iter = 0;
float t = 100;
Slice(int xiniTemp, int xSizeTemp, PImage imgTemp) {
xini = xiniTemp;
xSize = xSizeTemp;
img = imgTemp;
imgSlice = createImage(xSize,img.height,ARGB);
vel = 0;
xVel = 0;
sign = random(-1,1);
sign = sign/abs(sign);
seed = random(0,100);
xPos = 0.5*(width-img.width) + xini + xVel + sign*noise(seed)*img.width/3;
int p = 0;
for (int i = 0; i < img.height; i++) {
for (int j = 0; j < img.width; j++) {
if((j >= xini) & (j < xini + xSize)){
imgSlice.pixels[p] = img.pixels[j + i*img.width];
p +=1;
}
}
}
}
// create sliced image
void paint() {
image(imgSlice,xPos,0);
}
}
homework 3
PImage[] images = new PImage[12];
PImage img;
int w=100;
int h;
void setup() {
size(400, 500);
frameRate(10);
background(255);
for (int i = 0 ; i < images.length; i++)
{
images [i] = loadImage("IMG_0" + (701 + i) + ".JPG");
img = loadImage("farbe_007.jpg");
images [i].mask(img);
images [i].resize(100, 100);
println(i);
}
}
void draw()
{
if(mousePressed){
int counter = frameCount % 19;
image(images[counter], mouseX - 50, mouseY - 50);
}
}