Skip to main content
Describes how shapes are drawn, including fill or stroke style, thickness, color, gradient, and blending behavior.

Fields

style

Painting style of type PaintStyle.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  style = 'stroke',
})

join

Stroke join behavior for corners. See StrokeJoin.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  cap = 'round',
  style = 'stroke',
})

cap

Stroke cap used for line endings. See StrokeCap.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  join = 'round',
  style = 'stroke',
})

thickness

Thickness of the stroked path.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  thickness = 4,
  style = 'stroke',
})

blendMode

Blending mode used when compositing. See BlendMode.

feather

Feathering amount.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  feather = 4,
  style = 'stroke',
})

gradient

Gradient applied to fill (if present).
local g = Gradient.linear(Vector.xy(0, 0), Vector.xy(10, 0), {
  { position = 0, color = Color.rgb(255, 0, 0) },
  { position = 1, color = Color.rgb(0, 0, 255) },
})

self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  gradient = g,
  style = 'fill',
})

color

Color. See Color.
self.paint = Paint.with({
  color = Color.rgb(255, 100, 50),
  style = 'fill',
})

Constructors

new

Creates a new Paint object with default settings.
local paint = Paint.new()
paint.style = 'fill'
paint.color = Color.rgb(255, 200, 80)

with

Creates a new Paint initialized from the provided PaintDefinition.
local strokePaint = Paint.with({
  style = 'stroke',
  thickness = 3,
  color = Color.hex('#FF0066'),
  join = 'round',
  cap = 'round',
})

Methods

copy

Returns a new Paint that copies this one, optionally overriding selected properties with values from the provided PaintDefinition. Returns a new Paint instance.
local base = Paint.with({
  style = 'fill',
  color = Color.rgb(255, 0, 0),
})

local outline = base:copy({
  style = 'stroke',
  thickness = 4,
})