newLISP Fan Club

Forum => newLISP Graphics & Sound => Topic started by: didi on June 13, 2007, 11:21:35 AM

Title: Amateurs Corner - Gossip
Post by: didi on June 13, 2007, 11:21:35 AM
color-mixing ..


Quote; rgb-tst.lsp    13jun2007 dmemos  gui-server 0.4

( set 'cmax 1.0 )

( set 'cmin  0.0 )

( set 'cdelta ( div ( sub cmax cmin) 10 ))

( set 'drgb ( dup cdelta 3 ))



( set 'white ( dup cmax 3 ))

( set 'black ( dup cmin 3  ))

( set 'red ( list cmax cmin cmin ))

( set 'green ( list cmin cmax cmin ))

( set 'blue ( list cmin cmin cmax ))



( define ( limit rgbx)

  ( if ( <rgbx> rgbx cmax) cmax rgbx ))



( define ( rgb-add rgb1 rgb2 )

  ( map  limit ( map add rgb1 rgb2)))



( define ( rgb-sub rgb1 rgb2 )

  ( map  limit ( map sub rgb1 rgb2)))



( define ( rgb-complement rgb1 )

  ( rgb-sub white rgb1 ))



( set 'yellow ( rgb-add  red green ))

( set 'cyan ( rgb-add  green blue ))

( set 'magenta ( rgb-add  red blue ))



( define ( rgb-lighter rgb1 i )

  ( if ( = nil i )  (set 'i 1 ))

  ( rgb-add  rgb1  ( map mul drgb ( list i i i ))))



( define ( rgb-darker rgb1 i )

  ( if ( = nil i )  (set 'i 1 ))

  ( rgb-sub  rgb1  ( map mul drgb ( list i i i ))))





( set 'darkgrey ( rgb-lighter black 3 ))

( set 'lightgrey ( rgb-darker white ))


That's it ,  my first  code-snippet typed and tested complete in the gui-server-console 0.4 , and direct copied with  ctrl-C / ctrl-V to this forum.



Remarks :

- great feeling :-)



- the bracket-help doesn't work correctly



- while working in the gui console , the newlisp-console shows a lot of messages "dispatch events" "process events" ending with  "unknown source"



- on Windows2k the newlisp uses 1.5MB and Java 31MB - alot for java but no problem on my old machine ;-)



I've reached page 60  of Cormullions Introduction-to-newLISP so i don't know if the answer is there .

Question :

How the heck can i  get   rid of the brackets  of a list  ( 0.0 0.0 1.0 ), so that i can use  my rgb-value  in this way  

( gs-set-background 'frame yellow ) ?
Title:
Post by: didi on June 13, 2007, 11:27:52 AM
define ( limit rgbx)

  ( if ( <rgbx> rgbx cmax) cmax rgbx ))



hmm .. the limit function isn't copied correct .. obviously a problem of the forum



i typed

   ( if ( LESSSIGN rbgx cmin ) cmin ( GREATERSIGN rbgx cmax ) cmax rgbx ))
Title:
Post by: newdep on June 13, 2007, 11:38:32 AM
you could pick then from the list like



(dolist (l '( 0.5 0.6 0.7) (print l))



or you could do a (gs:set-background 'W (list 0) (list 1) (list 2))





Btw.. your example is added to the WIKI ;-)



nice  one ;-)
Title:
Post by: m i c h a e l on June 13, 2007, 01:57:20 PM
Hi didi!



Your code will be formatted correctly if you use the code tags around your code instead of the quote tags.



m i c h a e l
Title:
Post by: Lutz on June 13, 2007, 02:35:29 PM
QuoteHow the heck can i get rid of the brackets of a list ( 0.0 0.0 1.0 )


The next version of guiserver.lsp will allow a second syntax for gs:set-background and gs:set-color (the same)



(set 'myBlue '(0 0 1))

(gs:set-background myBlue)

; or with transparency value

(gs:set-background myBlue 0.5)


Lutz
Title:
Post by: didi on June 13, 2007, 09:51:21 PM
Thanks  newdep and  Michael , now i can see the  "Code"-Button above here ;-)



Thankyou Lutz , i think the second syntax will give us a  lispier way to set color.



With 'bracket-help doesn't work correct' i meant that while typing the paranthesis in the console , you get a hint to which other paranthesis it belongs - but that doesn't work correctly in the version 0.4 - the cursor jumps to short .