shape2d component
A 2D primitive at the node, tinted by color and drawn with texture. kind is circle, rectangle, capsule, ellipse, star, ngon or polyline; a polyline…
Bu sayfada
2d · render · 34 properties · 2D
A 2D primitive at the node, tinted by color and drawn with texture. kind is circle, rectangle, capsule, ellipse, star, ngon or polyline; a polyline follows a mesh or path2d asset.
In a scene, shape2d is the node key that applies it. A script reaches each property below as a field on node.shape2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.shape2d.get() and node.shape2d.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
blend_mode |
enum | auto |
How the surface lands on what is under it: straight alpha, a colour that already carries its alpha, added light, multiplied shade, screen, or opaque. auto is premultiplied for a texture uploaded with premultiply, else alpha One of auto, alpha, premultiplied, add, multiply, screen, opaque. |
cap |
enum | round |
How an open polyline ends One of round, butt, square. |
closed |
bool | false |
Join the last point back to the first, making a polygon outline |
color |
color | [0.8,0.8,0.8,1] |
Tint, as channel floats or #rrggbb / #rrggbbaa |
corner_radius |
float | 0 |
How far the corners are rounded off, when kind is rectangle; zero is a square corner At least 0. |
cull_back_faces |
bool | false |
Skip a triangle whose back faces the viewer, as a negative scale turns one |
dot_color |
color | [1,1,1,1] |
The dots' colour |
dot_size |
float | 0 |
Size of a dot drawn on every vertex; zero draws none At least 0. |
dot_sizing |
enum | world |
What dot_size counts: world is world units, which the camera's zoom scales, screen is pixels One of world, screen. |
draw_surface |
bool | true |
Whether the surface draws; off leaves the wireframe and the dots alone |
gradient |
color | [0,0,0,0] |
The colour a polyline fades to at its far end, from color at its start; a zero alpha means no gradient |
gradient_steps |
int | 32 |
How many colours a polyline's gradient steps through along its length At least 1. |
height |
float | 2 |
Length along y, tip to tip, when kind is capsule At least 0.01. |
inner_radius |
float | 0.2 |
How far the notches between a star's tips reach At least 0.01. |
join |
enum | round |
How a polyline's segments meet One of round, miter, bevel. |
kind |
enum | rectangle |
Rendered 2D shape One of circle, rectangle, capsule, ellipse, star, ngon, polyline. |
material |
asset · material |
— | The material this draws with; empty draws with the built-in one |
mesh |
asset · mesh |
— | Where a polyline's points come from: a mesh asset's vertices, or a path2d asset, which is sampled into points and so draws as a stroked curve |
miter_limit |
float | 4 |
How far a miter join may reach, in half-widths, before its corner is cut to a bevel At least 1. |
normal_map |
asset · texture |
— | A tangent-space normal map: the node then draws lit per pixel by every light2d, after the light map and over what it lit, with no shadow. Empty leaves it to the light map. Give the image srgb = false |
normal_strength |
float | 1 |
How far the normal map bends the surface; zero lights it flat At least 0. |
points |
int | 5 |
Tips, when kind is star At least 3. |
radius |
float | 0.5 |
Radius, when kind is circle, capsule, star or ngon At least 0.01. |
segments |
int | 32 |
Cuts around a circle, an ellipse, a rounded corner, or a polyline's round joins and caps At least 3. |
shininess |
float | 16 |
How tight the highlight is on a normal-mapped node; higher is smaller and sharper At least 1. |
sides |
int | 4 |
Sides, when kind is ngon At least 3. |
size |
vec2 | [1,1] |
Whole size along each axis, when kind is rectangle or ellipse |
specular_strength |
float | 0 |
How bright a light's highlight is on a normal-mapped node; zero draws none At least 0. |
taper |
vec2 | [1,1] |
Multipliers on width at a polyline's start and end, blended along it; anything but [1, 1] draws round joins and caps |
texture |
asset · texture |
— | An image, or a texture asset, the shape draws with: over a primitive's own UVs, and along a polyline repeating once per world unit of its length |
width |
float | 0.02 |
Line thickness in world units, when kind is polyline At least 0.001. |
wireframe_color |
color | [1,1,1,1] |
The wireframe's colour |
wireframe_sizing |
enum | world |
What wireframe_width counts: world is world units, which the camera's zoom scales, screen is pixels One of world, screen. |
wireframe_width |
float | 0 |
Width of a line drawn along every triangle edge, not the outline; zero draws none At least 0. |
Asset types this component references: material, mesh, texture.
Script functions
Methods of node.shape2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().
From render:
| method | what it does |
|---|---|
set_rectangle(float, float) |
Draw the node as a rectangle from its two half-extents, in world units, replacing any other 2D shape. |