AutoHotkey Community

It is currently May 27th, 2012, 10:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 24th, 2008, 10:23 pm 
Offline

Joined: October 6th, 2007, 2:28 am
Posts: 49
Location: Philadelphia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 10:42 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
You could slightly simplify getting the R,G,B values in decimal form:
Code:
B:= color >> 16
G:= color >> 8 & 255
R:= color & 255


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2008, 12:30 am 
Offline

Joined: October 6th, 2007, 2:28 am
Posts: 49
Location: Philadelphia
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 :!:

Great tip Laszlo.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2008, 2:01 am 
Offline

Joined: October 6th, 2007, 2:28 am
Posts: 49
Location: Philadelphia
Some Output:
1
Image
2
Image
3
Image
4
Image
5
Image

Method: Move cursor to center of image. Let it draw. Sometimes I change line thickness while it is drawing.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group