New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
color() does not "inherit" as expected #4057
Comments
the sequence is other way around the outer will supersede the inner - like an outer transformation is added to the inner
|
@UBaer21 yes, as I mentioned, that trivial example didn't have the nesting that my real example does, otherwise I could have done what you proposed there. @nophead I guess I was expecting It was just (to me) an unexpected effect, when the inner color function is just ignored. But thank you both for your explanations :) |
Perhaps the documentation could be updated to note that color statements can not be nested ? |
I just depends on your mental model. The inner color does bind tightly to its children and colours them but the outer color does the same and overrides it. Yes colours could combine like paint but then I don't think that would be very useful. When you have a single solid object, like a union, it doesn't make a lot of sense for it to have more than one colour unless you have a colour 3D printer, but even then it can be ambiguous when faces are shared. I apply a single colour to my objects that become STL files and are 3D printed. If they touch other 3D printed parts I use another colour so I can see the boundaries. Other items like fasteners are coloured realistically and are just placed into or around the printed parts, so they never end up under the same color statement. The documentation is a wiki, so feel free to add to it. |
what you try with nesting is apply a color twice
So think of it as you painted the cube red and then you paint over it in blue .. mixing colors would require to think of additive or subtractive and as white already is 1.1.1 you can't add anything however color are not part of the geometry and only visible in preview and png exports at the moment. Also colors are always altered to give a 3D illusion / shading - so an object always has multiple colors. If you want mixing you probably could make this happens with special variables in multiple modules.
|
Thanks both - that helps a lot - you're right: it just depends on your mental model. I'll suggest a small change to the docs so future me doesn't trip over this again. Thanks again |
color addition is possible like this to ensure you don't end up adding more than 1
|
added |
Not directly this topic: note that some color behaviors are somewhat deliberately not documented, because they are likely to change if we ever get multi-material multi-color support. Currently colors are applied only to faces and it is possible for an object to have different colors on different faces. With multi-color support color would have to be volumetric, and apply to the entire object. Different faces could not be different colors. |
I want to set an overall colour for a composite object, but colour sub-parts of it differently.
A simple example (the real one has modules to draw the sub-components):
I would expect the cube to be white, and the cylinder to be green, but it comes out all white, i.e. it's ignoring the closer-binding green
color
instruction.I can't see anything in the manual which suggests this shouldn't work as I expect, so suspect it's a bug?
OpenSCAD version
2021.01
on MacThe text was updated successfully, but these errors were encountered: