Re: [LogoForum] motion question

This is a discussion on Re: [LogoForum] motion question within the logo forums in Programming Languages category; At 09:21 1.7.2003 +0200, Erich Neuwirth wrote: > peter,is there an easy way to pick up a color from a pixel? > i imported a picture > and want to change it, so i need to use the colors used in the picture. > i did not find a tool for clicking on a pixel > and thelling the pen: > use this color now. > > is there a way to do that? Erich, Yes, there are ways. The picture must be loaded to the background of a pane or page. Then you can use either the classical turtle ...

Go Back   Application Development Forum > Programming Languages > logo

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-01-2003, 04:34 AM
Peter Tomcsanyi
Guest
 
Default Re: [LogoForum] motion question

At 09:21 1.7.2003 +0200, Erich Neuwirth wrote:
> peter,is there an easy way to pick up a color from a pixel?
> i imported a picture
> and want to change it, so i need to use the colors used in the picture.
> i did not find a tool for clicking on a pixel
> and thelling the pen:
> use this color now.
>
> is there a way to do that?


Erich,

Yes, there are ways.

The picture must be loaded to the background of a pane or page.

Then you can use either the classical turtle procedure dotcolor, which
tells you the color under the turtle's pen. FOr this approach you need to
create a helper turtle, which may be hidden. And on each click you position
it to the place where the user clicked and ask for its dotcolor.

In Imagine there is also a "turtleless" way - each page or pane has a
procedure dotcolorAt :coord which reports the pixel color at a given
coordinate.

You can define this code as the page's onLeftDown event to see the effect:

pr dotcolorAt mousepos

(if you define it for the onClick event then mousepos will be the place
where the user released the mouse button, not where he/she pushed it)

-------

Note that the result of both dotcolor and dotcolorat can be an name of
Imagine color (like "white or "pink or "yellow4) or an [r g b] triple if
the color does not match any of the defined Imagine colors.
If you need to process the colors then you need all of them in the [r g b]
form.
There is a function torgb which input is an Imagine color (Imagine color
name or Comenius Logo color number or [r g b] triple) and the output is an
[r g b ] triple:

? pr torgb [10 10 10]
10 10 10
? pr torgb "yellow4
168 168 0
? pr torgb 10
0 255 0

--------

If your picture is a turtle's shape then you can either change your program
and use a pane instead of the turtle. Or if it is essential to have a
turtle which shape is your picture then you can have in the same time the
same picture loaded to a hidden pane and detect clicks to the turtle while
reading pixels from that hidden pane. Ask for details if you need to use
this approach.

Regards

Peter


To unsubscribe from this group, send an email to:
LogoForum-unsubscribe@yahoogroups.com
LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.