Functional Shapes
From a function y=f(x) a polygon/path can be generated with this a shape.
Download: function-shape.layout
1 #!/usr/bin/layout
2 #name=function shapes
3 #help=create a polygon on the active layer with a entered function
4
5 double func(double d){
6 return d*d/100;
7 }
8
9
10 int main(){
11 double d2;
12 layout->drawing->clearPoints();
13 // add a x^2 polygon
14 layout->drawing->activeLayer=4;
15 for (d2=-100;d2<101;d2+=10){
16 layout->drawing->p(d2,func(d2));
17 }
18 layout->drawing->polygon();
19 // add a cos path
20 layout->drawing->activeLayer=2;
21 for (d2=-130;d2<=130;d2+=5){
22 layout->drawing->p(d2,-30*math::cos((d2-20)/50*math::pi));
23 }
24 layout->drawing->path();
25 layout->drawing->scaleFull();
26 }