| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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/ |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.