gorat

package module
v0.0.0-...-7707c45 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: BSD-3-Clause Imports: 13 Imported by: 15

README

#GoRat Gorat is vector rasterizer for go

##Recommand

  • Need Software(CPU) Rasterizer need for making vector image
  • Need Hareware(GPU) accelated rasterizer writen pure go(opengl(glsl) used, but except that there is no dependency)
  • Need easy to use path rendering libray

##Limitation

  • Hardware accelation need GLSL 4.3+(cause using imageSize, etc)
  • GoRat currently working in progress, all api is unstable
  • There is a lot improvement
  • Hardware(not Software Rasterizer) is pool to multithreading or goroutine it can only used on single thread

##Internal Project ###FWRat It is annoying to prepare the hardware rasterizer yourself. So we offer pre-prepared rasterizer. This requires additional github.com/go-gl/glfw/v3.2/glfw. And Must call oglSupport before load FWRat

###TextRat TextRat is Vector Font path drawer using it use github.com/golang/freetype/truetype for parse ttf font file

TextRat not use prerasterized font instead vector graphic

###oglSupport GoratHardwareRasterizer uses the interface for flexibility. Originally, you need to create the interface yourself, but it provides a predefined interface for github.com/go-gl/gl/v4.3-core/gl that you use the most. This is done to support various versions of the gl version. If you observe only this interface, you can use gorat in vulkan.

##Dependancy

###FWRat

###TextRat

###oglSupport

###Build only

######GoRat was heavily influenced by the golang.org/x/image/vector.

Documentation

Index

Constants

View Source
const (
	HARDWAREPOINTMINCAPACITY = 64
)

Variables

View Source
var ColorFillerModel = color.ModelFunc(func(c color.Color) color.Color {
	r, g, b, a := c.RGBA()
	return ColorFiller{uint8(r >> 8), uint8(g >> 8), uint8(b >> 8), uint8(a >> 8)}
})

Functions

func Clamp

func Clamp(v, min, max float32) float32

func DevSquared

func DevSquared(a, b, c mgl32.Vec2) float32

func Lerp

func Lerp(t float32, p, q mgl32.Vec2) mgl32.Vec2

func Mixing

func Mixing(to, a, b HardwareResult)

func Use

func Use(c Context)

func Vec2

func Vec2(x, y float32) mgl32.Vec2

func Vec4

func Vec4(x, y, z, w float32) mgl32.Vec4

Types

type ColorFiller

type ColorFiller color.RGBA

func NewColorFiller

func NewColorFiller(c color.Color) ColorFiller

func (ColorFiller) RGBA

func (s ColorFiller) RGBA() (r, g, b, a uint32)

type Context

type Context interface {
	Driver() Driver

	LoadStroker() HardwareProgram
	LoadFiller() HardwareProgram
	LoadColor() HardwareProgram
	LoadFixed() HardwareProgram
	LoadGaussian() HardwareProgram
	LoadNearest() HardwareProgram
	LoadNearestNeighbor() HardwareProgram
	LoadRepeat() HardwareProgram
	LoadRepeatHorizontal() HardwareProgram
	LoadRepeatVertical() HardwareProgram

	UnloadStroker(p HardwareProgram)
	UnloadFiller(p HardwareProgram)
	UnloadColor(p HardwareProgram)
	UnloadFixed(p HardwareProgram)
	UnloadGaussian(p HardwareProgram)
	UnloadNearest(p HardwareProgram)
	UnloadNearestNeighbor(p HardwareProgram)
	UnloadRepeat(p HardwareProgram)
	UnloadRepeatHorizontal(p HardwareProgram)
	UnloadRepeatVertical(p HardwareProgram)
	//	utils
	UtilLoadMixing() HardwareProgram
	UtilUnloadMixing(p HardwareProgram)
	// delete
	Delete()
}

func CreateSimpleContext

func CreateSimpleContext(driver Driver) Context

type Driver

type Driver interface {
	Init() error
	Version() (major int, minor int)
	ComputeProgram(source io.Reader) (HardwareProgram, error)
	WorkSpace(w, h int) HardwareWorkspace
	Result(w, h int) HardwareResult
	Bound() HardwareBound
	Color() HardwareColor
	Context() HardwareContext
	Filler(rgba *image.RGBA) HardwareFiller
}

type Filler

type Filler interface {
	// contains filtered or unexported methods
}

func NewImageFiller

func NewImageFiller(i image.Image, mode ImageFillerMode) Filler

type FillerWithBound

type FillerWithBound interface {
	Filler
	// contains filtered or unexported methods
}

type Hardware

type Hardware struct {
	SubHardware
	// contains filtered or unexported fields
}

func NewHardware

func NewHardware(to HardwareResult) *Hardware

func (*Hardware) Setup

func (s *Hardware) Setup(w, h int)

Rasterizer

type HardwareBound

type HardwareBound interface {
	Set(bound image.Rectangle)

	Get() image.Rectangle
	Delete()
}

type HardwareColor

type HardwareColor interface {
	Set(c color.Color)
	Delete()
}

type HardwareContext

type HardwareContext interface {
	Set(p ...mgl32.Vec2)
	Delete()
}

type HardwareFiller

type HardwareFiller interface {
	Delete()
}

type HardwareProgram

type HardwareProgram interface {
	Use()
	BindWorkspace(i int, o HardwareWorkspace)
	BindResult(i int, o HardwareResult)
	BindContext(i int, o HardwareContext)
	BindBound(i int, o HardwareBound)
	BindColor(i int, o HardwareColor)
	BindFiller(i int, o HardwareFiller)
	Compute(x, y, z int)
	Delete()
}

type HardwareResult

type HardwareResult interface {
	Pointer() uint32
	Get() *image.RGBA
	Size() (w, h int)
	Delete()
	Clear()
	RectClear(r image.Rectangle)
	Resize(w, h int)
}

type HardwareWorkspace

type HardwareWorkspace interface {
	Delete()
	Visualize() *image.RGBA
	Clear()
	Size() (w, h int)
	Resize(w, h int)
}

type ImageFillerMode

type ImageFillerMode uint8
const (
	ImageFillerFixed            ImageFillerMode = iota
	ImageFillerNearest          ImageFillerMode = iota
	ImageFillerNearestNeighbor  ImageFillerMode = iota
	ImageFillerGausian          ImageFillerMode = iota
	ImageFillerRepeat           ImageFillerMode = iota
	ImageFillerVerticalRepeat   ImageFillerMode = iota
	ImageFillerHorizontalRepeat ImageFillerMode = iota
)

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) Clone

func (s *Options) Clone() Options

func (*Options) DefaultOption

func (s *Options) DefaultOption()

func (*Options) GetFiller

func (s *Options) GetFiller() Filler

getter

func (*Options) GetStrokeCap

func (s *Options) GetStrokeCap() StrokeCap

func (*Options) GetStrokeColor

func (s *Options) GetStrokeColor() color.Color

func (*Options) GetStrokeJoin

func (s *Options) GetStrokeJoin() StrokeJoin

func (*Options) GetStrokeWidth

func (s *Options) GetStrokeWidth() float32

func (*Options) Restore

func (s *Options) Restore(opt Options)

func (*Options) SetFiller

func (s *Options) SetFiller(f Filler)

setter

func (*Options) SetStrokeCap

func (s *Options) SetStrokeCap(c StrokeCap)

func (*Options) SetStrokeColor

func (s *Options) SetStrokeColor(c color.Color)

func (*Options) SetStrokeJoin

func (s *Options) SetStrokeJoin(j StrokeJoin)

func (*Options) SetStrokeWidth

func (s *Options) SetStrokeWidth(w float32)

type Path

type Path struct {
	// contains filtered or unexported fields
}

import (

"golang.org/vecx/image/math/fixed"
"image/Color"

)

type Rasterizer

type Rasterizer interface {
	Setup(w, h int)
	SubRasterizer
}

type StrokeCap

type StrokeCap uint8
const (
	StrokeCapButt   StrokeCap = iota
	StrokeCapRound  StrokeCap = iota
	StrokeCapSqaure StrokeCap = iota
)

type StrokeJoin

type StrokeJoin uint8
const (
	StrokeJoinBevel StrokeJoin = iota
	StrokeJoinRound StrokeJoin = iota
	StrokeJoinMiter StrokeJoin = iota
)

type SubHardware

type SubHardware struct {
	Options
	// contains filtered or unexported fields
}

func (*SubHardware) Bound

func (s *SubHardware) Bound() image.Rectangle

func (*SubHardware) Clear

func (s *SubHardware) Clear()

func (*SubHardware) CloseTo

func (s *SubHardware) CloseTo()

func (*SubHardware) CubeTo

func (s *SubHardware) CubeTo(pivot1, pivot2, to mgl32.Vec2)

func (*SubHardware) Fill

func (s *SubHardware) Fill()

func (*SubHardware) FillStroke

func (s *SubHardware) FillStroke()

func (*SubHardware) LineTo

func (s *SubHardware) LineTo(to mgl32.Vec2)

func (*SubHardware) MoveTo

func (s *SubHardware) MoveTo(to mgl32.Vec2)

func (*SubHardware) Point

func (s *SubHardware) Point() mgl32.Vec2

func (*SubHardware) PreviousPoint

func (s *SubHardware) PreviousPoint() mgl32.Vec2

func (*SubHardware) QuadTo

func (s *SubHardware) QuadTo(pivot, to mgl32.Vec2)

func (*SubHardware) Reset

func (s *SubHardware) Reset()

func (*SubHardware) Root

func (s *SubHardware) Root() Rasterizer

SubRasterizer

func (*SubHardware) Size

func (s *SubHardware) Size() (w, h float32)

vector drawer

func (*SubHardware) Stroke

func (s *SubHardware) Stroke()

func (*SubHardware) SubRasterizer

func (s *SubHardware) SubRasterizer(r image.Rectangle) SubRasterizer

type SubRasterizer

type SubRasterizer interface {
	Root() Rasterizer
	Bound() image.Rectangle
	SubRasterizer(r image.Rectangle) SubRasterizer
	VectorDrawer
}

type VectorDrawer

type VectorDrawer interface {
	// Infomation
	Size() (w, h float32)
	PreviousPoint() mgl32.Vec2
	Point() mgl32.Vec2
	// Path
	Reset()
	MoveTo(to mgl32.Vec2)
	LineTo(to mgl32.Vec2)
	QuadTo(pivot, to mgl32.Vec2)
	CubeTo(pivot1, pivot2, to mgl32.Vec2)
	CloseTo()
	// Draw
	Clear()
	Stroke()
	Fill()
	FillStroke()
	//
	// Options
	VectorOptions
}

type VectorOptions

type VectorOptions interface {
	DefaultOption()
	Restore(opt Options)
	Clone() Options
	// getter
	GetFiller() Filler
	GetStrokeWidth() float32
	GetStrokeJoin() StrokeJoin
	GetStrokeCap() StrokeCap
	GetStrokeColor() color.Color
	// setter
	SetFiller(f Filler)
	SetStrokeWidth(w float32)
	SetStrokeJoin(j StrokeJoin)
	SetStrokeCap(c StrokeCap)
	SetStrokeColor(c color.Color)
}

Directories

Path Synopsis
oglSupport
v43
v44
v45
TODO : Add DMA support
TODO : Add DMA support
v46
TODO : Add DMA support
TODO : Add DMA support

Jump to

Keyboard shortcuts

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