I wrote a function for someone on one of the AHK forums to get coords based off known coords, length, and angle. I then decided to play into it a bit and draw some shapes. Here's a pretty good demo I made, although, please note that for polygons, it will never have more inner-vectors compared to the outer-vectors, because I wanted it that way
Instructions:
- Run script
- Open a new paint window, full-screen
- The rest should be self-explanatory (starting coords are always the center of the screen)
AHK-Draw Demo
; Make Gui's
; main gui
+1::
return
Circle: ; circle gui
return
CircleOK: ; draw circle
{
}
return
Spiral: ; spiral gui
return
SpiralOK: ; draw spiral
ind:=0
{
{
ind++
}
}
return
Polygon: ; polygon gui
return
PolygonOk: ; draw polygon
if(Ovec+Ivec > 360){
msgbox,,Error
,Can not have more than
360 vectors
. return
}
ind:=0
Lpc:= Ovec + Ivec
Ovec--
iys:=1
{
ind+=360/Lpc
Ivec-=iys ? 1 : 0
Ovec-=!iys ? 1 : 0
iys:=Ivec < 1 ? 0 : !iys
Sleep 15 ; seems to be inconsistent during multiple runs without delay }
return
+2:: ; stop drawing
+3:: ; kill
; ***function(s)***
GetPosFromAngle(ByRef x2,ByRef y2,x1,y1,len,ang){
ang := (ang-90) * 0.0174532925
x2
:= x1
+ len
* cos(ang
) y2
:= y1
+ len
* sin(ang
)}
The hotkeys are
Shift+1 to bring up the main gui,
Shift+2 to instantly interrupt the drawing,
Shift+3 to kill the script.
I encourage modification of this code, but request acknowledgement if my function is used elsewhere, thanks!