Troberg
2018-11-22 09:06:30 UTC
I have a laser cutter on the way, and in preparation for that, I've made a
couple of programs to cut pixel images. I firts run a small VB program which
translates the image to an array, so I can work with it in OpenSCAD.
Then, I make a module which loops through that image and places as scaled
copy of children() at each pixel position. The brighter the pixel, the
larger the scale (and thus the eventual hole cut).
That's nice and clean, and I can easily have square holes, round holes, star
shaped holes or whatever. With some parameters, I can even make the scaling
in only one direction, to crete a "blinds" effect.
Neat.
But, me being me, I couldn't stop thinking of possibilites.
So, I thought: "Wouldn't it be neat if I could change the shape of the pixel
hole depending on the value?". For example, start with a very thin + shape
for dark pixels, then move the four center vertices out towards the corners
for brighter pixels, making it look more like a four point star, through a
rhombus, an octagon and eventually a square for a white pixel.
Well, of course I can do that, but not in the same code. I can't send
paramaters to children(). I have to replace children() with a call to, for
example, mystarshape(). But, that comes with complications as well, as it
means that I will have to go into the module and change it if I wanted
another shape/logic, which makes for poor separation of concern.
Any thoughts on how to make a neat solution for this?
--
Sent from: http://forum.openscad.org/
couple of programs to cut pixel images. I firts run a small VB program which
translates the image to an array, so I can work with it in OpenSCAD.
Then, I make a module which loops through that image and places as scaled
copy of children() at each pixel position. The brighter the pixel, the
larger the scale (and thus the eventual hole cut).
That's nice and clean, and I can easily have square holes, round holes, star
shaped holes or whatever. With some parameters, I can even make the scaling
in only one direction, to crete a "blinds" effect.
Neat.
But, me being me, I couldn't stop thinking of possibilites.
So, I thought: "Wouldn't it be neat if I could change the shape of the pixel
hole depending on the value?". For example, start with a very thin + shape
for dark pixels, then move the four center vertices out towards the corners
for brighter pixels, making it look more like a four point star, through a
rhombus, an octagon and eventually a square for a white pixel.
Well, of course I can do that, but not in the same code. I can't send
paramaters to children(). I have to replace children() with a call to, for
example, mystarshape(). But, that comes with complications as well, as it
means that I will have to go into the module and change it if I wanted
another shape/logic, which makes for poor separation of concern.
Any thoughts on how to make a neat solution for this?
--
Sent from: http://forum.openscad.org/