Code: Select all
#SingleInstance,Force
SetBatchLines,-1
CoordMode,Mouse,Client
global Main:={},Petals:=2,Sweep:=11
Gdip_StartUp()
DllCall("gdiplus\GdipCreatePen1", "UInt", "0xffA50D05", "float", 3, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", PetalPen)
DllCall("gdiplus\GdipCreatePen1", "UInt", "0xff000000", "float", 1, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", SweepPen)
DllCall("gdiplus\GdipCreateSolidFill", "UInt", "0xff087864", A_PtrSize ? "UPtr*" : "UInt*", BBrush)
CreateWindow()
SetTimer,Update,60
return
GuiClose:
ExitApp
Update:
MouseGetPos,nx,ny
if((nx!=ox||ny!=oy)&&WinActive("Ahk_Id " Main.HWND)){
ox:=nx,oy:=ny,SweepList:="",PetalList:="",Sweep:=nx//5+Ran(),Petals:=(ny>300)?(7):(ny>250)?(6):(ny>200)?(5):(ny>150)?(4):(ny>100)?(3):(2)
Loop,360
SweepList.=Calculate(A_Index*Sweep), PetalList.=Calculate(A_Index*3.14159/180)
Gdip_FillRectangle( Main.G,BBrush,-1,-1,380+2,280+2),Gdip_DrawLines(Main.G,SweepPen,SweepList)
Gdip_DrawLines(Main.G,PetalPen,PetalList),BitBlt(Main.hdc1,10,10,380,280,Main.hdc2,0,0)
}
return
Ran(){
Random,out,1,9
return out
}
Calculate(InputValue){
r:=135*Sin(Petals*InputValue)
x:=r*cos(InputValue)+190
y:=r*sin(InputValue)+140
return x "," y "|"
}
CreateWindow(){
Gui,1:+AlwaysOnTop +HwndWindowHwnd -DPIScale
Gui,1:Color,1C2125
Main.HWND:=WindowHwnd,Main.hdc1:=GetDC(Main.HWND),Main.hdc2:=CreateCompatibleDC()
Main.hbm:=CreateDIBSection(380,280),Main.obm:=SelectObject(Main.hdc2,Main.hbm)
Main.G:=Gdip_GraphicsFromHDC(Main.hdc2),Gdip_SetSmoothingMode(Main.G,4)
Gui,1:Show,h300 w400,Maurer_rose
}
;-------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------Gdip functions----------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------
Gdip_Startup(){
Ptr := A_PtrSize ? "UPtr" : "UInt"
if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
DllCall("LoadLibrary", "str", "gdiplus")
VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
return pToken
}
Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdiplus\GdipFillRectangle", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
}
Gdip_DrawLines(pGraphics, pPen, Points){
Ptr := A_PtrSize ? "UPtr" : "UInt"
StringSplit, Points, Points, |
VarSetCapacity(PointF, 8*Points0)
Loop, %Points0%
{
StringSplit, Coord, Points%A_Index%, `,
NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
}
return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", Points0)
}
BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster=""){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("gdi32\BitBlt", Ptr, dDC, "int", dx, "int", dy, "int", dw, "int", dh, Ptr, sDC, "int", sx, "int", sy, "uint", Raster ? Raster : 0x00CC0020)
}
GetDC(hwnd=0){
return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
}
CreateCompatibleDC(hdc=0){
return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
}
CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0){
Ptr := A_PtrSize ? "UPtr" : "UInt"
hdc2 := hdc ? hdc : GetDC()
VarSetCapacity(bi, 40, 0)
NumPut(w, bi, 4, "uint"), NumPut(h, bi, 8, "uint"), NumPut(40, bi, 0, "uint"), NumPut(1, bi, 12, "ushort"), NumPut(0, bi, 16, "uInt"), NumPut(bpp, bi, 14, "ushort")
hbm := DllCall("CreateDIBSection", Ptr, hdc2, Ptr, &bi, "uint", 0, A_PtrSize ? "UPtr*" : "uint*", ppvBits, Ptr, 0, "uint", 0, Ptr)
if !hdc
ReleaseDC(hdc2)
return hbm
}
SelectObject(hdc, hgdiobj){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
}
Gdip_GraphicsFromHDC(hdc){
DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
return pGraphics
}
Gdip_SetSmoothingMode(pGraphics, SmoothingMode){
return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
}
ReleaseDC(hdc, hwnd=0){
Ptr := A_PtrSize ? "UPtr" : "UInt"
return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
}