cairo

package module
v0.0.0-...-b64226d Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: GPL-3.0 Imports: 8 Imported by: 5

README

cairo

cairo binding for golang

Cairo is a 2D graphics library.

Install

Install Cairo
$ sudo apt install libcairo2-dev
Load this package
$ go get github.com/gitchander/cairo

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Antialias

type Antialias int // cairo_antialias_t
const (
	ANTIALIAS_DEFAULT  Antialias = C.CAIRO_ANTIALIAS_DEFAULT
	ANTIALIAS_NONE     Antialias = C.CAIRO_ANTIALIAS_NONE
	ANTIALIAS_GRAY     Antialias = C.CAIRO_ANTIALIAS_GRAY
	ANTIALIAS_SUBPIXEL Antialias = C.CAIRO_ANTIALIAS_SUBPIXEL
	ANTIALIAS_FAST     Antialias = C.CAIRO_ANTIALIAS_FAST
	ANTIALIAS_GOOD     Antialias = C.CAIRO_ANTIALIAS_GOOD
	ANTIALIAS_BEST     Antialias = C.CAIRO_ANTIALIAS_BEST
)

type Canvas

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

func NewCanvas

func NewCanvas(s *Surface) (*Canvas, error)

func NewCanvasNative

func NewCanvasNative(ptr uintptr) (*Canvas, error)

func (*Canvas) Arc

func (c *Canvas) Arc(xc, yc, radius, angle1, angle2 float64)

func (*Canvas) ArcNegative

func (c *Canvas) ArcNegative(xc, yc, radius, angle1, angle2 float64)

func (*Canvas) Circle

func (c *Canvas) Circle(xc, yc float64, radius float64)

func (*Canvas) Clip

func (c *Canvas) Clip()

func (*Canvas) ClipPreserve

func (c *Canvas) ClipPreserve()

func (*Canvas) ClosePath

func (c *Canvas) ClosePath()

func (*Canvas) CopyPage

func (c *Canvas) CopyPage()

func (*Canvas) CurveTo

func (c *Canvas) CurveTo(x1, y1, x2, y2, x3, y3 float64)

func (*Canvas) Destroy

func (c *Canvas) Destroy()

func (*Canvas) Fill

func (c *Canvas) Fill()

func (*Canvas) FillColor

func (c *Canvas) FillColor(cr color.Color)

func (*Canvas) FillPreserve

func (c *Canvas) FillPreserve()

func (*Canvas) GetAntialias

func (c *Canvas) GetAntialias() Antialias

func (*Canvas) GetDashCount

func (c *Canvas) GetDashCount() int

func (*Canvas) GetFillRule

func (c *Canvas) GetFillRule() FillRule

func (*Canvas) GetGroupTarget

func (c *Canvas) GetGroupTarget() *Surface

func (*Canvas) GetLineCap

func (c *Canvas) GetLineCap() LineCap

func (*Canvas) GetLineJoin

func (c *Canvas) GetLineJoin() LineJoin

func (*Canvas) GetLineWidth

func (c *Canvas) GetLineWidth() float64

func (*Canvas) GetMatrix

func (c *Canvas) GetMatrix(matrix *Matrix)

func (*Canvas) GetMiterLimit

func (c *Canvas) GetMiterLimit() float64

func (*Canvas) GetOperator

func (c *Canvas) GetOperator() Operator

func (*Canvas) GetReferenceCount

func (c *Canvas) GetReferenceCount() uint

func (*Canvas) GetSource

func (c *Canvas) GetSource() *Pattern

func (*Canvas) GetTarget

func (c *Canvas) GetTarget() *Surface

func (*Canvas) GetTolerance

func (c *Canvas) GetTolerance() float64

func (*Canvas) IdentityMatrix

func (c *Canvas) IdentityMatrix()

func (*Canvas) InClip

func (c *Canvas) InClip(x, y float64) bool

func (*Canvas) InFill

func (c *Canvas) InFill(x, y float64) bool

func (*Canvas) InStroke

func (c *Canvas) InStroke(x, y float64) bool

func (*Canvas) LineTo

func (c *Canvas) LineTo(x, y float64)

func (*Canvas) MoveTo

func (c *Canvas) MoveTo(x, y float64)

------------------------------------------

func (*Canvas) Native

func (c *Canvas) Native() uintptr

Native returns native cairo context

func (*Canvas) NewPath

func (c *Canvas) NewPath()

func (*Canvas) NewSubPath

func (c *Canvas) NewSubPath()

func (*Canvas) Paint

func (c *Canvas) Paint()

func (*Canvas) PaintWithAlpha

func (c *Canvas) PaintWithAlpha(alpha float64)

func (*Canvas) PushGroup

func (c *Canvas) PushGroup()

func (*Canvas) PushGroupWithContent

func (c *Canvas) PushGroupWithContent(content Content)

func (*Canvas) Rectangle

func (c *Canvas) Rectangle(x, y, width, height float64)

func (*Canvas) Reference

func (c *Canvas) Reference() *Canvas

func (*Canvas) RelLineTo

func (c *Canvas) RelLineTo(dx, dy float64)

func (*Canvas) ResetClip

func (c *Canvas) ResetClip()

func (*Canvas) Restore

func (c *Canvas) Restore()

func (*Canvas) Rotate

func (c *Canvas) Rotate(angle float64)

func (*Canvas) Save

func (c *Canvas) Save()

func (*Canvas) Scale

func (c *Canvas) Scale(sx, sy float64)

func (*Canvas) SelectFontFace

func (c *Canvas) SelectFontFace(family string, fontSlant FontSlant, fontWeight FontWeight)

func (*Canvas) SetAntialias

func (c *Canvas) SetAntialias(antialias Antialias)

func (*Canvas) SetDash

func (c *Canvas) SetDash(dashes []float64, offset float64)

func (*Canvas) SetFillRule

func (c *Canvas) SetFillRule(fillRule FillRule)

func (*Canvas) SetFontSize

func (c *Canvas) SetFontSize(size float64)

func (*Canvas) SetLineCap

func (c *Canvas) SetLineCap(lineCap LineCap)

func (*Canvas) SetLineJoin

func (c *Canvas) SetLineJoin(lineJoin LineJoin)

func (*Canvas) SetLineWidth

func (c *Canvas) SetLineWidth(width float64)

func (*Canvas) SetMatrix

func (c *Canvas) SetMatrix(matrix *Matrix)

func (*Canvas) SetMiterLimit

func (c *Canvas) SetMiterLimit(limit float64)

func (*Canvas) SetOperator

func (c *Canvas) SetOperator(operator Operator)

func (*Canvas) SetSource

func (c *Canvas) SetSource(p *Pattern)

func (*Canvas) SetSourceColor

func (c *Canvas) SetSourceColor(cr color.Color)

------------------------------------------------------------------------------

func (*Canvas) SetSourceRGB

func (c *Canvas) SetSourceRGB(red, green, blue float64)

func (*Canvas) SetSourceRGBA

func (c *Canvas) SetSourceRGBA(red, green, blue, alpha float64)

func (*Canvas) SetSourceSurface

func (c *Canvas) SetSourceSurface(s *Surface, x, y float64)

func (*Canvas) SetTolerance

func (c *Canvas) SetTolerance(tolerance float64)

func (*Canvas) ShowPage

func (c *Canvas) ShowPage()

func (*Canvas) ShowText

func (c *Canvas) ShowText(text string)

func (*Canvas) Status

func (c *Canvas) Status() Status

func (*Canvas) Stroke

func (c *Canvas) Stroke()

func (*Canvas) StrokePreserve

func (c *Canvas) StrokePreserve()

func (*Canvas) TextExtents

func (c *Canvas) TextExtents(text string, textExtents *TextExtents)

func (*Canvas) TextPath

func (c *Canvas) TextPath(text string)

func (*Canvas) Transform

func (c *Canvas) Transform(matrix *Matrix)

func (*Canvas) Translate

func (c *Canvas) Translate(tx, ty float64)

type Content

type Content int // cairo_content_t
const (
	CONTENT_COLOR       Content = C.CAIRO_CONTENT_COLOR
	CONTENT_ALPHA       Content = C.CAIRO_CONTENT_ALPHA
	CONTENT_COLOR_ALPHA Content = C.CAIRO_CONTENT_COLOR_ALPHA
)

type Extend

type Extend int // cairo_extend_t
const (
	EXTEND_NONE    Extend = C.CAIRO_EXTEND_NONE
	EXTEND_REPEAT  Extend = C.CAIRO_EXTEND_REPEAT
	EXTEND_REFLECT Extend = C.CAIRO_EXTEND_REFLECT
	EXTEND_PAD     Extend = C.CAIRO_EXTEND_PAD
)

type FillRule

type FillRule int // cairo_fill_rule_t
const (
	FILL_RULE_WINDING  FillRule = C.CAIRO_FILL_RULE_WINDING
	FILL_RULE_EVEN_ODD FillRule = C.CAIRO_FILL_RULE_EVEN_ODD
)

type FontSlant

type FontSlant int // cairo_font_slant_t
const (
	FONT_SLANT_NORMAL  FontSlant = C.CAIRO_FONT_SLANT_NORMAL
	FONT_SLANT_ITALIC  FontSlant = C.CAIRO_FONT_SLANT_ITALIC
	FONT_SLANT_OBLIQUE FontSlant = C.CAIRO_FONT_SLANT_OBLIQUE
)

type FontWeight

type FontWeight int // cairo_font_weight_t
const (
	FONT_WEIGHT_NORMAL FontWeight = C.CAIRO_FONT_WEIGHT_NORMAL
	FONT_WEIGHT_BOLD   FontWeight = C.CAIRO_FONT_WEIGHT_BOLD
)

type Format

type Format int // cairo_format_t
const (
	FORMAT_INVALID   Format = C.CAIRO_FORMAT_INVALID
	FORMAT_ARGB32    Format = C.CAIRO_FORMAT_ARGB32
	FORMAT_RGB24     Format = C.CAIRO_FORMAT_RGB24
	FORMAT_A8        Format = C.CAIRO_FORMAT_A8
	FORMAT_A1        Format = C.CAIRO_FORMAT_A1
	FORMAT_RGB16_565 Format = C.CAIRO_FORMAT_RGB16_565
	FORMAT_RGB30     Format = C.CAIRO_FORMAT_RGB30
)

type LineCap

type LineCap int // cairo_line_cap_t
const (
	LINE_CAP_BUTT   LineCap = C.CAIRO_LINE_CAP_BUTT
	LINE_CAP_ROUND  LineCap = C.CAIRO_LINE_CAP_ROUND
	LINE_CAP_SQUARE LineCap = C.CAIRO_LINE_CAP_SQUARE
)

type LineJoin

type LineJoin int // cairo_line_join_t
const (
	LINE_JOIN_MITER LineJoin = C.CAIRO_LINE_JOIN_MITER
	LINE_JOIN_ROUND LineJoin = C.CAIRO_LINE_JOIN_ROUND
	LINE_JOIN_BEVEL LineJoin = C.CAIRO_LINE_JOIN_BEVEL
)

type Matrix

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

func NewMatrix

func NewMatrix() *Matrix

func (*Matrix) Init

func (m *Matrix) Init(xx, yx, xy, yy, x0, y0 float64)

func (*Matrix) InitIdendity

func (m *Matrix) InitIdendity()

func (*Matrix) InitRotate

func (m *Matrix) InitRotate(radians float64)

func (*Matrix) InitScale

func (m *Matrix) InitScale(sx, sy float64)

func (*Matrix) InitTranslate

func (m *Matrix) InitTranslate(tx, ty float64)

func (*Matrix) Invert

func (m *Matrix) Invert() Status

func (*Matrix) Multiply

func (m *Matrix) Multiply(a, b *Matrix)

func (*Matrix) Rotate

func (m *Matrix) Rotate(radians float64)

func (*Matrix) Scale

func (m *Matrix) Scale(sx, sy float64)

func (*Matrix) TransformDistance

func (m *Matrix) TransformDistance(dx, dy float64) (float64, float64)

func (*Matrix) TransformPoint

func (m *Matrix) TransformPoint(x, y float64) (float64, float64)

func (*Matrix) Translate

func (m *Matrix) Translate(tx, ty float64)

type Operator

type Operator int // cairo_operator_t
const (
	OPERATOR_CLEAR          Operator = C.CAIRO_OPERATOR_CLEAR
	OPERATOR_SOURCE         Operator = C.CAIRO_OPERATOR_SOURCE
	OPERATOR_OVER           Operator = C.CAIRO_OPERATOR_OVER
	OPERATOR_IN             Operator = C.CAIRO_OPERATOR_IN
	OPERATOR_OUT            Operator = C.CAIRO_OPERATOR_OUT
	OPERATOR_ATOP           Operator = C.CAIRO_OPERATOR_ATOP
	OPERATOR_DEST           Operator = C.CAIRO_OPERATOR_DEST
	OPERATOR_DEST_OVER      Operator = C.CAIRO_OPERATOR_DEST_OVER
	OPERATOR_DEST_IN        Operator = C.CAIRO_OPERATOR_DEST_IN
	OPERATOR_DEST_OUT       Operator = C.CAIRO_OPERATOR_DEST_OUT
	OPERATOR_DEST_ATOP      Operator = C.CAIRO_OPERATOR_DEST_ATOP
	OPERATOR_XOR            Operator = C.CAIRO_OPERATOR_XOR
	OPERATOR_ADD            Operator = C.CAIRO_OPERATOR_ADD
	OPERATOR_SATURATE       Operator = C.CAIRO_OPERATOR_SATURATE
	OPERATOR_MULTIPLY       Operator = C.CAIRO_OPERATOR_MULTIPLY
	OPERATOR_SCREEN         Operator = C.CAIRO_OPERATOR_SCREEN
	OPERATOR_OVERLAY        Operator = C.CAIRO_OPERATOR_OVERLAY
	OPERATOR_DARKEN         Operator = C.CAIRO_OPERATOR_DARKEN
	OPERATOR_LIGHTEN        Operator = C.CAIRO_OPERATOR_LIGHTEN
	OPERATOR_COLOR_DODGE    Operator = C.CAIRO_OPERATOR_COLOR_DODGE
	OPERATOR_COLOR_BURN     Operator = C.CAIRO_OPERATOR_COLOR_BURN
	OPERATOR_HARD_LIGHT     Operator = C.CAIRO_OPERATOR_HARD_LIGHT
	OPERATOR_SOFT_LIGHT     Operator = C.CAIRO_OPERATOR_SOFT_LIGHT
	OPERATOR_DIFFERENCE     Operator = C.CAIRO_OPERATOR_DIFFERENCE
	OPERATOR_EXCLUSION      Operator = C.CAIRO_OPERATOR_EXCLUSION
	OPERATOR_HSL_HUE        Operator = C.CAIRO_OPERATOR_HSL_HUE
	OPERATOR_HSL_SATURATION Operator = C.CAIRO_OPERATOR_HSL_SATURATION
	OPERATOR_HSL_COLOR      Operator = C.CAIRO_OPERATOR_HSL_COLOR
	OPERATOR_HSL_LUMINOSITY Operator = C.CAIRO_OPERATOR_HSL_LUMINOSITY
)

type Pattern

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

func NewPatternForSurface

func NewPatternForSurface(s *Surface) (*Pattern, error)

func NewPatternLinear

func NewPatternLinear(x0, y0, x1, y1 float64) (*Pattern, error)

func NewPatternNative

func NewPatternNative(ptr uintptr) (*Pattern, error)

func NewPatternRadial

func NewPatternRadial(cx0, cy0, radius0, cx1, cy1, radius1 float64) (*Pattern, error)

func (*Pattern) AddColorStopRGB

func (p *Pattern) AddColorStopRGB(offset, red, green, blue float64)

func (*Pattern) AddColorStopRGBA

func (p *Pattern) AddColorStopRGBA(offset, red, green, blue, alpha float64)

func (*Pattern) Destroy

func (p *Pattern) Destroy()

func (*Pattern) Native

func (p *Pattern) Native() uintptr

func (*Pattern) Reference

func (p *Pattern) Reference() *Pattern

func (*Pattern) SetExtend

func (p *Pattern) SetExtend(extend Extend)

func (*Pattern) SetMatrix

func (p *Pattern) SetMatrix(m *Matrix)

type Status

type Status int // cairo_status_t
const (
	STATUS_SUCCESS                   Status = C.CAIRO_STATUS_SUCCESS
	STATUS_NO_MEMORY                 Status = C.CAIRO_STATUS_NO_MEMORY
	STATUS_INVALID_RESTORE           Status = C.CAIRO_STATUS_INVALID_RESTORE
	STATUS_INVALID_POP_GROUP         Status = C.CAIRO_STATUS_INVALID_POP_GROUP
	STATUS_NO_CURRENT_POINT          Status = C.CAIRO_STATUS_NO_CURRENT_POINT
	STATUS_INVALID_MATRIX            Status = C.CAIRO_STATUS_INVALID_MATRIX
	STATUS_INVALID_STATUS            Status = C.CAIRO_STATUS_INVALID_STATUS
	STATUS_NULL_POINTER              Status = C.CAIRO_STATUS_NULL_POINTER
	STATUS_INVALID_STRING            Status = C.CAIRO_STATUS_INVALID_STRING
	STATUS_INVALID_PATH_DATA         Status = C.CAIRO_STATUS_INVALID_PATH_DATA
	STATUS_READ_ERROR                Status = C.CAIRO_STATUS_READ_ERROR
	STATUS_WRITE_ERROR               Status = C.CAIRO_STATUS_WRITE_ERROR
	STATUS_SURFACE_FINISHED          Status = C.CAIRO_STATUS_SURFACE_FINISHED
	STATUS_SURFACE_TYPE_MISMATCH     Status = C.CAIRO_STATUS_SURFACE_TYPE_MISMATCH
	STATUS_PATTERN_TYPE_MISMATCH     Status = C.CAIRO_STATUS_PATTERN_TYPE_MISMATCH
	STATUS_INVALID_CONTENT           Status = C.CAIRO_STATUS_INVALID_CONTENT
	STATUS_INVALID_FORMAT            Status = C.CAIRO_STATUS_INVALID_FORMAT
	STATUS_INVALID_VISUAL            Status = C.CAIRO_STATUS_INVALID_VISUAL
	STATUS_FILE_NOT_FOUND            Status = C.CAIRO_STATUS_FILE_NOT_FOUND
	STATUS_INVALID_DASH              Status = C.CAIRO_STATUS_INVALID_DASH
	STATUS_INVALID_DSC_COMMENT       Status = C.CAIRO_STATUS_INVALID_DSC_COMMENT
	STATUS_INVALID_INDEX             Status = C.CAIRO_STATUS_INVALID_INDEX
	STATUS_CLIP_NOT_REPRESENTABLE    Status = C.CAIRO_STATUS_CLIP_NOT_REPRESENTABLE
	STATUS_TEMP_FILE_ERROR           Status = C.CAIRO_STATUS_TEMP_FILE_ERROR
	STATUS_INVALID_STRIDE            Status = C.CAIRO_STATUS_INVALID_STRIDE
	STATUS_FONT_TYPE_MISMATCH        Status = C.CAIRO_STATUS_FONT_TYPE_MISMATCH
	STATUS_USER_FONT_IMMUTABLE       Status = C.CAIRO_STATUS_USER_FONT_IMMUTABLE
	STATUS_USER_FONT_ERROR           Status = C.CAIRO_STATUS_USER_FONT_ERROR
	STATUS_NEGATIVE_COUNT            Status = C.CAIRO_STATUS_NEGATIVE_COUNT
	STATUS_INVALID_CLUSTERS          Status = C.CAIRO_STATUS_INVALID_CLUSTERS
	STATUS_INVALID_SLANT             Status = C.CAIRO_STATUS_INVALID_SLANT
	STATUS_INVALID_WEIGHT            Status = C.CAIRO_STATUS_INVALID_WEIGHT
	STATUS_INVALID_SIZE              Status = C.CAIRO_STATUS_INVALID_SIZE
	STATUS_USER_FONT_NOT_IMPLEMENTED Status = C.CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
	STATUS_DEVICE_TYPE_MISMATCH      Status = C.CAIRO_STATUS_DEVICE_TYPE_MISMATCH
	STATUS_DEVICE_ERROR              Status = C.CAIRO_STATUS_DEVICE_ERROR
)

func (Status) String

func (s Status) String() string

type Surface

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

func CreateSurfaceForData

func CreateSurfaceForData(data []byte, format Format, width, height, stride int) (*Surface, error)

func NewSurface

func NewSurface(format Format, width, height int) (*Surface, error)

func NewSurfaceFromPNG

func NewSurfaceFromPNG(fileName string) (*Surface, error)

func NewSurfaceNative

func NewSurfaceNative(ptr uintptr) (*Surface, error)

func (*Surface) Destroy

func (s *Surface) Destroy()

func (*Surface) Finish

func (s *Surface) Finish()

func (*Surface) Flush

func (s *Surface) Flush()

func (*Surface) GetData

func (s *Surface) GetData(data []byte) error

func (*Surface) GetDataLength

func (s *Surface) GetDataLength() int

func (*Surface) GetFormat

func (s *Surface) GetFormat() Format

func (*Surface) GetHeight

func (s *Surface) GetHeight() int

func (*Surface) GetStride

func (s *Surface) GetStride() int

func (*Surface) GetWidth

func (s *Surface) GetWidth() int

func (*Surface) MarkDirty

func (s *Surface) MarkDirty()

func (*Surface) Native

func (s *Surface) Native() uintptr

func (*Surface) Reference

func (s *Surface) Reference() *Surface

func (*Surface) SetData

func (s *Surface) SetData(data []byte) error

func (*Surface) WriteToPNG

func (s *Surface) WriteToPNG(fileName string) error

type TextExtents

type TextExtents struct {
	BearingX float64
	BearingY float64
	Width    float64
	Height   float64
	AdvanceX float64
	AdvanceY float64
}

Directories

Path Synopsis
examples
hw1
hw2

Jump to

Keyboard shortcuts

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