text modification [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Exercise 3
Using GUI library called FLTK (Fast Light Tool Kit, “full tick”).

Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Exercise 3

#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;

int main()
try
{
	Point tl(100, 100);
	Simple_window win(tl, 600, 400, "Canvas");

	Text f(Point(200, 250), "P");
	f.set_color(Color::red);
	f.set_font_size(150);

	Text l(Point(300, 250), "S");
	l.set_color(Color::blue);
	l.set_font_size(150);

	win.attach(f);
	win.attach(l);

	win.wait_for_button();
}
catch (exception& e) {
	cout << e.what() << endl;
	return 1;
}
catch (...) {
	cout << "Exiting" << endl;
	return 2;
}

simple rectangle and text [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Exercise 2
Using GUI library called FLTK (Fast Light Tool Kit, “full tick”).

Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Exercise 2

#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;

int main()
try
{
	Point tl(100, 100);
	Simple_window win(tl, 600, 400, "Canvas");

	Graph_lib::Rectangle rect(Point(250, 185), 100, 30);
	rect.set_color(Color::black);

	Text t(Point(275, 205), "Howdy!");
	t.set_color(Color::black);
	
	win.attach(rect);
	win.attach(t);

	win.wait_for_button();
}
catch (exception& e) {
	cout << e.what() << endl;
	return 1;
}
catch (...) {
	cout << "Exiting" << endl;
	return 2;
}

rectangle vs. polygon [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Exercise 1
Using GUI library called FLTK (Fast Light Tool Kit, “full tick”).

Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Exercise 1

#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;

int main()
try
{
	Point tl(100, 100);
	Simple_window win(tl, 600, 400, "Canvas");

	Graph_lib::Rectangle rect(Point(100,150),150,100);
	rect.set_color(Color::blue);

	Graph_lib::Polygon poly;
	poly.add(Point(350, 150));
	poly.add(Point(500, 150));
	poly.add(Point(500, 250));
	poly.add(Point(350, 250));
	poly.set_color(Color::red);

	win.attach(rect);
	win.attach(poly);	

	win.wait_for_button();
}
catch (exception& e) {
	cout << e.what() << endl;
	return 1;
}
catch (...) {
	cout << "Exiting" << endl;
	return 2;
}

using simple fltk graphics interface classes 1.1 [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Drill 3
Using a GUI library called FLTK (Fast Light Tool Kit, “full tick”).

Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Drill 3

#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;

int main()
try
{
	//12.7.2
	Point tl(100, 100);		//top left corner of our window
	Simple_window win(tl, 600, 400, "Canvas");
	//screen coordinate tl for top left corner
	//window size(600*400)
	//title: Canvas

	//12.7.3
	Axis xa(Axis::x, Point(40, 300), 100, 10, "x axis");
	//an Axis is a kind of Shape
	//Axis::x means horizontal
	//starting at (20,300)
	//280 pixels long
	//10 "notches"
	//label the axis "x axis"
	win.attach(xa);			//attach xa to the window, win
	win.set_label("Canvas #2");	//relabel the window

	Axis ya(Axis::y, Point(40, 300), 100, 10, "y axis");
	ya.set_color(Color::dark_green);	//choose a color
	ya.label.set_color(Color::dark_red);	//choose a color for the text
	win.attach(ya);
	win.set_label("Canvas #3");

	//12.7.4
	Function sine(sin, 0, 100, Point(20, 150), 100, 50, 50);
	//sine curve
	//plot sin() in the range [0:100] with (0,0) at (20,150)
	//using 1000 points; scale x values *50, scale y values *50
	win.attach(sine);
	win.set_label("Canvas #4");

	//12.7.5
	sine.set_color(Color::blue);

	Graph_lib::Polygon poly;
	poly.add(Point(300, 200));
	poly.add(Point(500, 100));
	poly.add(Point(400, 200));

	poly.set_color(Color::red);
	poly.set_style(Line_style::dot);
	win.attach(poly);
	win.set_label("Canvas #5");

	//12.7.6
	Graph_lib::Rectangle r(Point(200, 200), 100, 50);
	//top left corner, width, height
	win.attach(r);
	win.set_label("Canvas #6");

	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, 90));
	win.attach(poly_rect);

	//12.7.7
	r.set_fill_color(Color::yellow);	//color the inside of the rectangle
	poly.set_style(Line_style(Line_style::dash, 1));
	poly_rect.set_style(Line_style(Line_style::dash, 5));
	poly_rect.set_fill_color(Color::green);
	win.set_label("Canvas #7");

	//12.7.8
	Text t(Point(150, 100), "Hello, graphical world!");
	win.attach(t);
	win.set_label("Canvas #8");

	t.set_font(Font::times_bold);
	t.set_font_size(25);
	win.set_label("Canvas #9");

	//12.7.9
	Image ii(Point(100, 100), "Input/Original-JPG-Image.jpg");
	win.attach(ii);
	win.set_label("Canvas #10");

	ii.move(100, 300);
	win.set_label("Canvas #11");

	//12.7.10
	Circle c(Point(100, 200), 30);
	Graph_lib::Ellipse e(Point(100, 200), 50, 50);
	e.set_color(Color::dark_red);
	Mark m(Point(100, 200), '.');

	ostringstream oss;
	oss << "screen size: " << x_max() << "*" << y_max()
		<< "; window size: " << win.x_max() << "*" << win.y_max();
	Text sizes(Point(100, 20), oss.str());

	Image cal(Point(255, 255), "Input/image2.jpeg");
	cal.set_mask(Point(40, 40), 200, 150);

	win.attach(c);
	win.attach(m);
	win.attach(e);
	win.attach(sizes);
	win.attach(cal);
	win.set_label("Canvas #12");

	win.wait_for_button();		//display!
}
catch (exception& e) {
	cout << e.what() << endl;
	return 1;
}
catch (...) {
	cout << "Exiting" << endl;
	return 2;
}

using simple fltk graphics interface classes 1.0 [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Drill 2
Using a GUI library called FLTK (Fast Light Tool Kit, “full tick”).

12.7.2 Output:

12.7.3 Output:

12.7.4 Output:

12.7.5 Output:

12.7.6 Output:

12.7.7 Output:

12.7.8 Output:

12.7.9 Output:

12.7.10 Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Drill 2

#include "Simple_window.h"
#include "Graph.h"
using namespace Graph_lib;

int main()
try
{
	
	//12.7.2
	Point tl(100, 100);			//top left corner of our window
	Simple_window win(tl, 600, 400, "Canvas");
						//screen coordinate tl for top left corner
						//window size(600*400)
						//title: Canvas

	//12.7.3
	Axis xa(Axis::x, Point(20, 300), 280, 10, "x axis");
						//an Axis is a kind of Shape
						//Axis::x means horizontal
						//starting at (20,300)
						//280 pixels long
						//10 "notches"
						//label the axis "x axis"
	win.attach(xa);				//attach xa to the window, win
	win.set_label("Canvas #2");		//relabel the window

	Axis ya(Axis::y, Point(20, 300), 280, 10, "y axis");
	ya.set_color(Color::cyan);		//choose a color
	ya.label.set_color(Color::dark_red);	//choose a color for the text
	win.attach(ya);
	win.set_label("Canvas #3");

	//12.7.4
	Function sine(sin, 0, 100, Point(20, 150), 1000, 50, 50);
					//sine curve
					//plot sin() in the range [0:100] with (0,0) at (20,150)
					//using 1000 points; scale x values *50, scale y values *50
	win.attach(sine);
	win.set_label("Canvas #4");

	//12.7.5
	sine.set_color(Color::blue);

	Graph_lib::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::dash);
	win.attach(poly);
	win.set_label("Canvas #5");

	//12.7.6
	Graph_lib::Rectangle r(Point(200, 200), 100, 50);
					//top left corner, width, height
	win.attach(r);
	win.set_label("Canvas #6");

	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));
	win.attach(poly_rect);

	//12.7.7
	r.set_fill_color(Color::yellow);//color the inside of the rectangle
	poly.set_style(Line_style(Line_style::dash, 4));
	poly_rect.set_style(Line_style(Line_style::dash, 2));
	poly_rect.set_fill_color(Color::green);
	win.set_label("Canvas #7");

	//12.7.8
	Text t(Point(150, 150), "Hello, graphical world!");
	win.attach(t);
	win.set_label("Canvas #8");

	t.set_font(Font::times_bold);
	t.set_font_size(20);
	win.set_label("Canvas #9");

	//12.7.9
	Image ii(Point(100, 50), "Input/Original-JPG-Image.jpg");
	win.attach(ii);
	win.set_label("Canvas #10");

	ii.move(100, 200);
	win.set_label("Canvas #11");
	
	//12.7.10
	Circle c(Point(100, 200), 50);
	Graph_lib::Ellipse e(Point(100, 200), 75, 25);
	e.set_color(Color::dark_red);
	Mark m(Point(100, 200), 'x');

	ostringstream oss;
	oss << "screen size: " << x_max() << "*" << y_max()
		<< "; window size: " << win.x_max() << "*" << win.y_max();
	Text sizes(Point(100, 20), oss.str());

	Image cal(Point(255, 255), "Input/image2.jpeg");
	cal.set_mask(Point(40, 40), 200, 150);

	win.attach(c);
	win.attach(m);
	win.attach(e);
	win.attach(sizes);
	win.attach(cal);
	win.set_label("Canvas #12");

	win.wait_for_button();		//display!
}
catch (exception& e) {
	cout << e.what() << endl;
	return 1;
}
catch (...) {
	cout << "Exiting" << endl;
	return 2;
}

simple window [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 12 Drill 1
Using a GUI library called FLTK (Fast Light Tool Kit, “full tick”).

Output:

//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 12 Drill 1

#include "Graph.h"
#include "Simple_window.h"

int main()
{
	using namespace Graph_lib;

	Point tl(150, 150);
	Simple_window win(tl, 600, 400, "My window");
	win.wait_for_button();
}