8000 GitHub - dipamsen/lumen: A simple scripting language for graphics rendering. · GitHub
[go: up one dir, main page]

Skip to content
  • dipamsenPublic

    About

    A simple scripting language for graphics rendering.

    Resources

    Stars

    4 stars

    Watchers

    1 watching

    Forks

    Repository files navigation

    Lumen

    Lumen
    Lumen
    A simple scripting language for graphics rendering.

    image

    Lumen is a simple scripting language for graphics rendering. It compiles to high performance C code under the hood, using the Raylib graphics library.

    Lumen allows the user to write concise, high-level code to create graphical simulations, games, and visualizations without needing to require boilerplate code to manage graphics resources. Lumen can generate both interactive graphics (e.g., games, simulations) and render video output (e.g., visualizations, generative art).

    Language

    See the manual for details on language features and built-in functions.

    Examples

    Fractal Tree

    config {
      width = 600
      height = 600
      mode = interactive
      title = "Fractal Tree"
    }
    
    let root = (300, 580)
    
    fn branch(pos: Vec2, ang, len, depth) {
      let rad = ang * (pi / 180)
      let end_pos = Vec2 { 
        x = pos.x + (cos(rad) * len), 
        y = pos.y + (sin(rad) * len) 
      }
      
      draw Line(pos, end_pos, color = #ffffff)
      if (depth > 0) {
        branch(end_pos, ang - 20, len * 0.7, depth - 1)
        branch(end_pos, ang + 20, len * 0.7, depth - 1)
      }
    }
    
    loop {
      clear()
      branch(root, -90, 120, 7)
    }
    

    fractal tree

    Bouncing Ball

    config { duration = 5s }
    
    let pos = (20, height/2)
    let vel = (10, 6)
    let r = 20
    
    loop {
      clear()
      vel.y += 0.6
      pos += vel
    
      if (pos.y + r > height) {
          pos.y = height - r
          vel.y = vel.y * -1
      }
    
      if (pos.x + r > width) {
          pos.x = width - r
          vel.x = vel.x * -1
      } else if (pos.x - r < 0) {
          pos.x = r
          vel.x = vel.x * -1
      }
    
      draw Circle(pos, r, color=#00ff00)
    }
    
    bounce.mp4

    Installation

    To install Lumen, follow these steps:

    Go to the releases page and download the .zip file for the latest release. Extract the contents and run the install.sh script to install Lumen globally on your system.

    Alternatively, you can build Lumen from source using the instructions below.

    Building from source

    1. Clone the repository:

      git clone https://github.com/dipamsen/lumen.git
      cd lumen
    2. Install OCaml and Dune: https://ocaml.org/install

      opam install dune
      opam install . --deps-only
      
    3. Build the project:

      dune build
    4. Run tests to verify everything is working:

      dune runtest
    5. Install other runtime dependencies using your system's package manager:

      • libGL (OpenGL library)
        sudo apt update
        sudo apt install libgl1-mesa-dev      # (for Ubuntu/Debian)
      • ffmpeg (for video rendering) (Check if it's already installed by running ffmpeg -version in your terminal)
        sudo apt install ffmpeg               # (for Ubuntu/Debian)
    6. Install lumen globally:

      ./install.sh
    7. Optionally, add lumen to your PATH. This will allow you to run lumen from any directory (in the current terminal session):

      On Linux:

      export PATH="$HOME/.lumen/bin:$PATH"

      On Windows:

      $env:PATH += ";$HOME\.lumen\bin"

    Usage

    lumen run <filename.lm>
    

    License

    MIT License

    About

    A simple scripting language for graphics rendering.

    Resources

    Stars

    4 stars

    Watchers

    1 watching

    Forks

    Releases

    Packages

    Used by

    Contributors

    Languages

    0