heavyfishdesign: github.com/dustismo/heavyfishdesign/transforms Index | Files

package transforms

import "github.com/dustismo/heavyfishdesign/transforms"


Package Files

cleanup.go dedup.go join.go matrix.go mirror.go move.go offset.go path_reorder.go rebuild.go reverse.go rotate.go rotate_scale.go scale.go shift.go slice.go trim_whitespace.go


const (
    Unknown = iota

type Axis Uses

type Axis int
const (
    Horizontal Axis = iota

type CleanupTransform Uses

type CleanupTransform struct {
    Precision int

func (CleanupTransform) PathTransform Uses

func (st CleanupTransform) PathTransform(p path.Path) (path.Path, error)

cleans up the path. 1. make sure the first operation is a move 2. Insert a Move if the segment Start is not the same as the segment end of the


3. align start and end if they are not equal, but within precision 4. Check for NaN

type DedupSegmentsTransform Uses

type DedupSegmentsTransform struct {
    Precision int

func (DedupSegmentsTransform) PathTransform Uses

func (st DedupSegmentsTransform) PathTransform(p path.Path) (path.Path, error)

this will remove any redundant operations. currently: 1. collapse multiple MOVEs in a row 2. Remove a MOVE to the current location 3. 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 Uses

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 Uses

func (hs HSliceTransform) PathTransform(p path.Path) (path.Path, error)

type JoinTransform Uses

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 Uses

func (jt JoinTransform) PathTransform(pth path.Path) (path.Path, error)

type MatrixTransform Uses

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 Uses

func (mt MatrixTransform) PathTransform(p path.Path) (path.Path, error)

func (MatrixTransform) TransformPoint Uses

func (mt MatrixTransform) TransformPoint(p path.Point) path.Point

type MirrorTransform Uses

type MirrorTransform struct {
    Axis             Axis
    Handle           path.PathAttr
    SegmentOperators path.SegmentOperators

This moves the path origin to the requested point

func (MirrorTransform) PathTransform Uses

func (mt MirrorTransform) PathTransform(p path.Path) (path.Path, error)

type MoveTransform Uses

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 Uses

func (mt MoveTransform) PathTransform(p path.Path) (path.Path, error)

type OffsetTransform Uses

type OffsetTransform struct {
    Precision        int
    Distance         float64
    SegmentOperators path.SegmentOperators
    SizeShouldBe     SizeShouldBe

func (OffsetTransform) PathTransform Uses

func (ofs OffsetTransform) PathTransform(p path.Path) (path.Path, error)

Transforms the path into an offset path at distance If distance is 0 than this transform does nothing.

type PathReverse Uses

type PathReverse struct {

func (PathReverse) PathTransform Uses

func (pr PathReverse) PathTransform(p path.Path) (path.Path, error)

type RebuildTransform Uses

type RebuildTransform struct{}

func (RebuildTransform) PathTransform Uses

func (st RebuildTransform) PathTransform(p path.Path) (path.Path, error)

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 Uses

type ReorderTransform struct {
    Precision int

func (ReorderTransform) PathTransform Uses

func (st ReorderTransform) PathTransform(p path.Path) (path.Path, error)

Transform that will reorder any sections that start and end at the same place

type RotateScaleTransform Uses

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 Uses

func (rt RotateScaleTransform) PathTransform(p path.Path) (path.Path, error)

type RotateTransform Uses

type RotateTransform struct {
    Degrees          float64
    Axis             path.PathAttr
    SegmentOperators path.SegmentOperators

func (RotateTransform) PathTransform Uses

func (rt RotateTransform) PathTransform(p path.Path) (path.Path, error)

func (RotateTransform) PathTransformWithAxis Uses

func (rt RotateTransform) PathTransformWithAxis(pth path.Path, axisPoint path.Point) (path.Path, error)

type ScaleTransform Uses

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 Uses

func (st ScaleTransform) PathTransform(p path.Path) (path.Path, error)

type SegmentReverse Uses

type SegmentReverse struct {

func (SegmentReverse) SegmentTransform Uses

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 Uses

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 Uses

func (st ShiftTransform) PathTransform(p path.Path) (path.Path, error)

type SimpleJoin Uses

type SimpleJoin struct {

func (SimpleJoin) JoinPaths Uses

func (sj SimpleJoin) JoinPaths(paths ...path.Path) path.Path

type SizeShouldBe Uses

type SizeShouldBe int

type TrimWhitespaceTransform Uses

type TrimWhitespaceTransform struct {
    SegmentOperators path.SegmentOperators

func (TrimWhitespaceTransform) PathTransform Uses

func (tw TrimWhitespaceTransform) PathTransform(p path.Path) (path.Path, error)

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

Package transforms imports 2 packages (graph) and is imported by 3 packages. Updated 2020-07-29. Refresh now. Tools for package owners.