Studio Yotsuba
Back to Node List

Line

line_generate

Draws a line between two points using Bresenham's algorithm

Reviewed
Guide available

Input Ports

NameTypeDescription
Color
color
Color
Line color (overrides parameter if connected)

Output Ports

NameTypeDescription
Image
output
Image
Generated line image

Parameters

NameTypeDefaultRangeDescription / Options
Width
width
Int
641–1024

Canvas width in pixels

Height
height
Int
641–1024

Canvas height in pixels

X1
x1
Int
00–1024

Start point X coordinate

Y1
y1
Int
00–1024

Start point Y coordinate

X2
x2
Int
630–1024

End point X coordinate

Y2
y2
Int
630–1024

End point Y coordinate

Thickness
thickness
Int
11–64

Line thickness in pixels

Color
color
Color
[1,1,1,1]—

Line color (used when input port is not connected)

Overview

A single-purpose node that draws a pixel-perfect straight line between two points using Bresenham's algorithm. Use it for numerically driven lines defined by coordinates, such as lasers, ropes, gauges, and reticles.

Usage tips

  • Promote the endpoints to input pins 📌 and connect coordinates from a waveform or path_sample to create a moving line such as a beam or connecting rope.
  • Curves and complex shapes belong to bezier_path + path_stroke. This node's advantage is the convenience of drawing from two numeric pairs.
  • Thicknesses of 2px or more are expanded with a circular brush. A horizontal or vertical line has a cross-section exactly as wide as the requested thickness.

Related nodes

  • path_stroke — draws curved or styled lines
  • shape_generate — draws other basic shapes
  • expression_vec2 — calculates endpoint coordinates
  • blend — composites the line over a background

Canvas-size binding

As a generator node, new instances automatically bind width / height to the project canvas size (_canvasWidth / _canvasHeight). The initial endpoint of a new instance is also placed on the current bottom-right pixel (x2 = width - 1, y2 = height - 1). The endpoint itself is not bound and remains freely editable afterward.

State width/height value
Default (new instance) Bound to the project canvas size and follows it automatically
Entered manually or unbound by the user Local value independent of the canvas size

Use the 🔗 button in the Inspector to remove or recreate the binding.

Algorithm

  • 1px thickness: Bresenham's line algorithm (exact pixel line)
  • 2px or more: applies a circular brush at each Bresenham point
  • Odd-sized brushes are symmetric around the line coordinate.
  • An even-sized brush cannot be perfectly symmetric on integer pixel centers, so its center is fixed 0.5px down and right from the line coordinate. For example, a 2px brush occupies offsets 0, +1, while a 4px brush occupies -1, 0, +1, +2.
  • Brush pixels outside the canvas are clipped.

Examples

  • LineGenerate → Blend → Preview — draw a straight line
  • TimeSource → ExpressionFloat (sin expression) → Remap → LineGenerate(x2) → AnimationRender — animate line endpoints
  • ColorPicker → LineGenerate(color) — draw a line in any color
Back to Node List