aUCBLogo Demos and Tests / colordb2html
to colordb2html
colors_by_name=getColorDatabase
c=[]
foreach colors_by_name
[ c=fPut
(Sentence
reHSB RGB (?).2 (?).3 (?).4
(?).1 (?).2 (?).3 (?).4)
c
]
colors_by_hue=mergeSort c
; colors_by_name
out="
<html>
<body>
<table>
<tbody>
<tr>
i=Int 0
foreach colors_by_name
[ if (mod i 4)==0
[ out=word out "
</tr>
<tr>
]
out=(word out "
<td width="100" bgcolor="
htmlcolor (?).2 (?).3 (?).4
""></td>
<td>
(?).1
"</td>
)
i+=1
]
out=word out "
</tr>
</tbody>
</table>
</body>
</html>
openWrite "colors_by_name.html
setWriter "colors_by_name.html
type out
setWriter []
close "colors_by_name.html
;now colors_by_hue
out="
<html>
<body>
<table>
<tbody>
<tr>
i=Int 0
foreach colors_by_hue
[ if (mod i 4)==0
[ out=word out "
</tr>
<tr>
]
out=(word out "
<td width="100" bgcolor="
htmlcolor (?).5 (?).6 (?).7
""></td>
<td>
(?).4
"</td>
)
i+=1
]
out=word out "
</tr>
</tbody>
</table>
</body>
</html>
openWrite "colors_by_hue.html
setWriter "colors_by_hue.html
type out
setWriter []
close "colors_by_hue.html
end
to htmlcolor r g b
output (word "#
htmlhex r*255
htmlhex g*255
htmlhex b*255)
end
to htmlhex n
ifelse n >= 16
[ output IntForm Int n 2 16
][ ifelse n>=1
[ output word "0 IntForm n 1 16
][ output "00
]
]
end