Draw an ellipse with pixels only (i.e not with the ellipse() function)
/*
E.Dare August 2011
Draw an ellipse with pixels only
*/
int x = 150;
int y =150;
float radius =80;
void setup() {
size(300, 300);
}
void draw() {
background(255);
color col2 = color(0, 0, 255);
//if i and j are within half radius width of x and y (centre) fill with blue
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if ((dist(i, j, x, y)<=radius/2)) {
set(i, j, col2);
}
}
}
}
No comments:
Post a Comment