Documentation ¶
Overview ¶
Package primitives provides support for Allegro's primitives addon.
Index ¶
- Constants
- func DrawArc(center Point, r, start_theta, delta_theta float32, color allegro.Color, ...)
- func DrawCircle(center Point, r float32, color allegro.Color, thickness float32)
- func DrawEllipse(center Point, rx, ry float32, color allegro.Color, thickness float32)
- func DrawEllipticalArc(center Point, rx, ry, start_theta, delta_theta float32, color allegro.Color, ...)
- func DrawFilledCircle(center Point, r float32, color allegro.Color)
- func DrawFilledEllipse(center Point, rx, ry float32, color allegro.Color)
- func DrawFilledPieslice(center Point, r, start_theta, delta_theta float32, color allegro.Color)
- func DrawFilledPolygon(p Polyline, color allegro.Color)
- func DrawFilledPolygonWithHoles(p Polyline, holes []Polyline, color allegro.Color)
- func DrawFilledRectangle(p1, p2 Point, color allegro.Color)
- func DrawFilledRoundedRectangle(p1, p2 Point, rx, ry float32, color allegro.Color)
- func DrawFilledTriangle(p1, p2, p3 Point, color allegro.Color)
- func DrawIndexedPrim(vertices []Vertex, decl *VertexDecl, texture *allegro.Bitmap, indices []int, ...) int
- func DrawLine(p1, p2 Point, color allegro.Color, thickness float32)
- func DrawPieslice(center Point, r, start_theta, delta_theta float32, color allegro.Color, ...)
- func DrawPolygon(p Polyline, joinStyle LineJoin, color allegro.Color, thickness float32, ...)
- func DrawPolyline(p Polyline, joinStyle LineJoin, capStyle LineCap, color allegro.Color, ...)
- func DrawPrim(vertices []Vertex, decl *VertexDecl, texture *allegro.Bitmap, start, end int, ...) int
- func DrawRectangle(p1, p2 Point, color allegro.Color, thickness float32)
- func DrawRibbon(p Polyline, color allegro.Color, thickness float32)
- func DrawRoundedRectangle(p1, p2 Point, rx, ry float32, color allegro.Color, thickness float32)
- func DrawSpline(points [4]Point, color allegro.Color, thickness float32)
- func DrawTriangle(p1, p2, p3 Point, color allegro.Color, thickness float32)
- func Install() error
- func Installed() bool
- func TriangulatePolygon(p Polyline, holes []Polyline, callback func(x, y, z int))
- func Uninstall()
- func Version() (major, minor, revision, release uint8)
- type LineCap
- type LineJoin
- type Point
- type Polyline
- type PrimAttr
- type PrimStorage
- type PrimType
- type Vertex
- type VertexDecl
- type VertexElement
Constants ¶
const ( PRIM_POINT_LIST PrimType = C.ALLEGRO_PRIM_POINT_LIST PRIM_LINE_LIST = C.ALLEGRO_PRIM_LINE_LIST PRIM_LINE_STRIP = C.ALLEGRO_PRIM_LINE_STRIP PRIM_LINE_LOOP = C.ALLEGRO_PRIM_LINE_LOOP PRIM_TRIANGLE_LIST = C.ALLEGRO_PRIM_TRIANGLE_LIST PRIM_TRIANGLE_STRIP = C.ALLEGRO_PRIM_TRIANGLE_STRIP PRIM_TRIANGLE_FAN = C.ALLEGRO_PRIM_TRIANGLE_FAN )
const ( PRIM_POSITION PrimAttr = C.ALLEGRO_PRIM_POSITION PRIM_COLOR_ATTR = C.ALLEGRO_PRIM_COLOR_ATTR PRIM_TEX_COORD = C.ALLEGRO_PRIM_TEX_COORD PRIM_TEX_COORD_PIXEL = C.ALLEGRO_PRIM_TEX_COORD_PIXEL )
const ( PRIM_FLOAT_2 PrimStorage = C.ALLEGRO_PRIM_FLOAT_2 PRIM_FLOAT_3 = C.ALLEGRO_PRIM_FLOAT_3 PRIM_SHORT_2 = C.ALLEGRO_PRIM_SHORT_2 )
const ( LINE_JOIN_NONE LineJoin = C.ALLEGRO_LINE_JOIN_NONE LINE_JOIN_BEVEL = C.ALLEGRO_LINE_JOIN_BEVEL LINE_JOIN_ROUND = C.ALLEGRO_LINE_JOIN_ROUND LINE_JOIN_MITER = C.ALLEGRO_LINE_JOIN_MITER )
const ( LINE_CAP_NONE LineCap = C.ALLEGRO_LINE_CAP_NONE LINE_CAP_SQUARE = C.ALLEGRO_LINE_CAP_SQUARE LINE_CAP_ROUND = C.ALLEGRO_LINE_CAP_ROUND LINE_CAP_TRIANGLE = C.ALLEGRO_LINE_CAP_TRIANGLE LINE_CAP_CLOSED = C.ALLEGRO_LINE_CAP_CLOSED )
Variables ¶
This section is empty.
Functions ¶
func DrawArc ¶
func DrawArc(center Point, r, start_theta, delta_theta float32, color allegro.Color, thickness float32)
Draws an arc.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_arc
func DrawCircle ¶
Draws an outlined circle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_circle
func DrawEllipse ¶
Draws an outlined ellipse.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_ellipse
func DrawEllipticalArc ¶
func DrawEllipticalArc(center Point, rx, ry, start_theta, delta_theta float32, color allegro.Color, thickness float32)
Draws an elliptical arc.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_elliptical_arc
func DrawFilledCircle ¶
Draws a filled circle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_circle
func DrawFilledEllipse ¶
Draws a filled ellipse.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_ellipse
func DrawFilledPieslice ¶
Draws a filled pieslice (filled circular sector).
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_pieslice
func DrawFilledPolygon ¶
Draw a filled, simple polygon. Simple means it does not have to be convex but must not be self-overlapping.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_polygon
func DrawFilledPolygonWithHoles ¶
Draws a filled simple polygon with zero or more other simple polygons subtracted from it - the holes. The holes cannot touch or intersect with the outline of the filled polygon.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_polygon_with_holes
func DrawFilledRectangle ¶
Draws a filled rectangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_rectangle
func DrawFilledRoundedRectangle ¶
Draws an filled rounded rectangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_rounded_rectangle
func DrawFilledTriangle ¶
Draws a filled triangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_triangle
func DrawIndexedPrim ¶
func DrawIndexedPrim(vertices []Vertex, decl *VertexDecl, texture *allegro.Bitmap, indices []int, num_vertices int, prim_type PrimType) int
Draws a subset of the passed vertex array. This function uses an index array to specify which vertices to use.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_indexed_prim
func DrawLine ¶
Draws a line segment between two points.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_line
func DrawPieslice ¶
func DrawPieslice(center Point, r, start_theta, delta_theta float32, color allegro.Color, thickness float32)
Draws a pieslice (outlined circular sector).
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_pieslice
func DrawPolygon ¶
func DrawPolygon(p Polyline, joinStyle LineJoin, color allegro.Color, thickness float32, miterLimit float32)
Draw an unfilled polygon. This is the same as passing ALLEGRO_LINE_CAP_CLOSED to al_draw_polyline.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_polygon
func DrawPolyline ¶
func DrawPolyline(p Polyline, joinStyle LineJoin, capStyle LineCap, color allegro.Color, thickness float32, miterLimit float32)
Draw a series of line segments.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_polyline
func DrawPrim ¶
func DrawPrim(vertices []Vertex, decl *VertexDecl, texture *allegro.Bitmap, start, end int, prim_type PrimType) int
Draws a subset of the passed vertex array.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_prim
func DrawRectangle ¶
Draws an outlined rectangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_rectangle
func DrawRibbon ¶
Draws a ribbon given an array of points. The ribbon will go through all of the passed points. The points buffer should consist of regularly spaced doublets of floats, corresponding to x and y coordinates of the vertices.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_ribbon
func DrawRoundedRectangle ¶
Draws an outlined rounded rectangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_rounded_rectangle
func DrawSpline ¶
Draws a Bézier spline given 4 control points.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_spline
func DrawTriangle ¶
Draws an outlined triangle.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_triangle
func Install ¶
func Install() error
Initializes the primitives addon.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_init_primitives_addon
func Installed ¶
func Installed() bool
Returns true if the primitives addon is initialized, otherwise returns false.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_is_primitives_addon_initialized
func TriangulatePolygon ¶
Divides a simple polygon into triangles, with zero or more other simple polygons subtracted from it - the holes. The holes cannot touch or intersect with the outline of the main polygon. Simple means the polygon does not have to be convex but must not be self-overlapping.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_triangulate_polygon
func Uninstall ¶
func Uninstall()
Shut down the primitives addon. This is done automatically at program exit, but can be called any time the user wishes as well.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_shutdown_primitives_addon
func Version ¶
func Version() (major, minor, revision, release uint8)
Returns the (compiled) version of the addon, in the same format as al_get_allegro_version.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_get_allegro_primitives_version
Types ¶
type Polyline ¶
type Polyline []Point
func CalculateArc ¶
func CalculateArc(center Point, rx, ry, start_theta, delta_theta, thickness float32, num_points int) Polyline
When thickness <= 0 this function computes positions of num_points regularly spaced points on an elliptical arc. When thickness > 0 this function computes two sets of points, obtained as follows: the first set is obtained by taking the points computed in the thickness <= 0 case and shifting them by thickness / 2 outward, in a direction perpendicular to the arc curve. The second set is the same, but shifted thickness / 2 inward relative to the arc. The two sets of points are interleaved in the destination buffer (i.e. the first pair of points will be collinear with the arc center, the first point of the pair will be farther from the center than the second point; the next pair will also be collinear, but at a different angle and so on).
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_calculate_arc
func CalculateRibbon ¶
Calculates a ribbon given an array of points. The ribbon will go through all of the passed points. If thickness <= 0, then num_segments of points are required in the destination buffer, otherwise twice as many are needed. The destination and the points buffer should consist of regularly spaced doublets of floats, corresponding to x and y coordinates of the vertices.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_calculate_ribbon
func CalculateSpline ¶
Calculates a Bézier spline given 4 control points. If thickness <= 0, then num_segments of points are required in the destination, otherwise twice as many are needed. The destination buffer should consist of regularly spaced (by distance of stride bytes) doublets of floats, corresponding to x and y coordinates of the vertices.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_calculate_spline
type PrimStorage ¶
type PrimStorage int
type VertexDecl ¶
type VertexDecl C.ALLEGRO_VERTEX_DECL
func CreateVertexDecl ¶
func CreateVertexDecl(elements []VertexElement, stride int) *VertexDecl
Creates a vertex declaration, which describes a custom vertex format.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_create_vertex_decl
func (*VertexDecl) Destroy ¶
func (v *VertexDecl) Destroy()
Destroys a vertex declaration.
See https://liballeg.org/a5docs/5.2.6/primitives.html#al_destroy_vertex_decl
type VertexElement ¶
type VertexElement struct { Attribute PrimAttr Storage PrimStorage Offset int // contains filtered or unexported fields }