Documentation ¶
Index ¶
- Constants
- type Axis
- type CleanupTransform
- type DedupSegmentsTransform
- type HSliceTransform
- type JoinTransform
- type MatrixTransform
- type MirrorTransform
- type MoveTransform
- type OffsetTransform
- type PathReverse
- type RebuildTransform
- type ReorderTransform
- type RotateScaleTransform
- type RotateTransform
- type ScaleTransform
- type SegmentReverse
- type ShiftTransform
- type SimpleJoin
- type SizeShouldBe
- type TrimWhitespaceTransform
Constants ¶
const ( Unknown = iota Smaller Larger )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupTransform ¶
type CleanupTransform struct {
Precision int
}
func (CleanupTransform) PathTransform ¶
cleans up the path.
- make sure the first operation is a move
- Insert a Move if the segment Start is not the same as the segment end of the previous
- align start and end if they are not equal, but within precision
- Check for NaN
type DedupSegmentsTransform ¶
type DedupSegmentsTransform struct {
Precision int
}
func (DedupSegmentsTransform) PathTransform ¶
this will remove any redundant operations. currently:
- collapse multiple MOVEs in a row
- Remove a MOVE to the current location
- if prev segment is the same as the reverse of the current segment, remove both TODO: should this be split into a its own transform? I wonder if this is ever the intent?
type HSliceTransform ¶
type HSliceTransform struct { Y float64 SegmentOperators path.SegmentOperators Precision int }
Cut the path horizontally at the given Y coordinate, removes everything above Y
func (HSliceTransform) PathTransform ¶
type JoinTransform ¶
type JoinTransform struct { Precision int SegmentOperators path.SegmentOperators // should we close the path? ClosePath bool }
connects any disjoint segments as smoothly as possible
func (JoinTransform) PathTransform ¶
type MatrixTransform ¶
type MatrixTransform struct {
A, B, C, D, E, F float64
SegmentOperators path.SegmentOperators
}
A basic affine (matrix) transform see: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#General_Transformation
func (MatrixTransform) PathTransform ¶
func (MatrixTransform) TransformPoint ¶
func (mt MatrixTransform) TransformPoint(p path.Point) path.Point
type MirrorTransform ¶
type MirrorTransform struct { Axis Axis Handle path.PathAttr SegmentOperators path.SegmentOperators }
This moves the path origin to the requested point
func (MirrorTransform) PathTransform ¶
type MoveTransform ¶
type MoveTransform struct { Point path.Point // if a handle is specified, than this move operation will move the // handle to the requested point. by default the handle is the topleft Handle path.PathAttr SegmentOperators path.SegmentOperators }
This moves the path origin to the requested point
func (MoveTransform) PathTransform ¶
type OffsetTransform ¶
type OffsetTransform struct { Precision int Distance float64 SegmentOperators path.SegmentOperators SizeShouldBe SizeShouldBe }
func (OffsetTransform) PathTransform ¶
Transforms the path into an offset path at distance If distance is 0 than this transform does nothing.
type RebuildTransform ¶
type RebuildTransform struct{}
func (RebuildTransform) PathTransform ¶
Simple transform to rebuild the path. this dumps the path to a string and reparses mostly this is for cleaning datastructure problems from other transforms (I.E internal changes mean start and end points don't align)
type ReorderTransform ¶
type ReorderTransform struct {
Precision int
}
func (ReorderTransform) PathTransform ¶
Transform that will reorder any sections that start and end at the same place
type RotateScaleTransform ¶
type RotateScaleTransform struct { StartPoint path.Point EndPoint path.Point // What point on the path should be considered origin? // defaults to path start PathStartPoint path.Point // What point on the path should be considered the end? // defaults to path end PathEndPoint path.Point SegmentOperators path.SegmentOperators }
Will rotate and scale the path so that the PathStartPoint and PathEndPoint equal StartPoint and EndPoint. This is useful for using svg to connect two points
func (RotateScaleTransform) PathTransform ¶
type RotateTransform ¶
type RotateTransform struct { Degrees float64 Axis path.PathAttr SegmentOperators path.SegmentOperators }
func (RotateTransform) PathTransform ¶
func (RotateTransform) PathTransformWithAxis ¶
type ScaleTransform ¶
type ScaleTransform struct { ScaleX float64 ScaleY float64 // TODO: Scaling by start and end point should // use the rotate_scale transform. StartPoint path.Point EndPoint path.Point Width float64 Height float64 SegmentOperators path.SegmentOperators }
This changes the size and proportions of the given path
func (ScaleTransform) PathTransform ¶
type SegmentReverse ¶
type SegmentReverse struct { }
func (SegmentReverse) SegmentTransform ¶
func (s SegmentReverse) SegmentTransform(segment path.Segment) path.Segment
Reverses a single segment. Note that this flips the segment, but will need a Move to start if you expect it to render properly within a path
type ShiftTransform ¶
type ShiftTransform struct { DeltaX float64 DeltaY float64 SegmentOperators path.SegmentOperators }
This shifts the path by the requested amount in X and/or Y
func (ShiftTransform) PathTransform ¶
type SimpleJoin ¶
type SimpleJoin struct { }
type SizeShouldBe ¶
type SizeShouldBe int
type TrimWhitespaceTransform ¶
type TrimWhitespaceTransform struct {
SegmentOperators path.SegmentOperators
}
func (TrimWhitespaceTransform) PathTransform ¶
PathTransform trims any whitespace by moving the path to as close to 0,0 as possible. Note that you should typically call simplify before triming whitespace to avoid things like M 0 0, M 10, 11