RGB viewer

By simplicity on Sep 14, 2007

A snippet that lets you scroll around to get the rgb value you need. There is a little bmp image preview that displays the color as you scroll. Once you have obtained your RGB value, click clipboard and it copies the rgb code.

To open: /rgbview

Updates:

Added an RGB info box with the HEX value and RGB value

dialog getrgbd {
  title "RGB viewer"
  size -1 -1 251 142
  option pixels
  scroll "", 1, 41 6 192 13, range 0 255 horizontal bottom
  text "Red:", 2, 1 4 33 16
  text "Blue:", 3, 0 23 33 16
  scroll "", 4, 41 24 192 13, range 0 255 horizontal bottom
  scroll "", 6, 41 42 192 13, range 0 255 horizontal bottom
  text "Green:", 7, 0 41 36 16
  button "Exit", 8, 97 113 45 25, ok cancel
  button "Clipboard", 9, 142 113 63 25
  icon 10, 1 67 91 77
  box "RGB info", 11, 97 52 144 55
  text "RGB ", 12, 103 68 50 16
  text "HEX", 13, 102 87 50 14
  text "", 14, 166 68 67 16
  text "", 15, 167 87 66 14
}

alias getrgb {
  window -phn +b @prev -1 -1 80 50
  drawfill -r @prev $rgb($1,$2,$3) 1 1 1
  drawsave @prev getrgb.bmp
  window -c @prev
}

on *:dialog:*:*:*:{ 
  if ($dname = getrgbd) { 
    if ($devent = scroll) { 
      var %z = $did($dname,1).sel $did($dname,6).sel $did($dname,4).sel
      getrgb %z
      did -g $dname 10 getrgb.bmp
      did -ra $dname 14 $+($did($dname,1).sel,$chr(44),$did($dname,6).sel,$chr(44),$did($dname,4).sel)
      did -ra $dname 15 $+($chr(35),$base($rgb($token(%z,1,32),$token(%z,2,32),$token(%z,3,32)),10,16))
    }
  }
  if ($devent = sclick) { 
    if ($did = 9) { clipboard $+($did($dname,1).sel,$chr(44),$did($dname,6).sel,$chr(44),$did($dname,4).sel) }
  }
}
alias rgbview { if (!$dialog(getrgbd)) { dialog -m getrgbd getrgbd }

Comments

Sign in to comment.
Vengeance   -  Dec 29, 2007

But i suggest you add a text box for hex as well

 Respond  
Vengeance   -  Dec 29, 2007

nice i made one of these as my first VB app

 Respond  
Gummo   -  Sep 27, 2007

Yeah, the box title needs to be fixed. :)

 Respond  
SilentExile   -  Sep 16, 2007

This is pretty cool. Although your box title interferes with the scroll bar. You might want to readjust that a bit. ;)

 Respond  
simplicity   -  Sep 15, 2007

Thank you Gummo. :)

 Respond  
Gummo   -  Sep 15, 2007

Nice.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.