Beam

광선

A beam of light from one point to another.

Also known as: BeamLight beam

Moves in browsers that support WebGPU

This device could not render the demo — showing a still

React
// Renders only in browsers with WebGPU.
import { Shader, Beam } from 'shaders/react'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: 320 }} disableTelemetry>
      <Beam />
    </Shader>
  )
}
Vue
<!-- Renders only in browsers with WebGPU. -->
<script setup lang="ts">
import { Shader, Beam } from 'shaders/vue'
</script>

<template>
  <Shader style="width: 100%; height: 320px" :disable-telemetry="true">
    <Beam/>
  </Shader>
</template>
Svelte
<!-- Renders only in browsers with WebGPU. -->
<script>
  import { Shader, Beam } from 'shaders/svelte'
</script>

<Shader style="width: 100%; height: 320px" disableTelemetry>
  <Beam />
</Shader>
Solid
// Renders only in browsers with WebGPU.
import { Shader, Beam } from 'shaders/solid'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <Beam />
    </Shader>
  )
}
JavaScript
// Renders only in browsers with WebGPU.
// expects <canvas id="canvas" style="width:100%;height:320px"></canvas> on the page
import { createShader } from 'shaders/js'

const shader = await createShader(document.getElementById("canvas"), {
  components: [
    {
      type: 'Beam',
    }
  ]
}, { disableTelemetry: true })

Props · Beam

Changes apply to the demo above and to the code tabs. Descriptions come from the library registry (MIT).

NameValueDefaultRange / optionsDescription
startPositionStart Position
x0.2y0.5
{"x":0.2,"y":0.5}x, y: 0 – 1Starting point of the beam
endPositionEnd Position
x0.8y0.5
{"x":0.8,"y":0.5}x, y: 0 – 1Ending point of the beam
startThicknessStart Thickness0.20 – 2 (step 0.1)Thickness at the start of the beam
endThicknessEnd Thickness0.20 – 2 (step 0.1)Thickness at the end of the beam
startSoftnessStart Softness0.50 – 50 (step 0.1)Edge softness at the start of the beam
endSoftnessEnd Softness0.50 – 20 (step 0.1)Edge softness at the end of the beam
insideColorInside Color#FF0000—Color at the center of the beam
outsideColorOutside Color#0000FF—Color at the edges of the beam
colorSpaceColor Spacelinearlinear · oklch · oklab · hsl · hsv · lchColor space for color interpolation

Every component also takes blendMode · opacity · visible · maskSource/maskType · boundingBox · id

It looks like a flattened laser or stage light stretched between two points. Its defined endpoints make it useful for pointing to a place on the canvas.

Move the endpoints with `startPosition` and `endPosition`. Adjust `startThickness` and `endThickness` independently to taper the beam, and use `insideColor` for its center and `outsideColor` for its edges.

Beam draws its own layer rather than modifying an image. Place it over a dark background and tune both endpoint widths to make the destination clear. It does not track a light source inside a photo.

When to use

Use it to connect two points, add a light accent to a dark hero, or draw a short laser detail. Avoid stacking many beams in a dense diagram on a narrow screen.

Open as page ↗