Documentation ¶
Index ¶
- Constants
- Variables
- func AutoResolution(radius, start, end, spacing float64) int
- type Base
- type Circle
- type ClampedViewport
- type Edge
- type End
- type Geom
- func (g *Geom) AABB(value mat.AABB)
- func (g *Geom) Accept(vertexes ggl.Vertexes, indices ggl.Indices)
- func (g *Geom) Apply(start, end int)
- func (g *Geom) Arc(start, end float64) *Geom
- func (g *Geom) Circle(c mat.Circ)
- func (g *Geom) Color(value mat.RGBA) *Geom
- func (g *Geom) Draw(t ggl.Target, mat mat.Mat, rgba mat.RGBA)
- func (g *Geom) Fetch(t ggl.Target)
- func (g *Geom) Fill(fill bool) *Geom
- func (g *Geom) Intensity(value float64) *Geom
- func (g *Geom) Line(points ...mat.Vec)
- func (g *Geom) LineType(ld LineDrawer) *Geom
- func (g *Geom) Loop(loop bool) *Geom
- func (g *Geom) Rect(corners [4]mat.Vec)
- func (g *Geom) Reserve(amount int) ggl.Vertexes
- func (g *Geom) Resolution(resolution int) *Geom
- func (g *Geom) Restart()
- func (g *Geom) Spacing(value float64) *Geom
- func (g *Geom) Thickness(thickness float64) *Geom
- type LineDrawer
- type LineDrawerBase
- func (l *LineDrawerBase) Close(e *Edge, lp *LineProcessor)
- func (l *LineDrawerBase) Edge(e *Edge, lp *LineProcessor)
- func (*LineDrawerBase) End(e *End, lp *LineProcessor)
- func (*LineDrawerBase) Init(thickness float64)
- func (*LineDrawerBase) PostEnge(e *Edge, lp *LineProcessor)
- func (*LineDrawerBase) PreEdge(e *Edge, lp *LineProcessor)
- func (*LineDrawerBase) Start(e *End, lp *LineProcessor)
- type LineProcessor
- type Preprocessor
- type RoundLine
- type SharpLine
- type SpriteViewport
Constants ¶
const Auto = -1
Auto is constant that if you pass as resolution to Circle, auto resolution will be used
Variables ¶
var ( Default = &LineDrawerBase{} Sharp = &SharpLine{} // Round holds some inner state so if you are drawing on multiple threads, you need to create own instances Round = &RoundLine{} )
Line Modes
var AutoResolutionSpacing float64 = 1
AutoResolutionSpacing is size of fraction of the circle that has Auto resolution
var LineIndicePatern = ggl.Indices{0, 1, 3, 0, 3, 2}
Functions ¶
func AutoResolution ¶
Types ¶
type Circle ¶
Circle is a drawing tool that can draw circles with different resolution efficiently as everithing is precalculated upon creation
func NCircle ¶
NCircle creates ready-to-use Circle, choose resolution based of how big circles you want to draw bigger the circle more resolution matters, radius is not that important ac you can scale circle how ever you like
type ClampedViewport ¶
ClampedViewport clamps all vertices into Area
type Geom ¶
Geom is is small abstraction around Data that allows drawing of geometric shapes, geomdrawer can be used as canvas for creating complex shapes, Drawers can draw to each other, though if you don't want triangles to get modified by target drawer use drawer.Data as target
// use as is or create with NGeom that sets some default values d := drw.Geom{} // red rectangle d.Color(mat.Red).Fill(true).AABB(mat.A(0, 0, 100, 100)) // draws green outline to red rectangel with total thickness 10 d.Color(mat.Green).Thickness(5).Fill(false).AABB(mat.A(0, 0, 100, 100)) // draws line closed in triangle with custom edge style d.Color(mat.RGB(0, 1, 1)).Loop(true).Thickness(10).Edge(CutEdge{}) d.Line(mat.V(0, -100), mat.V(-100, -200), mat.V(100, -200)) // draw everithing to target with no transformation d.Fetch(t) // draw to target with ewerithing transformed by matrix and masked, in this case // everithing is shifted by 100 to right, twice as big and rotated by 90 degrees d.Draw(t, mat.M(mat.V(100, 0), mat.V(2, 2), math.Phi*.5), mat.RGB(.5, .5, .5))
func (*Geom) LineType ¶
func (g *Geom) LineType(ld LineDrawer) *Geom
func (*Geom) Reserve ¶
Reserve reserves vertexes, sets theier intensity and color and returns slice that points to them
func (*Geom) Resolution ¶
Resolution sets resolution of circle, it can be set to Auto but if spacing is 0 nothing will be drawn
type LineDrawer ¶
type LineDrawer interface { Init(thickness float64) Start(*End, *LineProcessor) End(*End, *LineProcessor) Edge(*Edge, *LineProcessor) Close(*Edge, *LineProcessor) }
type LineDrawerBase ¶
type LineDrawerBase struct{}
func (*LineDrawerBase) Close ¶
func (l *LineDrawerBase) Close(e *Edge, lp *LineProcessor)
func (*LineDrawerBase) Edge ¶
func (l *LineDrawerBase) Edge(e *Edge, lp *LineProcessor)
func (*LineDrawerBase) End ¶
func (*LineDrawerBase) End(e *End, lp *LineProcessor)
func (*LineDrawerBase) Init ¶
func (*LineDrawerBase) Init(thickness float64)
func (*LineDrawerBase) PostEnge ¶
func (*LineDrawerBase) PostEnge(e *Edge, lp *LineProcessor)
func (*LineDrawerBase) PreEdge ¶
func (*LineDrawerBase) PreEdge(e *Edge, lp *LineProcessor)
func (*LineDrawerBase) Start ¶
func (*LineDrawerBase) Start(e *End, lp *LineProcessor)
type LineProcessor ¶
func (*LineProcessor) AppendIndices ¶
func (l *LineProcessor) AppendIndices(indices ...uint32)
func (*LineProcessor) AppendPoints ¶
func (l *LineProcessor) AppendPoints(center mat.Vec, points ...mat.Vec)
func (*LineProcessor) Process ¶
func (l *LineProcessor) Process(g *Geom, ld LineDrawer, points ...mat.Vec)
type Preprocessor ¶
Preprocessor is something that changes triangles in some way and can draw them, for example multiplying of seting color mask
type RoundLine ¶
type RoundLine struct { LineDrawerBase Circle }
func (*RoundLine) Close ¶
func (r *RoundLine) Close(e *Edge, lp *LineProcessor)
func (*RoundLine) Edge ¶
func (r *RoundLine) Edge(e *Edge, lp *LineProcessor)
func (*RoundLine) End ¶
func (r *RoundLine) End(e *End, lp *LineProcessor)
func (*RoundLine) Start ¶
func (r *RoundLine) Start(e *End, lp *LineProcessor)
type SharpLine ¶
type SharpLine struct{ LineDrawerBase }
func (*SharpLine) AddEnd ¶
func (s *SharpLine) AddEnd(e *End, lp *LineProcessor)
func (*SharpLine) Close ¶
func (s *SharpLine) Close(e *Edge, lp *LineProcessor)
func (*SharpLine) Edge ¶
func (s *SharpLine) Edge(e *Edge, lp *LineProcessor)
func (*SharpLine) End ¶
func (s *SharpLine) End(e *End, lp *LineProcessor)
func (*SharpLine) Start ¶
func (s *SharpLine) Start(e *End, lp *LineProcessor)
type SpriteViewport ¶
SpriteViewport is able to crop sprite triangles that are not rotated thus i makes effect like sprites are only visible from Area, if you try to clamp rotated sprites they will get deformed, trying to clamp something other then sprites will also result in random deformation of corse vertices will be visible only inside the View but for unreasonable performance cost.