Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

rgb color selector error (/data = none)

 [1/5] from: rchristiansen:pop:isdfa:sei-it at: 1-Aug-2000 15:14


The following creates an RGB color selector. Slide the red, green, and blue sliders to increase the intensity of the color. Click on the frame below the sliders to return the new color value. One problem: If you do not move all three sliders initially before clicking on the frame, the script deals with a /data value of "none" and returns an error. Can someone help me on this one? How can I preset the /data value for a slider to zero so that it doesn't return "none" ? Thanks. -Ryan REBOL [] rgb-color-selector: layout [ backdrop 255.255.255 across red: slider 10x259 [red/color: 255.0.0 + (255 - red/data) show red print red/data] green: slider 10x259 [green/color: 0.255.0 + (255 - green/data) show green print green/data] blue: slider 10x259 [blue/color: 0.0.255 + (255 - blue/data) show blue print blue/data] return rgb: frame 50x50 [rgb/color: make tuple! rejoin [red/data {.} green/data {.} blue/data] show rgb] ] view rgb-color-selector

 [2/5] from: rchristiansen::pop::isdfa::sei-it::com at: 1-Aug-2000 17:02

%rgbcolors.r


Following is an RGB Color Selector I created using /View. It is my first /View creation and I'm pretty happy with it except for a couple of quirks (which are explained in the "Comments" portion of the header. I have it here if you would like to use it in determining colors for your /View scripts or HTML pages. If you can help me fix the couple of problems with the script, I would be grateful. Thanks. -Ryan REBOL [ Title: "RGB Color Selector" Date: 1-August-2000 Version: 0.9.0 File: %rgbcolors.r Author: "Ryan C. Christiansen" Email: [norsepower--uswest--net] Owner: "Ryan C. Christiansen" Rights: "Copyright (C) Ryan C. Christiansen 2000" Tabs: 4 Language: 'English Purpose: { Interpolates and displays RGB color values in tuple and in hexidecimal based on red, green, and blue sliders. } Comment: { The author is no mathematician and still has not figured out how to make the tuple range from 0.0.0 to 255.255.255 instead of 1.1.1 to 255.255.255. Also, the hex values returned have a similar problem, whereas #010101 is the darkest value instead of #000000. Also, you must slide all color bars from their original position before clicking on a color frame or else the script will return an error. } History: [ 0.9.0 [1-August-2000 "Created this example" "Ryan"] ] Example: {Slide the red, green, and blue sliders and then click on the frames to view the color created and the tuple and hex values for the color.} ] rgb-color-selector: layout/size [ backdrop 255.255.255 rgb-tuple: frame 105x50 [ rgb-tuple/color: make tuple! rejoin [red/data {.} green/data {.} blue/data] rgb-tuple/text: make string! rejoin [red/data {.} green/data {.} blue/data] show rgb-tuple ] rgb-hex: frame 105x50 [ rgb-hex/color: make tuple! rejoin [red/data {.} green/data {.} blue/data] red-hex: to-hex red/data green-hex: to-hex green/data blue-hex: to-hex blue/data rgb-hex/text: make string! rejoin [{#} red-hex/7 red-hex/8 green-hex/7 green-hex/8 blue-hex/7 blue-hex/8] show rgb-hex ] across red: slider 30x259 [ red/color: 255.0.0 + (255 - red/data) show red print red/data ] green: slider 30x259 [ green/color: 0.255.0 + (255 - green/data) show green ] blue: slider 30x259 [ blue/color: 0.0.255 + (255 - blue/data) show blue ] return button 105x25 "close" [unview/only rgb-color-selector] ] 144x450 view rgb-color-selector

 [3/5] from: g::santilli::tiscalinet::it at: 2-Aug-2000 19:09

Re: rgb color selector error (/data = none)


Hello [RChristiansen--pop--isdfa--sei-it--com]! On 01-Ago-00, you wrote: R> One problem: If you do not move all three sliders initially R> before clicking on the frame, the script deals with a /data R> value of "none" and returns an error. Can someone help me on R> this one? How can I preset the /data value for a slider to R> zero so that it doesn't return "none" ? Change: red: slider 10x259 [red/color: ... to: red: slider 10x259 0 [red/color: ... etc. That should do the job. My slider does not suffer from this problem, but the value is in /current, not /data (just in case you downloaded it and was wondering :-). Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [4/5] from: rchristiansen:pop:isdfa:sei-it at: 2-Aug-2000 13:29


Making this change only made the slider /data value change from 0 to 1 when I move the slider and the /data value doesn't return to 0.

 [5/5] from: g:santilli:tiscalinet:it at: 3-Aug-2000 19:06


Hello [RChristiansen--pop--isdfa--sei-it--com]! On 02-Ago-00, you wrote: R> Making this change only made the slider /data value change R> from 0 to 1 when I move the slider and the /data value doesn't R> return to 0. Yup, sorry, I was too tired yesterday. :-) If you don't want to check for none then you may want to try my slider style. Otherwise: rgb: frame 50x50 [ rgb/color: to-tuple reduce [ any [red/data 1] - 1 any [green/data 1] - 1 any [blue/data 1] - 1 ] show rgb ] assuming /data goes from 1 to 256 (so you can solve your problem with black being 1.1.1). Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/