[Thread Prev][Thread Next][Index]

[ferret_users] set color from hexa code



Hi all,

Here is a script to convert hexa code color easy to get from applications
such as kcolorchooser or xv to ferret code color.
It uses gawk.

Here is a demo:

!==========================
! Define RRR, GGG, BBB variables
go set_rgb_from_hexa ABCDEF

! Set color 2 with a new color
ppl color 2,`RRR`,`GGG`,`BBB`

plot/color=2/thick=3/i=1:100 sin(i/5)
!==========================

Hope it will help
Patrick

#!/bin/ksh
#
# Usage: echo ABCDEF | convert_hexa

export LC_ALL=C
gawk --non-decimal-data '{
	a=sprintf("0x%s\n",substr($1,1,2))
	b=sprintf("0x%s\n",substr($1,3,2))
	c=sprintf("0x%s\n",substr($1,5,2))
	#printf("%X\n%X\n%X\n", a, b, c)
	printf("%3.1f\n%3.1f\n%3.1f\n",(100.*a)/255, (100.*b)/255, (100.*c)/255)
}'
\cancel mode verify

!**************************************************************
! Description: Define RRR, GGG, BBB variables from 
!              hexadecimal code on 6 digits
!              ex: FFFFF for 255,255,255 as RGB values
!
! Usage: go set_rgb_from_hexa XXXXXX
!
! Example:
!          yes? go set_rgb_from_hexa ABFFE5 
! 
! Note: - Applications such as xv or kcolorchooser will give you hexa color code. 
!       - The script convert_hexa must be accessible via your path
! 
!**************************************************************

let mycolor={spawn:"echo ($01) | convert_hexa"}

let RRR=`mycolor[i=1]`
let GGG=`mycolor[i=2]`
let BBB=`mycolor[i=3]`

!list RRR,GGG,BBB

!----------------------
cancel var mycolor

!----------------------
set mode/last verify
! Define RRR, GGG, BBB variables
go set_rgb_from_hexa ABCDEF 

! Set color 2 with a new color
ppl color 2,`RRR`,`GGG`,`BBB`

plot/color=2/thick=3/i=1:100 sin(i/5)

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement