21 lines
707 B
Text
21 lines
707 B
Text
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);
|