That is amazing Helgef o_o especially the second image.
I tried to make it one of those fancy "dots further away from mouse get smaller" things but kinda failed. can only figure out how to get the one under the cursor (it is flickery, unfortunately. not sure how to make ahk work with 400+ things nicely):
as for optimizing it, see the comments with "!!!"
Code: Select all
; https://autohotkey.com/boards/viewtopic.php?p=126261#p126261
; Usage Example
#singleInstance, force
#persistent
; !!! improves speed A LOT
setBatchLines, -1
pToken:=Gdip_Startup()
sFile:=A_ScriptDir "\owl - small.jpg" ; tidbits avatar
I:=particliseImage(sFile,20,3,7)
showParticleIm(I)
settimer, effects, 200
return
effects:
coordMode, mouse, client
mouseGetPos, mx, my
for k, v in psys.particles[1]
if ((v.x1-(size//2)<=mx && v.x1+(size//2)>=mx) && (v.y1-(size//2)<=my && v.y1+(size//2)>=my))
{
dot:=k
break
}
if (dot=dotp)
return
I:=particliseImage(sFile,20,3,7)
I.psys.particles[1, dot].radius*=3
showParticleIm(I)
dotp:=dot
return
guiClose:
guiEscape:
esc::
Gdip_Shutdown(pToken)
exitapp
return
particliseImage(file,size:="",space:=2,res:=4)
{
if !size
size:=space*res*2
psys:=new particles(30)
pBitmap:=Gdip_CreateBitmapFromFile(file)
if !pBitmap
{
MsgBox, Fail
return -1
}
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
Gdip_GetDimensions(pBitmap,w,h)
gui, new, +hwndguiId +ToolWindow
gui, % guiId ":margin", 0,0
gui, % guiId ":add", picture, % "x0 y0 " "w" w*space " h" h*space " 0xE hwndhPic"
;gui, % guiId ":add", picture, , % "HBITMAP:" hBitmap ; debug
psys.setCanvas(0, 0, w*space, h*space, 1, hPic)
ctr:=0
e:=psys.addEmitter()
; !!! you don't need to define all the blanks
; e.speed:=[]
; e.life:=[]
; e.alpha:=[]
e.color:=[]
e.circleSize:=[size] ; !!! since these never change, they only need to be set once
; e.lineWidth:=[size] ; !!! since these never change, they only need to be set once
e.coords:=[]
e.alpha:=[255]
; e.pattern:=[]
; e.gravity:=[]
; e.type:="sparks"
Loop, % w//res
{
i:=A_Index
x:=(i-1)*res
Loop, % h//res
{
j:=A_Index
y:=(j-1)*res
argb := Gdip_GetPixel(pBitmap, x, y)
rgb:=argb & 0x00FFFFFF
e.color.Push(format("{:06x}", rgb))
; e.alpha.Push(argb>>24) ; !!! these are not needed for /every/ particle. Save some memory.
; e.life.Push(1) ; !!! these are not needed for /every/ particle. Save some memory.
; e.speed.Push(0) ; !!! these are not needed for /every/ particle. Save some memory.
; e.circleSize.Push(size) ; !!! these are not needed for /every/ particle. Save some memory.
; e.lineWidth.Push(size) ; !!! these are not needed for /every/ particle. Save some memory.
; e.pattern.Push("r") ; !!! these are not needed for /every/ particle. Save some memory.
; e.gravity.Push(0) ; !!! these are not needed for /every/ particle. Save some memory.
e.coords.Push({x:x*space,y:y*space})
}
}
; !!! I put this stuff in here so I could change the size of stuff after we add them but before we draw them
; psys.particles:=[]
e:=psys.emitters[1]
for k, tuple in e.coords
psys.addParticle(tuple.x,tuple.y)
Gdip_DisposeImage(pBitmap) ; !!! in this code it gets redrawn. get rid of the old
Gdip_DisposeImage(hBitmap) ; !!! in this code it gets redrawn. get rid of the old
return {psys:psys, w:w//res, h:h//res, guiId:guiId, hPic:hPic, res:res, space:space, size:size}
}
showParticleIm(pIm)
{
if !WinExist("ahk_id " pIm.guiId)
Gui, % pIm.guiId ":show"
pIm.psys.clear()
pIm.psys.draw(pIm.hPic)
; !!! since you're not using .step(), particles never age. this isn't needed
; pIm.psys.Particles[1].life:=1
; for k, particle in pIm.psys.Particles[1]
; particle.life:=1
return
}
SpecialG wrote:Great stuff lol - If I have some time I'll fiddle around with it
It would be nice to make the initial script work on the full set of screens. (aka multi monitor support)
I tried a few things but to no avail for the time being..
you can using
sysget to get the entire "virtual screen" (options 78, 79). but I advise against that. Do a smart way: get which monitor your mouse is on. use sysget to get the x/y/w/h of that monitor. if the monitor your mouse is on ISN'T the same as the last check, draw the canvas on the new monitor.
having 1 massive canvas will crank up the CPU usage and how much RAM is needed to store all the stuff.
I did this in one of my non-gui versions. I don't feel like adding it to the toy as it's just meant for experimenting. the real thing is the class, program the stuff yourself after you figured out the options you like. I might consider adding it later, but for now that's beyond the gui-toy's purpose.
This should help you get started:
Code: Select all
mouseGetPos, xxx, yyy
monCoords:=monitorAtCoords(xxx,yyy)
monitorAtCoords(xxx,yyy)
{
sysGet, count, MonitorCount
loop, %count%
{
sysGet, mCoords, monitor, %A_Index%
if ((xxx>=mCoordsLeft && xxx<=mCoordsRight) && (yyy>=mCoordsTop && yyy<=mCoordsBottom))
return {"mon":A_Index, "x1":mCoordsLeft, "y1":mCoordsTop
, "x2":mCoordsRight, "y2":mCoordsBottom
, "w": mCoordsRight-mCoordsLeft, "h": mCoordsBottom-mCoordsTop}
}
}
rawr. fear me.
*poke*
Is it December 21, 2012 yet?