Rotating Texture/Material of a Face

I am now fairly familiar with using the position_material method to position a material on a face.

The basic example is here in the Ruby API: Class: Sketchup::Face — SketchUp Ruby API Documentation

So far I’ve only needed to translate in the X or Z direction (or both) however now I am thinking about trying to rotate the texture image some arbitrary angle. Has anyone ever tried that before or know how to use this method to do that? or possibly a different method? At this point I’m not sure it is even possible with the API but I thought I might ask.

You can always get the image_rep of the texture and manipulate the data.
Then set it back to the face’s material.

I’d think the web would have some code already posted for rotating image pixel data.

… then again the pixel data UV coordinates could have a rotational transformation applied and then the coordinates truncated. (There might be some blurring.)

You’d need to use the 3D Geom::Transformation as the Transformation2d has it’s origin at the top left and Y coordinates going downward.

Some years ago I wrote a toolset that lets you manipulate textures in several ways.
It’s available at the SketchUcation PluginStore - TIG-TextureTools
See how it can rotate a texture to any desired angle…
You can borrow its methods as you see fit…


I might take a look at that code then and see if I can even understand what you are doing.