jscad / scad-api

DEPRECATED: OpenSCAD like API for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/V2/packages
MIT License
14 stars 8 forks source link

color transparency fails except for red? #3

Closed z3dev closed 7 years ago

z3dev commented 7 years ago

From @biscuitlad on February 24, 2016 15:4

box = color("palegreen", 0.8, box); //fails lid = color("red", 0.8, lid); //works

Red will be transparent, any other colour seems to fail. You can swap these and still one will fail and the other work.

Copied from original issue: Spiritdude/OpenJSCAD.org#132

z3dev commented 7 years ago

@biscuitlad you found a bug. I'm not sure what the issue is at this time, but was able to reproduce the issue.

It seems that other color names do not work, like "blue", "palegreen", etc. And as you mentioned, "red" works.

kaosat-dev commented 7 years ago

so does this mean the color lookup is failing ?

z3dev commented 7 years ago

I'm writing the test now. I'll let you know.

By the way, this requires a table of CSS color names and RGB values. Not sure if this table needs to be exposed, but I'm going to export css2rgb() and rgb2css() functions.

kaosat-dev commented 7 years ago

does this mean that this code is not for css color names ? https://github.com/jscad/scad-api/blob/master/src/color.js#L4

z3dev commented 7 years ago

The color list is CSS. But there's no way to convert directly from CSS name to RGB. The current function applies the color to an object. I want to separate our the css2rgb(), and change color() to call css2rgb() to get the color from the list, and then apply the color to the object. Slightly different.

kaosat-dev commented 7 years ago

ah yes, very nice, good idea, thanks for the clarification

z3dev commented 7 years ago

I believe this is now fixed with the merge of #5 A final review would be appreciated.

kaosat-dev commented 7 years ago

Looks good to me ! Closing