Documentation
¶
Index ¶
- Variables
- func Capture(path string, surface Surface) (err error)
- func IsFail(o Option) bool
- func Setup(name Driver, driver func(w, h int, options ...Option) (Surface, error))
- func Vec(x, y float32) mgl32.Vec2
- type Clear
- type CloseQueryBuffer
- type ColorShader
- type Driver
- type FixedShader
- type FlushQueryBuffer
- type Font
- type FrameBuffer
- type Height
- type InnerPath
- type KernalShader
- type MixOperation
- type Option
- type OptionType
- type Path
- type QueryBufferLength
- type QueryType
- type RepeatShader
- type ResultFail
- type Shader
- type Size
- type Surface
- type TextPath
- type Transform
- func (s *Transform) Mul(v mgl32.Vec2) mgl32.Vec2
- func (s *Transform) Pivot(at mgl32.Vec2, do func(t *Transform)) *Transform
- func (s *Transform) RawMul(v mgl32.Vec3) mgl32.Vec3
- func (s *Transform) Reflection(a axis.Axis) *Transform
- func (s *Transform) Rotate(degree float32) *Transform
- func (s *Transform) Scale(scale mgl32.Vec2) *Transform
- func (s *Transform) Shear(shear float32, ea axis.ExculsiveAxis) *Transform
- func (s *Transform) String() string
- func (s *Transform) Translate(delta mgl32.Vec2) *Transform
- type UseQueryBuffer
- type WaitFlush
- type Width
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Surface ErrorUnknownDriver = errors.New("Unknown driver") ErrorAllocation = errors.New("Allocation fail") ErrorNotAllowNil = errors.New("nil is not allow") ErrorTooBusy = errors.New("Currently, Query queue is too busy to handle this") ErrorUnsupported = errors.New("Unsupported Option") ErrorClosed = errors.New("This is closed Surface, Do not use this") )
Predefined Errors for implement Surface. They are not used in the package, but are designed for surface implementation in other packages.
var ( Src = MixOperation(draw.Src) Over = MixOperation(draw.Over) )
var (
FetalSetup = errors.New("Fetal error, Setup check fail")
)
Fetal is a very serious error. They are passed through the panic(), not the return value.
Functions ¶
Types ¶
type Clear ¶
Clear with color.RGBA Clear{} for using this empty all pixels
= Write | Init
func (Clear) OptionType ¶
func (Clear) OptionType() OptionType
type CloseQueryBuffer ¶
type CloseQueryBuffer struct{}
Close buffer
= Send
func (CloseQueryBuffer) OptionType ¶
func (CloseQueryBuffer) OptionType() OptionType
type ColorShader ¶
func (*ColorShader) Size ¶
func (s *ColorShader) Size(w, h int)
type Driver ¶
type Driver string
Get DriverName
= Read
func (Driver) OptionType ¶
func (Driver) OptionType() OptionType
type FixedShader ¶
type FixedShader struct {
// contains filtered or unexported fields
}
func (*FixedShader) Size ¶
func (s *FixedShader) Size(w, h int)
type FlushQueryBuffer ¶
type FlushQueryBuffer struct{}
Flush all buffer for Data
= Send
func (FlushQueryBuffer) OptionType ¶
func (FlushQueryBuffer) OptionType() OptionType
type FrameBuffer ¶
GetResult image
= Read | Write
func (FrameBuffer) Convert ¶
func (s FrameBuffer) Convert() *image.RGBA
func (FrameBuffer) OptionType ¶
func (FrameBuffer) OptionType() OptionType
type Height ¶
type Height int
Get Height
= Read | Write
func (Height) OptionType ¶
func (Height) OptionType() OptionType
type KernalShader ¶
type KernalShader struct {
// contains filtered or unexported fields
}
type MixOperation ¶
GetResult image
= Read | Write | Init
func (MixOperation) OptionType ¶
func (MixOperation) OptionType() OptionType
type Option ¶
type Option interface {
// They do not do anything, but they tell us that they are implementations of the Option interface.
// It exists for a structure that can be utilized in IDE.
OptionType() OptionType
}
Option is an interface used for various synchronization, value transfer and acquisition on the surface. Each option allows you to pass in, receive, or synchronize values that match your name (structure name). All options except Essensial are optional implementations and do not necessarily exist. This can be checked with the .Support method of the Surface interface.
type OptionType ¶
type OptionType uint8
OptionType is the type that exists for the return of the .OptionType() method of the Option interface,
which tells you roughly what the implementation of the Option interface has.
const ( // Read 는 Read OptionType = 0x01 Write OptionType = 0x02 Init OptionType = 0x04 Send OptionType = 0x08 Error OptionType = 0x80 )
type Path ¶
func (*Path) RectValidate ¶
func (*Path) SetLineCap ¶
func (*Path) SetLineJoint ¶
func (*Path) SetLineWidth ¶
type QueryBufferLength ¶
type QueryBufferLength int
GetCurrent Buffer Query Count
= Read
func (QueryBufferLength) OptionType ¶
func (QueryBufferLength) OptionType() OptionType
type RepeatShader ¶
type RepeatShader struct {
// contains filtered or unexported fields
}
type ResultFail ¶
type ResultFail struct {
Cause error
}
There is two type Fail, one is .Option(...) return error wrap by ResultFail Other is return nil, which is so obious, no need to explain
func (ResultFail) Error ¶
func (s ResultFail) Error() string
func (ResultFail) OptionType ¶
func (ResultFail) OptionType() OptionType
type Shader ¶
func NewColorShader ¶
type Size ¶
Get Size(Width, Height)
= Read | Write
func (Size) OptionType ¶
func (Size) OptionType() OptionType
type Surface ¶
type Surface interface {
// Check Support options
// Returns true if all the given options are satisfied
Support(opt ...Option) bool
// It is highly affected by the Linux ioctl function.
// You can pass Option pointer or value(pointer is normally use for get, value normally used for set)
//
// return can be error
// If there is error, it return nil or ResultFail struct(not pointer of ResultFail)
Option(opt Option) Option
// Query send Path, Shader, Transform for Path Rendering
// Always it MUST BE thread-safe
// You can use Goroutine
//
// throw > ErrorTooBusy : Literally, it is too busy to handle this
// throw > ErrorClosed : .Close() method called, do not use this Surface
// throw > * : any other errors
//
// query : It is points for path render
// :
// : nil not allowed, you must pass valid path data
// throw > ErrorNotAllowNil
//
// shader : It is filling data for rendering area
// : This will determine how to fill given space
// :
// : nil can be use, it MUST parsed as NewColorShader(colors.HTML.Black)
// throw > _
//
// transform : It is 3x3 matrix for homogeneous vector points(in query)
// : Every points in query is handle by this for transfomation
// : You can use directly apply this by handling Path.Data
// : But query build is CPU-dependent work
// : Surface can be accelerate by GPU
// : So if you can, pass transformation by using this
// :
// : nil can be use, it assume Identity matrix
// throw > _
Query(query *Path, shader Shader, transform *Transform) error
// This make free every resource for surface
// It destroy Surface
// Even if Surface call this, it is possible to use Surface in some case(not using external resource like GPU)
// But not recommanded for safety reason
io.Closer
}
type Transform ¶
Transform is matrix for transforming homogeneous vector You can easyly build transform matrix by using this
It can use method chaining [https://en.wikipedia.org/wiki/Method_chaining]
func NewTransform ¶
func NewTransform() *Transform
Example ¶
package main
import (
"fmt"
"github.com/go-gl/mathgl/mgl32"
"github.com/iamGreedy/canvas"
)
func main() {
// Identity matrix
fmt.Println(canvas.NewTransform())
// translation matrix (+5, +5)
fmt.Println(canvas.NewTransform().Translate(mgl32.Vec2{5, 5}))
// Scale (16x, 16x)
fmt.Println(canvas.NewTransform().Scale(mgl32.Vec2{16, 16}))
// Scale and Translate
fmt.Println(canvas.NewTransform().Scale(mgl32.Vec2{16, 16}).Translate(mgl32.Vec2{5, 5}))
// Make (15, 15) to origin Scale (3x, 3x)
fmt.Println(canvas.NewTransform().Pivot(mgl32.Vec2{15, 15}, func(t *canvas.Transform) {
t.Scale(mgl32.Vec2{3, 3})
}))
}
type UseQueryBuffer ¶
type UseQueryBuffer struct{}
Use Flush buffer for performance
= Send
func (UseQueryBuffer) OptionType ¶
func (UseQueryBuffer) OptionType() OptionType
type WaitFlush ¶
type WaitFlush struct{}
Lock until every flushing success
= Send
func (WaitFlush) OptionType ¶
func (WaitFlush) OptionType() OptionType
type Width ¶
type Width int
Get Width
= Read | Write
func (Width) OptionType ¶
func (Width) OptionType() OptionType