Skip to content

layer

Overlays multiple children in the same coordinate space without any layout offset.

js
gf.Layer([
  gf.Rect({ w: 100, h: 80, fill: gf.color.blue[3] }),
  gf.Ellipse({ w: 60, h: 60, fill: gf.color.red[3] }),
]).render(root, { w: 200, h: 150 });

Both shapes occupy the same space. The ellipse is drawn on top of the rectangle because it appears second in the array.

Signature

ts
Layer(options?, [child1, child2, ...])

Parameters

OptionTypeDescription
coordCoordinateTransformCoordinate transform for this layer
wnumberOverride width
hnumberOverride height
transform.scale.xnumberScale factor for x axis
transform.scale.ynumberScale factor for y axis