primitives

package
v1.0.1-0...-c7f6355 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: MIT Imports: 5 Imported by: 5

Documentation

Overview

Package primitives provides support for Allegro's primitives addon.

Index

Constants

View Source
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
)
View Source
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
)
View Source
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
)
View Source
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
)
View Source
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

func DrawCircle(center Point, r float32, color allegro.Color, thickness float32)

Draws an outlined circle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_circle

func DrawEllipse

func DrawEllipse(center Point, rx, ry float32, color allegro.Color, thickness float32)

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

func DrawFilledCircle(center Point, r float32, color allegro.Color)

Draws a filled circle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_circle

func DrawFilledEllipse

func DrawFilledEllipse(center Point, rx, ry float32, color allegro.Color)

Draws a filled ellipse.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_ellipse

func DrawFilledPieslice

func DrawFilledPieslice(center Point, r, start_theta, delta_theta float32, color allegro.Color)

Draws a filled pieslice (filled circular sector).

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_pieslice

func DrawFilledPolygon

func DrawFilledPolygon(p Polyline, color allegro.Color)

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

func DrawFilledPolygonWithHoles(p Polyline, holes []Polyline, color allegro.Color)

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

func DrawFilledRectangle(p1, p2 Point, color allegro.Color)

Draws a filled rectangle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_rectangle

func DrawFilledRoundedRectangle

func DrawFilledRoundedRectangle(p1, p2 Point, rx, ry float32, color allegro.Color)

Draws an filled rounded rectangle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_filled_rounded_rectangle

func DrawFilledTriangle

func DrawFilledTriangle(p1, p2, p3 Point, color allegro.Color)

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

func DrawLine(p1, p2 Point, color allegro.Color, thickness float32)

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

func DrawRectangle(p1, p2 Point, color allegro.Color, thickness float32)

Draws an outlined rectangle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_rectangle

func DrawRibbon

func DrawRibbon(p Polyline, color allegro.Color, thickness float32)

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

func DrawRoundedRectangle(p1, p2 Point, rx, ry float32, color allegro.Color, thickness float32)

Draws an outlined rounded rectangle.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_rounded_rectangle

func DrawSpline

func DrawSpline(points [4]Point, color allegro.Color, thickness float32)

Draws a Bézier spline given 4 control points.

See https://liballeg.org/a5docs/5.2.6/primitives.html#al_draw_spline

func DrawTriangle

func DrawTriangle(p1, p2, p3 Point, color allegro.Color, thickness float32)

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

func TriangulatePolygon(p Polyline, holes []Polyline, callback func(x, y, z int))

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 LineCap

type LineCap int

type LineJoin

type LineJoin int

type Point

type Point struct {
	X float32
	Y float32
}

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

func CalculateRibbon(p Polyline, color allegro.Color, thickness float32, num_segments int) Polyline

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

func CalculateSpline(points [4]Point, thickness float32, num_segments int) Polyline

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 PrimAttr

type PrimAttr int

type PrimStorage

type PrimStorage int

type PrimType

type PrimType int

type Vertex

type Vertex struct {
	X, Y, Z float32
	Color   allegro.Color
	U, V    float32
	// contains filtered or unexported fields
}

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL