Beispiel #1
1
int main(){
	Simple_window win6(Point(100, 100), 600, 400, "Open polyline");

	Open_polyline opl;
	opl.add(Point(100, 100));
	opl.add(Point(150, 200));
	opl.add(Point(250, 250));
	opl.add(Point(300, 200));

	win6.attach(opl);
	win6.wait_for_button();		// 表示!
}
int main()
try {
    const int xmax = 1200;
    const int ymax = 600;

    const int x_orig = 100;
    const int y_orig = ymax - 100;
    const Point orig(x_orig,y_orig);

    const int r_min = 0;
    const int r_max = 20;

    const int x_scale = 20;
    const int y_scale = 200;

    Point tl(300,50);
    Simple_window win(tl,xmax,ymax,"");

    const int xlength = xmax - 200;
    const int ylength = ymax - 200;

    Axis x(Axis::x,Point(100,y_orig),xlength,xlength/x_scale,"1 == 20 pixels");
    x.set_color(Color::red);
    win.attach(x);
    Axis y(Axis::y,Point(x_orig,500),ylength,ylength/y_scale,"1 == 200 pixels");
    y.set_color(Color::red);
    win.attach(y);

    Open_polyline opl;
    opl.add(Point(orig.x,orig.y-y_scale));
    win.attach(opl);

    for (int i = 1; i<=50; ++i) {
        ostringstream ss;
        ss << "Leibniz series, element " << i;
        win.set_label(ss.str());
        int x = opl.point(i-1).x + x_scale;
        int y = orig.y - leibniz(i) * y_scale;
        opl.add(Point(x,y));
        win.wait_for_button();
    }
}
catch (exception& e) {
    cerr << "exception: " << e.what() << endl;
    keep_window_open();
}
catch (...) {
    cerr << "exception\n";
    keep_window_open();
}
void Lines_window::next() {
	int x = next_x.get_int();
	int y = next_y.get_int();
	lines.add(Point{x,y});
	ostringstream os;
	os << '(' << x << ',' << y << ')';
	xy_out.put(os.str());
	redraw();
}
Beispiel #4
0
		void draw_lines() const{
			T dist = (m_r2 - m_r1) / m_count;
			T r = m_r1;
			Open_polyline op;
			for(int i = 0; i < m_count; ++i) {
				op.add(Point(m_orig.x + int(r * m_xscale), m_orig.y - int(m_f(r) * m_yscale)));
				r += dist;
			}
			op.draw_lines();
		}
Beispiel #5
0
void Lines_window::next()
{
  int x = next_x.get_int();
  int y = next_y.get_int();
  lines.add(Point{x, y});
  // update current position readout:
  ostringstream ss;
  ss << '(' << x << ',' << y << ')';
  xy_out.put(ss.str());

  redraw();
}
Beispiel #6
0
void Lines_window::next()
{
    int x = next_x.get_int();
    int y = next_y.get_int();

    lines.add(Point(x, y));

    stringstream ss;
    ss << '(' << x << ',' << y << ')';
    xy_out.put(ss.str());

    redraw();
}