🐍 Viper

A Visual DSL for UI/UX and Creative Coding

Declarative. Reactive. Visual-First. Built in Rust.

What is Viper?

Viper is a toy GUI and domain-specific language designed to make creating interactive UI/UX experiences and creative code effortless. It combines declarative syntax, reactive state management, and built-in visual primitives for everything from fractals to shaders to animations.

Whether you're building a dashboard, visualizing mathematical concepts, or crafting generative art—Viper lets you express complex visuals with minimal boilerplate.

✨ Core Features

🎨 Visual Primitives

Built-in shapes: box, circle, path, text, image. Advanced: fractals, curves, polygons, tilings, polynomials.

🎬 Animation System

Smooth motion with lerp, decay, hybrid, leap, and spring easing. Motion paths with splines.

🔮 Shaders & Textures

GPU-accelerated effects: plasma, noise, glass morphing, crackle, Jian ware textures.

🌉 Bridge System

Call external code: Rust, GLSL, Python, Go, C++, Uiua, and more. With built-in caching.

⚡ Reactive State

Declarative state management with state keyword. Changes propagate automatically.

🧩 Components

Reusable UI blocks with parameters, event handling, and theme support.

⚡ Quick Examples

Interactive Button with State

state count = 0

component Button {
  param label: String
  
  draw box(on: tap => count = count + 1) {
    text(content: label + ": " + count)
  }
}

Button(label: "Click Me")

Fractal Viewer with Bridge

state zoom = 1.5

bridge {
  call: "rust:mandelbrot"
  args: { zoom: zoom, center: [0, 0] }
  cache with zoom
  on result {
    canvas {
      draw image(data: result, format: "pixels")
    }
  }
}

Smooth Animation

state targetPos = { x: 100, y: 100 }

animation.smooth(type: "spring", stiffness: 120, damping: 0.9) {
  follow(node: button, to: targetPos)
}

Generative Curve

curve(type: "custom", params: { 
  fn: |t| { x: sin(t * 5), y: cos(t * 3) } 
}) {
  draw path(stroke: "cyan", strokeWidth: 2)
}

Shader Overlay with Glass Effect

shader(type: "glass", params: { blur: 8, refraction: 1.2 }) {
  canvas(width: 512, height: 512)
}

🎯 Language Features

Keywords & Control Flow

Visual Primitives

Animation & Smoothing

Shader & Texture System

Bridge System (External Code)

Call code from 15+ languages with automatic caching:

🧮 Type System

Primitives: Int, UInt, F64, F32, Byte, Bool, Char, Str
Visual Types: Color, Vec2, Vec3, Vec4, matrix
Composites: Tuple, List, Set, Hash
Specialized: Fractal, Shape, Curve

🎭 Perfect For

🚀 Get Started

Explore the full language reference and examples:

🎓 Philosophy

Declarative. Write what you want, not how to compute it.

Reactive. State changes automatically propagate through your UI.

Visual-First. Build visual experiences without fighting abstraction layers.

Minimal. No unnecessary boilerplate—just expressive, focused syntax.

Performant. Compiled to WebAssembly with GPU acceleration for shaders.