`
kennethf6986
  • 浏览: 67289 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

chapter12 例程

阅读更多

#include "Simple_window.h"
#include "Graph.h"
int main()
{

	using namespace Graph_lib;

	Simple_window win(Point(100,100), 600, 400, "axis");

	Axis xa(Axis::x, Point(20,300), 280, 10, "x axis");  // x轴
	Axis ya(Axis::y, Point(20,300), 280, 10, "y axis");  //y轴
	ya.set_color(Color::cyan);
	ya.label.set_color(Color::dark_red);

	//函数图
	Function sine(sin, 0, 100, Point(20, 150), 1000, 50, 50 );
	sine.set_color(Color::blue);
	
	//Polygon
	Polygon poly;
	poly.add(Point(300,200));
	poly.add(Point(350,100));
	poly.add(Point(400,200));
	poly.set_color(Color::red);
	poly.set_style(Line_style(Line_style::dash,4));

	win.attach(poly);

	//Rectangle
	Rectangle r(Point(200,200), 100,50);
	r.set_fill_color(Color::yellow);
	win.attach(r);

	//Closed_polyline
	Closed_polyline poly_rect;
	poly_rect.add(Point(100,50));
	poly_rect.add(Point(200,50));
	poly_rect.add(Point(200,100));
	poly_rect.add(Point(100,100));
	poly_rect.add(Point(50,75));
	poly_rect.set_style(Line_style(Line_style::dash,2));
	poly_rect.set_fill_color(Color::green);
	win.attach(poly_rect);

	//text
	Text t(Point(150,150), "Hello, graphical world!");
	t.set_font(Font::times_bold);
	t.set_font_size(20);
	win.attach(t);

	//image
	Image ii(Point(100,50), "../Winter.jpg");
	ii.move(100,200);

	win.attach(ii);

	win.attach(xa);
	win.attach(ya);
	win.attach(sine);
	
	win.set_label("Canvas #2");
	win.wait_for_button();

	return 0;

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics