September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
21
Task/Draw-a-cuboid/Zkl/draw-a-cuboid.zkl
Normal file
21
Task/Draw-a-cuboid/Zkl/draw-a-cuboid.zkl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
var [const] M=50.0;
|
||||
fcn cuboid(w,h,z){
|
||||
w*=M; h*=M; z*=M; // relative to abs dimensions
|
||||
bitmap:=PPM(400,400);
|
||||
|
||||
clr:=0xff0000; // red facing rectangle
|
||||
bitmap.line(0,0, w,0, clr); bitmap.line(0,0, 0,h, clr);
|
||||
bitmap.line(0,h, w,h, clr); bitmap.line(w,0, w,h, clr);
|
||||
|
||||
r,a:=(w+z).toFloat().toPolar(0); // relative to the origin
|
||||
a,b:=r.toRectangular((30.0).toRad() + a).apply("toInt"); c:=a; d:=b+h;
|
||||
clr=0xff; // blue right side of cuboid
|
||||
bitmap.line(w,0, a,b, clr); bitmap.line(a,b, c,d, clr);
|
||||
bitmap.line(w,h, c,d, clr);
|
||||
|
||||
e:=c-w;
|
||||
clr=0xfff00; // green top of cuboid
|
||||
bitmap.line(0,h, e,d, clr); bitmap.line(c,d, e,d, clr);
|
||||
|
||||
bitmap.write(File("foo.ppm","wb"));
|
||||
}(2,3,4);
|
||||
Loading…
Add table
Add a link
Reference in a new issue