NoMainWin Global sw, sh sw = 400: sh = 400 WindowWidth = sw+6 WindowHeight= sh+32 Open "[RC] Draw Cuboid" For graphics_nsb_nf As #g #g "Down; Fill black; TrapClose [xit]" #g "when leftButtonDown [xit]" Call drawCuboid 3,4,5 Wait [xit] Close #g End Sub drawCuboid width, height, depth wd = width*50 ht = height*50 dp = depth*20 sx = Int((sw-(wd+dp))/2) sy = Int((sh-(ht-dp))/2) #g "Color 0 128 255; BackColor 0 128 255" #g "Place ";sx;" ";sy #g "boxFilled ";sx+wd;" ";sy+ht x1 = sx+dp : y1 = sy-dp x2 = x1+wd-1 : y2 = y1+1 #g "Color 0 64 128" Call triFill sx,sy, x1,y1, x2,y2 Call triFill sx,sy, x2,y2, sx+wd, sy #g "Color 0 96 192" x3 = x2: y3 = y2+ht Call triFill x2,y2, x3,y3, sx+wd-1, sy+ht-1 Call triFill x2,y2, sx+wd-1, sy+ht-1, sx+wd-1, sy #g "Color white;BackColor black;Place 5 20" #g "\Size: ";width;", ";height;", ";depth End Sub Sub triFill x1,y1, x2,y2, x3,y3 If x2x3 Then slope1=(y3-y1)/(x3-x1) length=x2-x1 If length<>0 Then slope2=(y2-y1)/(x2-x1) For x = 0 To length #g "Line ";Int(x+x1);" ";Int(x*slope1+y1);" ";Int(x+x1);" ";Int(x*slope2+y1) Next End If y = length*slope1+y1 :length=x3-x2 If length<>0 Then slope3=(y3-y2)/(x3-x2) For x = 0 To length #g "Line ";Int(x+x2);" ";Int(x*slope1+y);" ";Int(x+x2);" ";Int(x*slope3+y2) Next End If End Sub