Computer Graphics Program In Python And C++

Python

from graphics import *
win = GraphWin()

#point and line
pt = Point(100,50)
line = Line(pt, Point(50, 100))
line.draw(win)

#circle
pt = Point(150, 100)
c = Circle(pt, 25)
c.draw(win)

#square
rect = Rectangle(Point(10, 10), Point(50,50))
rect.draw(win)

#rectangle
rect = Rectangle(Point(130, 140), Point(190,180))
rect.draw(win)

#text
label = Text(Point(100, 7), 'Experiment 1')
label.draw(win)


win.getMouse()
win.close()

computer graphics

C++

#include​<graphics.h>
int ​​main​()
{
    ​int ​​gd​ = ​DETECT​, ​gm​;
    ​initgraph​(&​gd​, &​gm​, ​ ""​);
    ​line​(​150​, ​150​, ​500​, ​150​);
    ​circle​(​200​, ​200​, ​50​);
    ​rectangle​(​150​, ​250​, ​250​, ​150​);
    ​getch​();
    ​closegraph​();
    return 0;
}

computer graphics

LEAVE A REPLY