colors.constants: clean up naming
							parent
							
								
									ded68c67c0
								
							
						
					
					
						commit
						05fe9c7ead
					
				| 
						 | 
				
			
			@ -11,23 +11,23 @@ IN: colors.constants
 | 
			
		|||
    [ [ string>number 255 /f ] tri@ 1.0 <rgba> ] dip
 | 
			
		||||
    [ blank? ] trim-head { { CHAR: \s CHAR: - } } substitute swap ;
 | 
			
		||||
 | 
			
		||||
: parse-rgb.txt ( lines -- assoc )
 | 
			
		||||
: parse-colors ( lines -- assoc )
 | 
			
		||||
    [ "!" head? not ] filter
 | 
			
		||||
    [ 11 cut [ " \t" split harvest ] dip suffix ] map
 | 
			
		||||
    [ parse-color ] H{ } map>assoc ;
 | 
			
		||||
 | 
			
		||||
MEMO: rgb.txt ( -- assoc )
 | 
			
		||||
MEMO: colors ( -- assoc )
 | 
			
		||||
    "resource:basis/colors/constants/rgb.txt"
 | 
			
		||||
    "resource:basis/colors/constants/factor-colors.txt"
 | 
			
		||||
    [ utf8 file-lines parse-rgb.txt ] bi@ assoc-union ;
 | 
			
		||||
    [ utf8 file-lines parse-colors ] bi@ assoc-union ;
 | 
			
		||||
 | 
			
		||||
PRIVATE>
 | 
			
		||||
 | 
			
		||||
: named-colors ( -- keys ) rgb.txt keys ;
 | 
			
		||||
: named-colors ( -- keys ) colors keys ;
 | 
			
		||||
 | 
			
		||||
ERROR: no-such-color name ;
 | 
			
		||||
 | 
			
		||||
: named-color ( name -- color )
 | 
			
		||||
    dup rgb.txt at [ ] [ no-such-color ] ?if ;
 | 
			
		||||
    dup colors at [ ] [ no-such-color ] ?if ;
 | 
			
		||||
 | 
			
		||||
SYNTAX: COLOR: scan named-color parsed ;
 | 
			
		||||
		Loading…
	
		Reference in New Issue