# Tixy Generator

A standalone module for generating Tixy-like shader patterns in JavaScript/TypeScript. Create beautiful mathematical art using compact expressions.

## What is Tixy?

Tixy is a minimalist programming language designed by Martin Kleppe for creating visual patterns using 4 variables:
- `t` - time
- `i` - index (pixel index in the grid)
- `x` - x coordinate
- `y` - y coordinate

## Usage

```typescript
import { compileTixyExpression, renderTixyToCanvas } from '@src/tixy-generator'

// Compile a Tixy expression
const expression = compileTixyExpression('sin(t)*x')

// Render to canvas
const result = renderTixyToCanvas(expression, {
  width: 64,
  height: 64,
  time: 0,
  backgroundColor: '#000000',
  foregroundColor: '#ffffff'
})

// Add to DOM
document.body.appendChild(result.canvas)
```

## Example Expressions

- `sin(t)` - Simple sine wave
- `sin(t)*x` - Sine wave with x scaling
- `sin(t+x/8)*y` - Traveling wave
- `(x+t)*(y+t)` - Expanding diagonal pattern
- `sin(x*y+t)` - XY interference pattern
- `sin((x-8)**2+(y-8)**2+t)/2` - Ripple from center
- `x%2*y%2` - Checkerboard pattern

## API

### Core Functions

- `compileTixyExpression(code: string): TixyExpression` - Compile expression string
- `evaluateTixyExpression(expression, t, i, x, y): number` - Evaluate at coordinates
- `renderTixyToCanvas(expression, options): TixyResult` - Render to canvas
- `renderTixyToImageData(expression, options): ImageData` - Render to ImageData

### Types

- `TixyExpression` - Compiled expression object
- `TixyRenderOptions` - Rendering configuration
- `TixyResult` - Canvas and ImageData result

Math functions like `sin`, `cos`, `sqrt` etc. are available without the `Math.` prefix.