How to modify texture color with code?
-
Hi,
Is there a way to modify a texture color with code?
Thanks
-
Methods in https://developers.google.com/sketchup/docs/ourdoc/texture lets you find the material's texture's 'average_color' etc.
Methods in https://developers.google.com/sketchup/docs/ourdoc/material lets you get/set a material's texture and also the material's color, opacity etc. -
Note that the API is missing methods to make a texture Colorized.
-
You can tell if a material is colorized, via https://developers.google.com/sketchup/docs/ourdoc/material#materialType which returns 2 if the material is 'textured and colorized' [or 0 is untextured and 1 if textured], but as TT says there is no effective way to change a material's 'colorization; settings in the API.
The 'average_color' is useful for representing the material's texture as its RGB color when the view-mode isn't showing textures.
-
If I understood correctly it can't display the color changes while in texture mode. I hope one day the API will support such a task. Oh well I guess I need to use another method to achieve what I wanted which was to change the color of texturized clouds depending on the sun or moon is position.
Thank you both
-
I think when setting a color to a textured material, the change becomes visible immediately, however the API does not differ between colorizing (checkbox in the materials browser) and color-shifting (pointer on the color wheel).
Assuming you rotate the color wheel of a material A and get material B:

We can then read the color value of B:
` material.materialType2
color = material.color
Color(200, 147, 62, 255)then reset it to the texture image's original look:material.color = nil
nilThis way we get A.material.materialType
1then trying to set it again:material.color = color
Color(200, 147, 62, 255)
material.materialType
2`
This time it is also colorized (C) and we have no control about it.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement