meta data for this page
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
en:design_guide_color [2020/11/28 02:59] JSCAD Editor created |
en:design_guide_color [2021/05/29 08:48] (current) JSCAD Editor |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Color ==== | ==== Color ==== | ||
| - | Shapes can exhibit different colors. And just like the other transformations, | + | Shapes can exhibit different colors. And just like the other transformations, |
| - | //NOTE: 2D shapes cannot exhibit colors today. This is a known issue.// | + | Colors are not only important for visual rendering but also controlling the selection of filaments during 3D printing. Therefore, colors should be applied as the last step in designs to insure proper printing. |
| <code javascript> | <code javascript> | ||
| - | let a = color(" | + | const myshape |
| - | let b = color([1, 0.5, 0.3], | + | const myshape |
| - | let c = color([1, 0.5, 0.3, 0.6],sphere(10),cube(20)) | + | const myshape |
| - | </code> | + | |
| - | + | ||
| - | See the [[https:// | + | |
| - | + | ||
| - | The CSG library functions can also be used. //NOTE: Deprecated in the V2 API// | + | |
| - | + | ||
| - | <code javascript> | + | |
| - | let a = object.setColor(css2rgb(' | + | |
| - | let b = sphere().setColor(1, | + | |
| - | let c = sphere().setColor([1, 0.5, 0.3, 0.7]) | + | |
| </ | </ | ||
| Line 25: | Line 15: | ||
| === Color Space Conversion === | === Color Space Conversion === | ||
| - | Following | + | There are several |
| <code javascript> | <code javascript> | ||
| - | let rgb = css2rgb('navy') | + | const wildcylinder |
| - | let rgb = html2rgb('# | + | |
| - | let rgb = hsl2rgb(h,s,l) // or hsl2rgb([h,s,l]) | + | const bluesphere |
| - | let rgb = hsv2rgb(h,s,v) // or hsv2rgb([h, | + | |
| - | let hsv = rgb2hsv(r,g,b) // or rgb2hsv([r,g,b]) | + | const mysphere |
| - | let hsl = rgb2hsl(r,g,b) // or rgb2hsl([r,g,b]) | + | |
| - | let html = rgb2html(r,g,b) | + | const mysphere |
| </ | </ | ||
| whereas | whereas | ||
| - | * r,g,b (red, green, blue) | + | * r,g,b (red, green, blue) of [[https:// |
| - | * h,s,l (hue, saturation, lightness) | + | * h,s,l (hue, saturation, lightness) |
| - | * h,s,v (hue, saturation, value) | + | * h,s,v (hue, saturation, value) |
| + | |||
| + | See the [[https:// | ||