We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to make a program that decays and image. I could figure out how delete the pixels but what I have is fine. But for some reason I can't get the picture to load.
float speed = 100;
float direction = 200;
void update(){
}
float x = 0;
float y = 0;
float x2 = 0;
float y2 = 0;
int a = int(x);
int b = int(y);
int steps = 0;
void setup() {
PImage RD = loadImage("RD.jpg");
image(RD, 0, 0);
size(800, 600);
x = width / 2;
y = height / 2;
}
void draw() {
update();
takeStep();
}
void takeStep() {
smooth();
steps = steps + 1;
strokeWeight((200 / (abs(speed) + 50)) * 3);
x2 = x + ((speed / 5.0) * cos(radians(direction)));
y2 = y + ((speed / 5.0) * sin(radians(direction)));
line(x2, y2, x, y);
if (x2 < 0) {
float xDiff = x2 - x;
x2 = (x2 % width) + width;
x = x2 - xDiff;
}
else if (width < x2) {
float xDiff = x2 - x;
x2 = x2 % width;
x = x2 - xDiff;
}
if (y2 < 0) {
float yDiff = y2 - y;
y2 = (y2 % height) + height;
y = y2 - yDiff;
}
else if (height < y2) {
float yDiff = y2 - y;
y2 = y2 % height;
y = y2 - yDiff;
}
x = x2+1;
y = y2;
}
Answers
Hi! You should first set the size() and only then load the image :)