i missed it for long time so i decided to make it.
        this script gives you the color from a hex triplet.
        to use it put the attached file in your .gimp/scripts directory.

        now my question is : why this improved version of the script don't
        work? 

-----------------------------------------------
define (chop chaine)
        (aset chaine 0 " ")
        (string-trim-left chaine))

(define (script-fu-hextripcol image layer hextrip)

; this is the added code
;
(let* ((couleur (let* ((couleur (string-trim hextrip)))
                        (if (not (= "#" (aref couleur 0)))
                                couleur
                                (chop couleur))
;

        (gimp-palette-set-foreground
                (list
                       (string->number (substring couleur 0 2) 16)
                        (string->number (substring couleur 2 4) 16)
                        (string->number (substring couleur 4 6) 16)))))


(script-fu-register
   "script-fu-hextripcol"
   "<Image>/web/s@m/heXTRIP"
   "hex triplet -> color"
   "s@m <[EMAIL PROTECTED]>"
   "copyright 2000, s@m"
   "5/2000"
   ""
   SF-IMAGE "The image" 0
   SF-DRAWABLE "The layer" 0
   SF-VALUE "heXTRIP?" "\"#F00000\""
-------------------------------------------------------------
                                                        
                                                                s@m
(define (script-fu-hextripcol image layer hextrip) 
        (gimp-palette-set-foreground 
                (list
                        (string->number (substring hextrip 1 3) 16)     
                        (string->number (substring hextrip 3 5) 16)     
                        (string->number (substring hextrip 5 7) 16))))


(script-fu-register
   "script-fu-hextripcol"
   "<Image>/web/s@m/heXTRIP"
   "hex triplet -> color"
   "s@m <[EMAIL PROTECTED]>"
   "copyright 2000, s@m"
   "5/2000"
   ""
   SF-IMAGE "The image" 0
   SF-DRAWABLE "The layer" 0
   SF-VALUE "heXTRIP?" "\"#F00000\""
 )

Reply via email to