AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bringing the Cursor to life.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
williamsharkey



Joined: 06 Oct 2007
Posts: 52
Location: Philadelphia

PostPosted: Thu Jan 24, 2008 9:23 pm    Post subject: Bringing the Cursor to life. Reply with quote

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
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Thu Jan 24, 2008 9:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
williamsharkey



Joined: 06 Oct 2007
Posts: 52
Location: Philadelphia

PostPosted: Thu Jan 24, 2008 11:30 pm    Post subject: Reply with quote

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. Wink


Not only is Laszlo's code easier to read, less error prone, and shorter, but..

-Computers are really fast at SHIFTing and ANDing Exclamation

Great tip Laszlo.
Back to top
View user's profile Send private message Visit poster's website
williamsharkey



Joined: 06 Oct 2007
Posts: 52
Location: Philadelphia

PostPosted: Fri Jan 25, 2008 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group