More pixels found in bottom right section
in
Programming Questions
•
1 years ago
Hi! My question isn't very practical, but I noticed something when I was making a sketch. I was messing around, and decided to make a circle with expanding and decreasing size, so it would look like a spinning coin even though it was rendered in 2d. Once I had done that, I saved my sketch, and decided to try to draw lines from one part of the outside of the circle to another part of the outside. I gave the circle an outline with a stroke of 1, so only the computer could tell the difference between it and the background. Then, I used 2 for loops to run through each pixel and draw lines from pixels with an RGB value of 1, to other pixels with a value of 1. The sketch did this pretty well, but only in the bottom right quarter of the window. I didn't save the sketch, but i tried to recreate it. Unfortunately, my remade version isn't nearly as effective as the original from some reason.
int s=700;
int sm=15;
int outlineblack=-16711423;
int x=0;
int y=0;
int px, py;
void setup() {
size(700, 700);
smooth();
background(0);
}
void draw() {
if (s>700 || s<0) {
sm=-sm;
}
s+=sm;
fill(0, 30);
rect(0, 0, width, height);//background
stroke(1);
fill(0, 0, 255);
ellipse(width/2, height/2, s, 700);//coin
for (int ix=0;ix<width;ix=ix+15) {//the code is "ix=ix+10" instead of "ix++" because of performance issues
for (int iy=0;iy<height;iy=iy+15) {
if (get(ix, iy)==outlineblack) {//run through pixels and find which ones are the color of the coin's outline
px=x;
py=y;
x=ix;
y=iy;
}
if(px!=0 && py != 0 && x!=0 && y != 0){
stroke(255);
line(px, py, x, y);
}
}
}
}
So my question is why does it tend to draw lines more often in the bottom right quarter. Thanks
1