May 17, 2024
Description
I produce a lot of customised products with embedded images and text from SVG and PNG files using OpenSCAD but I've been frustrated that it's not been as easy to do with curved surfaces.
Examples I've found in the past have focussed on PNG images and applied a geometric subtraction directly but I wanted to be able to choose whether to add, subtract or just create a standalone curved object. PNG images can produce some pretty ugly blocking artefacts unless high resolution images are used, which really impacts rendering, and often hits hardware limits.
I was finally badgered enough to try again and came up with some OpenSCAD code that works for SVG images. I made it work to an extent with PNG images as well but not for multiple greyscales with varying depth, as I have for flat planes. I think this will take some further work so I have removed the PNG functionality for now. SVG images render faster and don't suffer the scaling issues that PNG images do.
A lot of credit goes to Justin Lin for providing some theory and example code that helped me to understand the approach here.
This code, without additional plugins can take, as a list, a number of images and wrap them around a curved, essentially cylindrical surface. Images can be independently scaled, rotated, flipped and positioned around a radius at an angular position and height. Spheres and other irregular surfaces will take a lot more effort but it's a step in the right direction for now.
The dimensions of the images need to be known (find them by using Inkscape or similar app) as they are required for the calculations. There are a couple of images included that I have no provenance for. Consider these as having no commercial license and are used purely for demonstrating the code. Do not use them in projects without checking their provenance. If you are the intellectual copyright owner to these images then please let me know and I will remove them.
A single image of a dragon.
Multiple images of a heart at different angular positions, heights and rotations. The top row are also flipped.
The code has 2 examples for embossing and ‘debossing’ (not a real word) a cylinder using OpenSCAD, but the stl of the images themselves could be used directly in a slicer as an additive or subtractive part.
A 'debossed" cylinder example.
An embossed cylinder example.
Note: It is recommended to use a nightly build of OpenSCAD and use the Manifold feature to speed up processing by orders of magnitude. Increasing the number of curve segments will have a significant impact on rendering time, particularly with multiple images.
I've moved the source to Github to track any changes here.
License:
GNU General Public License v2.0