8000 GitHub - rsaccon/fidget-koto: Koto scripting for fidget
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rsaccon/fidget-koto

Repository files navigation

fidget-koto

Koto scripting for fidget (as alternative to Rhai)

Demo

fidget-viewer https://github.com/mkeeter/fidget/tree/main/demos/viewer modified to accept Koto scripts.

cargo run --release -p fidget-viewer PATH_TO_YOUR_KOTO_SCRIPT_MODEL

The models folder has some examples (all Rhai fidget models have been ported to Koto and some new ones added). The fidget-viewer can currently only watch one Koto file, therefore any attempt to import from a differnt module represented by a differnt Koto file in the models folder will fail.

Differences to fidget Rhai scripting:

  • no draw_rgb() function, just use draw() with optionally adding the color arguments r, g and b.
  • use tree() Koto shape method for converting to a fidget Tree.
  • Engine initialization
    • Default: Engine::default()
    • Custom: Engine::new(settings: EngineSettings). The following options are available:
      • add_fidget_fns: bool for making all fidget helper functions avaliable at top level
      • execution_limit: Duration for scripting execution time limit

Sphere Example

Either use the built-in implementation from the core library:

# sphere with radius=1.0, x=0.0 (default), y=0.0 (default), z=0.0 (default)
draw sphere 1

or build it from scratch by using fidget Tree operations as with Rhai:

draw (x.square() + y.square() + z.square()).sqrt() - 1

or with operators where possible:

draw (x^2 + y^2 + z^2)).sqrt() - 1

or from scratch, but with importing fidget Tree operations into global namespace:

from fidget import square, sqrt

draw sqrt(square(x) + square(y) + square(z)) - 1

About

Koto scripting for fidget

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0