Știe cineva cum se deseneaza un hexagon in c++?
Răspunsuri la întrebare
#include <Simple_window.h>
struct Hexagon : Shape {
Hexagon(Point p, int d): d(d)
{ add(Point(p)); }
void draw_lines() const
{
fl_line(point(0).x-d,point(0).y, point(0).x-d/2,point(0).y-(d-d/20*3),
point(0).x+d/2,point(0).y-(d-d/20*3));
fl_line(point(0).x+d/2,point(0).y-(d-d/20*3), point(0).x+d,point(0).y,
point(0).x+d/2,point(0).y+(d-d/20*3));
fl_line(point(0).x+d/2,point(0).y+(d-d/20*3), point(0).x-d/2,point(0).y+(d-d/20*3),
point(0).x-d, point(0).y);
}
private:
int d;
};
int main() {
using namespace Graph_lib;
Simple_window win(Point(100,100), 600,400, "Hexagon");
Graph_lib::Rectangle r(Point (50,50), 400,200);
Point p(100,100);
int d = 50;
Hexagon h(p,d);
win.attach(h);
win.wait_for_button();
}