# Let position paint a pattern

Turn a wave into stripes on a surface.

Last updated: 2026-09-09

Package: dolphin.spatial3d | Status: complete-program

Tags: cpu, dolphin.materials, dolphin.math, dolphin.spatial3d, recipe

A constant blend gives one color everywhere. A changing blend gives a pattern. DolphinSurfaceWave converts a coordinate and frequency into a smooth repeating value around the zero-to-one range. Using position.y makes the blend vary with height. Using position.x changes which direction the pattern follows. The function still returns an ordinary Dolphin surface value.

```yh
start.yh
```


## Let position paint a pattern

Turn a wave into stripes on a surface.

Verification: type checked

```yh
using dolphin.materials
using dolphin.math
using dolphin.spatial3d

Surface(Vector3 position) -> dolphinSurface
{
    float bands = DolphinSurfaceWave(position.y, 14.0)
    Vector3 teal = Vector3(0.08, 0.7, 0.6)
    Vector3 violet = Vector3(0.6, 0.12, 0.95)
    Vector3 color = DolphinSurfaceMix(teal, violet, bands)
    return DolphinSurface(color, 0.32, 0.55, 0.0)
}

Console.Log(Text.From(Surface(Vector3(0.0, 0.0, 0.0)).roughness))
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__bands"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

[[dependencies]]
package = "dolphin.materials"
version = "0.1.0"
path = "../../../dolphin/packages/materials"

[[dependencies]]
package = "dolphin.math"
version = "0.1.0"
path = "../../../dolphin/packages/math"

[[dependencies]]
package = "dolphin.spatial3d"
version = "0.1.0"
path = "../../../dolphin/packages/spatial3d"

```

Expected output:

```text
0.32
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/recipe--bands/program --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


In the Atlas surface example, change frequency from 14.0 to 7.0. Then restore it and change position.y to position.x.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
