Need help with drawing a shape
in
Programming Questions
•
1 year ago
Alright so I have to make a diamond and draw it one pixel at a time. Starting from the pixel in the middle of the screen and going out from there until the diamond's ends have reached the ends of the screen. And i have to draw all of this in the initial frame. Here's what I have so far :
- void setup() {
- size (500,500);
- int pointxposition = (width/2);
- int pointyposition = (height/2);
- int lastrightxposition = (width/2);
- int lastleftxposition = (width/2);
- int lastupyposition = (height/2);
- int lastdownyposition = (height/2);
- color (0,0,0);
- point (pointxposition,pointyposition);
- while (pointyposition > (lastupyposition-1)) {
- pointyposition--;
- point (pointxposition,pointyposition);
- }
- while (pointxposition < (lastrightxposition+1)) {
- pointxposition++;
- pointyposition++;
- point (pointxposition,pointyposition);
- }
- while (pointyposition < (lastdownyposition+1)) {
- pointxposition--;
- pointyposition++;
- point (pointxposition,pointyposition);
- }
- while (pointxposition > (lastleftxposition-1)) {
- pointxposition--;
- pointyposition--;
- point (pointxposition,pointyposition);
- }
- }
1