##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: August 2016 # Modified: 2016-10-03/23:10-0400 ##+ # # plot-function, trigonometric plotting, function from command line # $define points 300 $define xoff 154 $define base 64 $define yscale 60 $define xscale 100 invocable "asin", "acos", "atan" # plot the given function, default to sine procedure main(args) func := map(args[1]) | "asin" if not func == ("asin" | "acos" | "atan") then func := "asin" # range of pixels for 300 points, y scaled at +/- 60, 4 pixel margins &window := open("Plotting", "g", "size=308,128", "canvas=hidden") # tan may cause runtime errors if func == "atan" then &error := 6 color := "vivid orange" Fg(color) write(&window, "\n " || func) Fg("gray") DrawLine(2, base, 306, base) DrawLine(xoff, 2, xoff, 126) DrawString(8, 10, "1.5+", 8, 69, "0", 2, 126, "-1.5-") DrawString(xscale / 2 + 2, 76, "-1.0") DrawString(points - (xscale / 2) - 2, 76, "1.0") Fg(color) step := 2.0 / points every x := -1.0 to 1.0 by step do { DrawPoint(xoff + (x * xscale), base - (yscale * func(x))) } WSync() WriteImage("../images/plot-" || func || ".png") close(&window) end