Graphics 800,600Cls SetBlend SOLIDBLENDSetColor 200,200,200SetScale 2,2DrawRect 200,200,100,50SetColor 255,0,0SetHandle 0,0SetLineWidth 2Rot_Box(200,200,100,50,45)Rot_Box(200,200,100,50,90)Rot_Box(200,200,100,50,180)FlipWaitKey()Function Rot_Box(bx#,by#,w#,h#,deg#) 'bx,by == upper right corner 'draw a box rotated about its center Local s1#,s2# GetScale(s1,s2) SetScale 1,1 w=w/2*s1 h=h/2*s2 'calc center of rectangle x# = bx+w y# = by+h c# = Cos(deg) s# = Sin(deg) 'first corner h1# = -w*c+h*s v1# = -w*s-h*c 'second corner h2# = w*c+h*s v2# = w*s-h*c x1 = x + h1 y1 = y + v1 x2 = x + h2 y2 = y + v2 x3 = x - h2 y3 = y - v2 x4 = x - h1 y4 = y - v1 'draw the box DrawLine x1,y1,x2,y2 DrawLine x1,y1,x3,y3 DrawLine x2,y2,x4,y4 DrawLine x3,y3,x4,y4 'restore scale SetScale s1,s2End Function
SetGraphicsDriver(GLMax2DDriver())Graphics 800,600SetBlend alphablendClsSetColor 200,200,200DrawRect 200,200,200,100SetColor 255,0,0SetLineWidth 2rot_box 200,200,200,100,45,255,0,0rot_box 200,200,200,100,90,255,0,0FlipWaitKeyFunction rot_box(h,v,x,y,rr,r,g,b)Local s:TImage=CreateImage(800,600),l=GetLineWidth()Local i:TImage=CreateImage(x,y) GrabImage s,0,0 Cls SetColor r,g,b DrawRect 0,0,x,y SetColor 0,0,0 DrawRect l,l,x-l*2,y-l*2 MidHandleImage i GrabImage i,0,0 Cls SetColor 255,255,255 DrawImage s,0,0 SetRotation rr DrawImage i,h+x/2,v+y/2 SetRotation 0EndFunction