Documentation
¶
Overview ¶
Package gog is a Go Drawing Library
Example ¶
150-frame rotating cubic bezier APNG animation
ctx := gog.NewContext(250, 250)
curve := shapes.CubicBezier(100, 95, 50, 300, 190, 88, 140, 200, 50)
curve.SetPos(ctx.Center)
for range 150 {
ctx.Clear(color.Gray{30})
curve.Rotate((math.Pi * 2) / 150)
ctx.DebugDraw(curve)
ctx.AppendAnimationFrame()
}
// ctx.SaveAPNG("anim.png", 3)
fmt.Println(len(ctx.AnimationFrames))
Output: 150
Index ¶
- type CapMode
- type Context
- func (ctx *Context) AppendAnimationFrame()
- func (ctx *Context) Clear(c color.Color) *Context
- func (ctx *Context) ClearAnimationFrames()
- func (ctx *Context) DebugDraw(pth *path.Path)
- func (ctx *Context) Fill(p *path.Path, fillColor color.Color)
- func (ctx *Context) SaveAPNG(filePath string, delay int)
- func (ctx *Context) SavePNG(filePath string)
- func (ctx *Context) Stroke(p *path.Path, strokeStyle *StrokeStyle)
- func (ctx *Context) Surface() *image.RGBA
- type DrawMode
- type JoinMode
- type StrokeStyle
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
AnimationFrames []image.Image
// Center point of Canvas
Center v.Vec
// contains filtered or unexported fields
}
func NewContext ¶
NewContext returns a new drawing context.
func (*Context) AppendAnimationFrame ¶
func (ctx *Context) AppendAnimationFrame()
AppendAnimationFrame appends current canvas to animation frames.
func (*Context) ClearAnimationFrames ¶
func (ctx *Context) ClearAnimationFrames()
ClearAnimationFrames clears context.AnimationFrames
func (*Context) SaveAPNG ¶
SaveAPNG Saves APNG animation addes with AppendAnimationFrame().
The successive delay times, one per frame, in 100ths of a second. (2 for 50 FPS, 4 for 25 FPS)
type StrokeStyle ¶
type StrokeStyle struct {
Color color.Color
LineWidth float64
// Line cap style constant
//
// 0=ButtCap 1=SquareCap 2=RoundCap 3=CubicCap 4=QuadraticCap
Cap CapMode
// Line join style
//
// 0=MiterJoin 1=RoundJoin 2=BevelJoin
Join JoinMode
}
Style of path
func NewStrokeStyle ¶
func NewStrokeStyle(fillColor, strokeColor color.Color, lineWidth float64, cap CapMode, join JoinMode) *StrokeStyle
NewStyle shorthand for create Style{}
func (*StrokeStyle) SetColor ¶
func (s *StrokeStyle) SetColor(c color.Color) *StrokeStyle
func (*StrokeStyle) SetLineWidth ¶
func (s *StrokeStyle) SetLineWidth(w float64) *StrokeStyle
Click to show internal directories.
Click to hide internal directories.