GithubHelp home page GithubHelp logo

Comments (2)

spuder avatar spuder commented on July 17, 2024 1

Thanks!

Got it working with the <hsvtorgb.scad> library

It takes a value between 0.0 and 1.0 and translates it to an RGB value (e.g. [1,0,0] would be red, [0,1,0] would be green)

    $openscad_path /dev/null \
        -D 'use <hsvtorgb.scad>;' \
        -D '$vpr = [60, 0, 360 * $t];' \
        -o "${MYTMPDIR}/foo.png"  \
        -D "color(hsvToRGB(\$t,1,1)) import(\"${MYTMPDIR}/foo-centered.stl\");" \
        --imgsize=600,600 \
        --animate 60 \
        --viewall --autocenter \
        --preview \
        --quiet

I've created a docker container/script that can do this with any .stl file on my github spuder/CAD-scripts/stl2gif.sh

Thanks again

benchy

from gridfinity-rebuilt-openscad.

kennetek avatar kennetek commented on July 17, 2024

I don't think I still have the code snippet, it got lost somewhere and I do not know where. But I can remember vaguely how I did it. To sum it up, I used the animation window in the OpenSCAD GUI to program the movement/color, get an image dump, and used Image Magick to compile into a gif. Animating in OpenSCAD can be done with the variable $t (see the wiki). I think I normalized $t to be between 0 and 1, so $t was divided by the number of frames I wanted. There are three steps to this animation:

  1. Rotation: use the rotate command around the Z axis. Since it only does one rotation, this is simply 360*$t
  2. Translation: The up and down movement is a sine function of $t. So something like sin(360*$t) inside a translate command. There may have been frequency modifiers.
  3. Color: using the color([r,g,b,a]) command, all that is needed is some continuous mapping function of $t to a hue. I don't remember what I used, most likely something copied off Stack Overflow.

After playing the animation and having the dump images box checked, the files were in order in the script directory. With ImageMagick, you can collect all these image files and generate a gif.

from gridfinity-rebuilt-openscad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.