Draw a circle. Move a mark around on the circle (let it move a bit each time you
ID: 3849919 • Letter: D
Question
Draw a circle. Move a mark around on the circle (let it move a bit each time you hit the “Next” button).
PLEASE FOLLOW THIS CODE. The code shoud be like this but i could not frigure it out what wrong on this.
int main()
try
{
if(H112 != 201401L)error("Error: incorrect std_lib_facilities_4.h version ",
H112);
Point top_left {100,100};
Simple_window canvas {top_left, 1000, 600, "Canvas"};
Circle : Shape
{
Circle(Point p, int rr);
void draw_lines() const;
Point center() const ;
int radius() const { return r; }
void set_radius(int rr)
{
set_point(0,Point{center().x–rr,center().y–rr}); // maintain
r = rr;
}
private:
int r;
};
Circle c1 {Point{100,200},50};
Circle c2 {Point{150,200},100};
Circle c3 {Point{200,200},150};
Circle::Circle(Point p, int rr) // center and radius
:r{rr}
{
add(Point{p.x–r,p.y–r}); // store top left corner
}
Point Circle::center() const
{
return {point(0).x+r, point(0).y+r};
}
void Circle::draw_lines() const
{
if (color().visibility())
fl_arc(point(0).x,point(0).y,r+r,r+r,0,360);
}
return 0;
}
catch(exception& e) {
cerr << "exception: " << e.what() << ' ';
return 1;
}
catch (...) {
cerr << "Some exception ";
return 2;
}
Explanation / Answer
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
int main(){
int gd = DETECT,gm;
int x ,y ,radius=80;
initgraph(&gd, &gm, "C:\TC\BGI");
x = getmaxx()/2;
y = getmaxy()/2;
outtextxy(x-100, 50, "CIRCLE Using Graphics in C");
circle(x, y, radius);
getch();
closegraph();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.