News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
feedback please
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: feedback please

Also having trouble with this one. The original had changed color index 15 in order to display a color chosen with fl_color_chooser(). That was annoying to me, and more annoying after I included the rgb and hex values in the tooltips of the colored boxes. I started using fl_rgb_color() to change the color of the color_chooser button so the initial 256 indexed colors wouldn't be bothered, and that seemed to work well until I noticed something weird.

There seems to be a bug in the way fl_rgb_color() is applying the colors in the red spectrum. Regardless of which color is chosen from the red side of the picker, the button always ends up being colored 128 0 0. The fl_color_cube button seems to receive the proper color from that chosen in the color picker, so I suspect either a bug in fl_rgb_color, or I'm not using it right.

EDIT: So far it looks like fl_rgb_color succeeds as long as the R value is less than 128. The G and B values can be whatever you want, but anything over 127 for R will cause the function to return 128 0 0. I'm surprised this hasn't come up mention of it from a web maybe something went weird in the murgaLua bindings?


-- make a 16x16 array of 20px boxes, 10px from the left edge
colors = {}
for i = 0,255 do
  local r,g,b=Fl:get_color(i,r,g,b) -- get RGB values of current color
  -- show color index, rgb, and html values in tooltip
  colors[i]:tooltip("Color index: "..i.."\nRGB: "..r.." "..g.." "..b.."\nHTML: "..string.format("#%.2X%.2X%.2X",r,g,b))
  left=left+bw -- next box will be placed 20px to the right
  if i == switch then -- if we have reached 16 boxes
    switch = switch+16  -- next switch position will be in 16 loops
    row = row+bw        -- move to next row
    left = 10           -- move back to first column

-- pick an indexed color and apply it to the button
  local newcolor=fltk.fl_show_colormap(colormap:color())
  colormap:label("FLTK Color "..newcolor)

  local color_ok,r,g,b -- initialize local variables
  color_ok,r,g,b=fltk.fl_color_chooser("starting color: "..r.." "..g.." "..b,r,g,b)
  if color_ok == 1 then -- color_ok represents the first value (exit status) returned by fl_color_chooser
    hexcolor=string.format("#%.2X%.2X%.2X",r,g,b) -- convert the rgb values to hex
    colorchooser:color(fltk.fl_rgb_color(r,g,b)) -- apply rgb color to button
    -- set the color_cube box color
    color_cube:color(fltk.fl_color_cube(r * (fltk.FL_NUM_RED - 1) / 255,g * (fltk.FL_NUM_GREEN - 1) / 255,b * (fltk.FL_NUM_BLUE - 1) / 255))
    color_cube:label("fl_color_cube: "..color_cube:color())
    colorchooser:label("Color "..colorchooser:color().."\nRGB "..r.." "..g.." "..b.."\nHTML "..hexcolor)



This post was last modified: 06-30-2009 03:09 AM by mikshaw.

06-30-2009 01:13 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
feedback please - mikshaw - 06-29-2009, 11:51 AM
RE: feedback please - mikshaw - 06-30-2009 01:13 AM
RE: feedback please - jpjacobs - 06-30-2009, 06:01 AM
RE: feedback please - mikshaw - 06-30-2009, 12:28 PM
RE: feedback please - jpjacobs - 07-01-2009, 04:21 AM
RE: feedback please - MrBill - 07-02-2009, 03:34 AM
RE: feedback please - mikshaw - 07-02-2009, 12:33 PM
RE: feedback please - jpjacobs - 11-29-2010, 10:08 PM
RE: feedback please - mikshaw - 11-30-2010, 01:55 PM
RE: feedback please - JohnMurga - 12-06-2010, 07:05 AM
RE: feedback please - mikshaw - 12-06-2010, 08:08 AM
RE: feedback please - jpjacobs - 12-06-2010, 10:05 AM
RE: feedback please - mikshaw - 12-07-2010, 01:37 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: