# slope function graphing 3/8 [fltk]

Bjarne Stroustrup “Programming Principles and Practice Using C++”
Chapter 15 Shape Graphing Drill 4
Using GUI library called FLTK (Fast Light Tool Kit, “full tick”).

```Output:

```
```//  Philipp Siedler
//  Bjarne Stroustrup's PP
//  Chapter 15 Shape Graphing Drill 4

#define _USE_MATH_DEFINES
#include &quot;Simple_window.h&quot;
#include &quot;Graph.h&quot;
#include &lt;cmath&gt;

using namespace Graph_lib;

constexpr int xmax = 600;
constexpr int ymax = 600;

constexpr int x_orig = xmax / 2;
constexpr int y_orig = ymax / 2;
Point orig(x_orig, y_orig);

constexpr int r_min = -10;
constexpr int r_max = 10;

constexpr int n_points = 400;

constexpr int x_scale = 20;
constexpr int y_scale = 20;

double one(double x) { return 1; }
double slope(double x) { return x / 2; }

int main()
try
{
Point tl(100, 100);
Simple_window win(tl, xmax, ymax, &quot;Function graphs.&quot;);

Axis x(Axis::x, Point(orig.x - 200, orig.y), 400, 20, &quot;1 == 20&quot;);
x.set_color(Color::red);

Axis y(Axis::y, Point(orig.x, orig.y + 200), 400, 20, &quot;1 == 20&quot;);
y.set_color(Color::red);

Function f1(slope, r_min, r_max, orig, n_points, x_scale, y_scale);
f1.set_color(Color::black);

win.attach(f1);

win.attach(x);
win.attach(y);

win.wait_for_button();
}
catch (exception&amp; e) {
cout &lt;&lt; e.what() &lt;&lt; endl;
return 1;
}
catch (...) {
cout &lt;&lt; &quot;Exiting&quot; &lt;&lt; endl;
return 2;
}
```

This site uses Akismet to reduce spam. Learn how your comment data is processed.