Computer graphics program to draw an ellipse that appears at random positions on the screen

0
82

Computer graphics program in Python and C++

Python

from graphics import *
win = GraphWin("Experiment 3.3", 600, 600)
import random
 
#text
label = Text(Point(290, 24), 'Draw a Ellipse')
label.setSize(24)
label.draw(win)
# oval = Oval(Point(100,50), Point(500,250))
# oval.draw(win)
#Oval
while True:
   x = random.randint(-100, 100)
   y = random.randint(-100, 100)
   # oval1 = oval.clone()
   # oval1.move(x, 0)
   # oval.undraw()
   # oval1.undraw()
   # oval1.draw(win)
   # oval2 = oval.clone()
   # oval2.move(0, x)
   # oval2.draw(win)
   oval = Oval(Point(100+x,50+y), Point(500+x,250+y))
   oval.draw(win)
   time.sleep(1)
   oval.undraw()
win.getMouse()
win.close()
computer graphics

C++

#include<conio.h>
#include<graphics.h>
 
int main(){
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "");
    setlinestyle(0, 0 ,3);
    while(!kbhit()){
        delay(200);
        cleardevice();
        int x = rand() % getwindowwidth();
        int y = rand() % getwindowheight();
        ellipse(x, y, 0, 360, 150, 100);
        // setfillstyle(SOLID_FILL, YELLOW); 
        // floodfill(x, y, YELLOW); 
    }
 
    getch();
    closegraph(); 
    return 0;
}

computer graphics

LEAVE A REPLY