Topographic Lines
NewCustomize
Color
Angle28°
Height1.00
Density18
Thickness1.00px
Scale1.00
Major5
Fill0.60
Relief1.00
Fade0.70
Speed1.0
Grain0.020
Hill1.00
Installation
npx shadcn@latest add https://uibrik.com/r/topographic-lines.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/topographic-lines/topographic-lines.tsx"use client"; import type { CSSProperties, ReactNode } from "react"; import { ShaderSurface, sourcePass, type Prepass } from "../_shader-background/ShaderSurface"; import { paletteOf, type ShadeStep } from "../_shader-background/shades"; const TERRAIN = /* glsl */ ` float terrain(vec2 p, float t) { // a slow warp bends the landforms into ridges and valleys instead of round blobs p += 0.28 * vec2(snoise(vec3(p * 0.45, t * 0.7)), snoise(vec3(p * 0.45 + 7.3, t * 0.7))); float h = snoise(vec3(p * 0.9, t)) * 0.62; h += snoise(vec3(p * 2.1 + 3.7, t * 1.3)) * 0.26; h += snoise(vec3(p * 4.6 - 1.9, t * 1.7)) * 0.1; return h * 0.5 + 0.5; } `; // Flat view: contour lines of a slowly shifting landscape, like a survey map. The terrain is three octaves of // gently warped noise drifting through time; a line is drawn wherever its height crosses a whole // step, sized in screen px with fwidth so every line keeps one crisp width however steep the // ground. Every few lines an index line is drawn heavier, with a soft glow on dark pages. Under the // lines the ground is hill-shaded from the upper left and tinted by height, so the map reads as // relief rather than flat rings. Where the ground is so steep the lines would crowd into mush they // fade to their average tone. The pointer raises a hill under it and lights the lines around it,
Adds the files to
components/uibrik/topographic-lines. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/topographic-lines.Usage
import { TopographicLines } from "@/components/uibrik/topographic-lines/topographic-lines";<TopographicLines color="#178a6a" perspective angle={28} height={1} density={18} thickness={1} scale={1} major={5} fill={0.6} relief={1} fade={0.7} speed={1} grain={0.02} animate interactive hill={1}> …</TopographicLines>Props
TopographicLines- color
- Type string
- "#178a6a"
- Colour of the lines; drawn in shades of it.
- colors
- Type string[]
- ["#1d3557","#2a6f97","#52b69a","#d9ed92"]
- Hex colours, 2 to 6, from the lowest ground to the highest. Overrides color.
- perspective
- Type boolean
- true
- Draw the terrain in 3D, seen from a tilted camera; off draws a flat map.
- angle
- Type number
- 28
- Camera tilt down from level.
- height
- Type number
- 1
- Height of the relief.
- density
- Type number
- 18
- How many contour lines span the terrain's full height.
- thickness
- Type number
- 1
- Line width.
- scale
- Type number
- 1
- Size of the landforms; larger is broader and calmer.
- major
- Type number
- 5
- Every Nth line is drawn heavier as an index line; 0 turns them off.
- fill
- Type number
- 0.6
- Tint between the lines by height.
- relief
- Type number
- 1
- Strength of the hill shading under the lines; 0 is flat.
- fade
- Type number
- 0.7
- Flat: how far the lines fade toward the edges. 3D: how thick the haze toward the horizon is.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- grain
- Type number
- 0.02
- Film grain strength.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- interactive
- Type boolean
- true
- Raise a hill under the pointer.
- hill
- Type number
- 1
- Height of the pointer's hill.
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.