#include "library.h" // This is the important function to print, with x // ranging from 0 to 600 double formula(const double x) { return 150 + 300*pow(sin(x/24),2)+25*cos(x); } // but I also want a close connection to this function's // value too, so I'll use it to colour the other function's // plot. double minor_function(const double x) { return sin(x/180); } void internal_plot(const double x, const double last) { if (x > last) return; const double y = formula(x); const double m = minor_function(x); // use m to choose colour set_pen_color_hls(m, 0.5, 1.0); draw_to(x, 600-y); internal_plot(x+0.1, last); } void plot(const double x, const double last) { if (x > last) return; const double y = formula(x); move_to(x, 600-y); internal_plot(x+0.1, last); } void main() { make_window(600, 600); set_pen_width(2); set_pen_color(color::red); plot(0, 600); }