encoding

package
v0.0.0-...-e2d5c53 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 0 for a fill, 1 for a stroke
	FlagsStyleBit uint32 = 0x8000_0000

	// 0 for non-zero, 1 for even-odd
	FlagsFillBit uint32 = 0x4000_0000

	// Encodings for join style:
	//    - 0b00 -> bevel
	//    - 0b01 -> miter
	//    - 0b10 -> round
	FlagsJoinBitsBevel uint32 = 0
	FlagsJoinBitsMiter uint32 = 0x1000_0000
	FlagsJoinBitsRound uint32 = 0x2000_0000
	FlagsJoinMask      uint32 = 0x3000_0000

	FlagsCapBitsSquare uint32 = 0x0100_0000
	FlagsCapBitsRound  uint32 = 0x0200_0000

	FlagsStartCapMask uint32 = 0x0C00_0000
	FlagsEndCapMask   uint32 = 0x0300_0000
	MiterLimitMask    uint32 = 0xFFFF
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DrawTag

type DrawTag uint32
const (
	// No operation.
	DrawTagNop DrawTag = 0

	// Color fill.
	DrawTagColor DrawTag = 0x50

	// Linear gradient fill.
	DrawTagLinearGradient DrawTag = 0x114

	// Radial gradient fill.
	DrawTagRadialGradient DrawTag = 0x29c

	// Sweep gradient fill.
	DrawTagSweepGradient DrawTag = 0x254

	// Image fill.
	DrawTagImage DrawTag = 0x248

	// Begin layer/clip.
	DrawTagBeginClip DrawTag = 0x9

	// End layer/clip.
	DrawTagEndClip DrawTag = 0x21
)

func (DrawTag) InfoSize

func (tag DrawTag) InfoSize() uint32

type Encoding

type Encoding struct {
	PathTags        []PathTag
	PathData        []byte
	DrawTags        []DrawTag
	DrawData        []byte
	Transforms      []jmath.Transform
	Styles          []Style
	Resources       Resources
	NumPaths        uint32
	NumPathSegments uint32
	NumClips        uint32
	NumOpenClips    uint32
	Flags           uint32
}

func (*Encoding) Append

func (enc *Encoding) Append(other *Encoding, transform jmath.Transform)

func (*Encoding) ApplyTransform

func (enc *Encoding) ApplyTransform(transform jmath.Transform)

func (*Encoding) EncodeBeginClip

func (enc *Encoding) EncodeBeginClip(blendMode gfx.BlendMode, alpha float32)

func (*Encoding) EncodeBrush

func (enc *Encoding) EncodeBrush(b gfx.Brush, alpha float32)

func (*Encoding) EncodeColor

func (enc *Encoding) EncodeColor(color drawColor)

func (*Encoding) EncodeEmptyShape

func (enc *Encoding) EncodeEmptyShape()

EncodeEmptyShape encodes an empty path.

This is useful for bookkeeping when a path is absolutely required (for example in pushing a clip layer). It is almost always the case, however, that an application can be optimized to not use this method.

func (*Encoding) EncodeEndClip

func (enc *Encoding) EncodeEndClip()

func (*Encoding) EncodeFillStyle

func (enc *Encoding) EncodeFillStyle(fill gfx.Fill)

func (*Encoding) EncodeImage

func (enc *Encoding) EncodeImage(img gfx.Image, alpha float32)

func (*Encoding) EncodeLinearGradient

func (enc *Encoding) EncodeLinearGradient(
	gradient drawLinearGradient,
	colorStops []gfx.ColorStop,
	alpha float32,
	extend gfx.Extend,
)

func (*Encoding) EncodePath

func (enc *Encoding) EncodePath(path curve.BezPath, isFill bool) bool

func (*Encoding) EncodeRadialGradient

func (enc *Encoding) EncodeRadialGradient(
	gradient drawRadialGradient,
	colorStops []gfx.ColorStop,
	alpha float32,
	extend gfx.Extend,
)

func (*Encoding) EncodeStrokeStyle

func (enc *Encoding) EncodeStrokeStyle(stroke curve.Stroke)

func (*Encoding) EncodeStyle

func (enc *Encoding) EncodeStyle(style Style)

func (*Encoding) EncodeSweepGradient

func (enc *Encoding) EncodeSweepGradient(
	gradient drawSweepGradient,
	colorStops []gfx.ColorStop,
	alpha float32,
	extend gfx.Extend,
)

func (*Encoding) EncodeTransform

func (enc *Encoding) EncodeTransform(transform jmath.Transform) bool

func (*Encoding) ForceNextTransformAndStyle

func (enc *Encoding) ForceNextTransformAndStyle()

func (*Encoding) IsEmpty

func (enc *Encoding) IsEmpty() bool

func (*Encoding) Reset

func (enc *Encoding) Reset()

func (*Encoding) StreamOffsets

func (enc *Encoding) StreamOffsets() StreamOffsets

func (*Encoding) SwapLastPathTags

func (enc *Encoding) SwapLastPathTags()

type ImagePatch

type ImagePatch struct {
	DrawDataOffset int
	Image          gfx.Image
}

type Patch

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

type PathTag

type PathTag uint8
const (
	// 32-bit floating point line segment.
	//
	// This is equivalent to `(PathSegmentType::LineTo | PathTag::F32_BIT)`.
	PathTagLineToF32 PathTag = 0x9

	// 32-bit floating point quadratic segment.
	//
	// This is equivalent to `(PathSegmentType::QUAD_TO | PathTag::F32_BIT)`.
	PathTagQuadToF32 PathTag = 0xa

	// 32-bit floating point cubic segment.
	//
	// This is equivalent to `(PathSegmentType::CUBIC_TO | PathTag::F32_BIT)`.
	PathTagCubicToF32 PathTag = 0xb

	// 16-bit integral line segment.
	PathTagLineToI16 PathTag = 0x1

	// 16-bit integral quadratic segment.
	PathTagQuadToI16 PathTag = 0x2

	// 16-bit integral cubic segment.
	PathTagCubicToI16 PathTag = 0x3

	// Transform marker.
	PathTagTransform PathTag = 0x20

	// Path marker.
	PathTagPath PathTag = 0x10

	// Style setting.
	PathTagStyle PathTag = 0x40

	// Bit that marks a segment that is the end of a subpath.
	PathTagSubpathEndBit PathTag = 0x4

	// Bit for path segments that are represented as f32 values. If unset
	// they are represented as i16.
	PathTagF32Bit PathTag = 0x8

	// Mask for bottom 3 bits that contain the [`PathSegmentType`].
	PathTagSegmentMask PathTag = 0x3
)

type RampPatch

type RampPatch struct {
	DrawDataOffset int
	Stops          [2]int
	Extend         gfx.Extend
}

type Resources

type Resources struct {
	Patches    []Patch
	ColorStops []gfx.ColorStop
}

func (*Resources) Reset

func (r *Resources) Reset()

type StreamOffsets

type StreamOffsets struct {
	// Current length of path tag stream.
	PathTags int
	// Current length of path data stream.
	PathData int
	// Current length of draw tag stream.
	DrawTags int
	// Current length of draw data stream.
	DrawData int
	// Current length of transform stream.
	Transforms int
	// Current length of style stream.
	Styles int
}

func (StreamOffsets) Add

type Style

type Style struct {

	// Encodes the stroke and fill style parameters. This field is split into two 16-bit
	// parts:
	//
	// - `flags: u16` - encodes fill vs stroke, even-odd vs non-zero fill mode for fills and cap
	//                  and join style for strokes. See the FLAGS_* constants below for more
	//                  information.
	// “`text
	// flags: |style|fill|join|start cap|end cap|reserved|
	//  bits:  0     1    2-3  4-5       6-7     8-15
	// “`
	//
	// - `miter_limit: u16` - The miter limit for a stroke, encoded in binary16 (half) floating
	//                        point representation. This field is only meaningful for the
	//                        `Join::Miter` join style. It's ignored for other stroke styles and
	//                        fills.
	FlagsAndMiterLimits uint32
	LineWidth           float32
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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