 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
williamsharkey
Joined: 06 Oct 2007 Posts: 52 Location: Philadelphia
|
Posted: Thu Jan 24, 2008 9:23 pm Post subject: Bringing the Cursor to life. |
|
|
I have stumbled across an interesting(to me) class of programs.
General features:
-Reading a color near the mouse
-Acting upon that color by moving the mouse
Generally, I have the mouse move slightly, in a way that I can still control it to a large degree. When not controlling the mouse, you experience it drifting away.
I've had so much fun with these simple programs, I wanted to share it with you.
When you open up MSPaint, or whichever art program you use, you will find that you can create striking interactions between the pen and canvas.
Implementation:
- A loop will be necessary to continually get the color, then move the mouse.
- Here is a tip on getting the color:
| Code: | MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
; Format of color: 0xAAFF55
;Extract the colors for R G and B
B:= "0x" . SubStr(color, 3 ,2)
G:= "0x" . SubStr(color, 5 ,2)
R:= "0x" . SubStr(color, 7 ,2)
;By adding zero, the hex numbers will be converted to decimal notation
B+=0
G+=0
R+=0
|
- Thats all the tips you get. Try it! (If you get frustrated, I can help you and send an example. )
I'm curious how your programs will be different than mine. |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Thu Jan 24, 2008 9:42 pm Post subject: |
|
|
You could slightly simplify getting the R,G,B values in decimal form: | Code: | B:= color >> 16
G:= color >> 8 & 255
R:= color & 255 |
|
|
| Back to top |
|
 |
williamsharkey
Joined: 06 Oct 2007 Posts: 52 Location: Philadelphia
|
Posted: Thu Jan 24, 2008 11:30 pm Post subject: |
|
|
I will use your method.
Explanation:
-Each Character is made up of 4 bits.
-The >> means "shift the bits to the right, and pad in any gaps with zeros."
:: Therefore, >> 8 means shift 2 character to the right.
- & is being used here as a mask. Wherever there is a 0, all bits will be off. Wherever a 1, bits preserved
255 is 0000,0000,0000,0000,1111,1111 in Binary
So the only survivors will be the last two characters. They can stay on the island.
Not only is Laszlo's code easier to read, less error prone, and shorter, but..
-Computers are really fast at SHIFTing and ANDing
Great tip Laszlo. |
|
| Back to top |
|
 |
williamsharkey
Joined: 06 Oct 2007 Posts: 52 Location: Philadelphia
|
Posted: Fri Jan 25, 2008 1:01 am Post subject: |
|
|
Some Output:
1
2
3
4
5
Method: Move cursor to center of image. Let it draw. Sometimes I change line thickness while it is drawing. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|