AntialiasedTriangle
A specialized triangle shape that simulates antialiasing using additional vertices.
This class creates a smooth-edged triangle without requiring multisampling or hardware antialiasing. It achieves this by adding extra vertices around the edges with alpha transparency, creating a gradient effect that simulates antialiased edges.
The triangle uses 6 vertices instead of the typical 3:
- 3 inner vertices forming the main triangle (fully opaque)
- 3 outer vertices extending beyond the triangle bounds (fully transparent)
var triangle = new AntialiasedTriangle();
triangle.size(200, 150);
triangle.color = Color.RED;
triangle.antialiasing = 2; // 2-pixel antialiasing border
triangle.pos(100, 100);
Instance Members
antialiasing: Float
The width of the antialiasing border in pixels. Higher values create a smoother but wider gradient edge. Default value is 1 pixel.
Common values:
- 0.5: Very subtle antialiasing
- 1.0: Standard antialiasing (default)
- 2.0: Strong antialiasing for larger triangles
new(): Void
Creates a new antialiased triangle. Initializes the mesh with 6 vertices and the appropriate indices for rendering the antialiased edges.
Private Members
updateVertices(): Void
Updates the vertex positions based on current width, height, and antialiasing values.
The vertex layout is:
- Vertices 0,1,2: Inner triangle vertices (opaque)
- Vertices 3,4,5: Outer vertices for antialiasing (transparent)
The outer vertices are positioned beyond the triangle bounds by the antialiasing amount.
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |