dom

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Inches = Units{
	"Inches", "in",
}

Functions

func ComponentsToDynMap

func ComponentsToDynMap(c []Component) []*dynmap.DynMap

Converts a list of components to the list of DynMaps

func EvalExpression

func EvalExpression(expression string, element Element) (interface{}, error)

func InchToMM

func InchToMM(inch float64) float64

func MMToInch

func MMToInch(mm float64) float64

func ParseToHFDMap

func ParseToHFDMap(raw string, logger *util.HfdLog) (*dynmap.DynMap, error)

parses to an HFDMap. This should be used instead of parse json directly as we may want to change the encoding in the future.

Types

type Attr

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

Attributes should be local to the component Referenced params will get looked up through the stack, but it is expected that the attributes are available at the component level.

func NewAttr

func NewAttr(e Element, mp *dynmap.DynMap) *Attr

func NewAttrElement

func NewAttrElement(e Element) *Attr

func (*Attr) Bool

func (b *Attr) Bool(param string) (bool, bool)

func (*Attr) Float64

func (b *Attr) Float64(param string) (float64, bool)

func (*Attr) Handle

func (b *Attr) Handle(param string) (path.PathAttr, bool)

func (*Attr) Int

func (b *Attr) Int(param string) (int, bool)

func (*Attr) MustBool

func (b *Attr) MustBool(param string, def bool) bool

func (*Attr) MustFloat64

func (b *Attr) MustFloat64(param string, def float64) float64

func (*Attr) MustHandle

func (b *Attr) MustHandle(param string, def path.PathAttr) path.PathAttr

func (*Attr) MustInt

func (b *Attr) MustInt(param string, def int) int

func (*Attr) MustPoint

func (b *Attr) MustPoint(param string, def path.Point) path.Point

func (*Attr) MustPoint2

func (b *Attr) MustPoint2(param string, from path.Point, def path.Point) path.Point

func (*Attr) MustString

func (b *Attr) MustString(param string, def string) string

func (*Attr) Point

func (b *Attr) Point(param string) (path.Point, bool)

func (*Attr) Point2

func (b *Attr) Point2(param string, from path.Point) (path.Point, bool)

Returns a Point either by x + y coords or by angle + length

func (*Attr) String

func (b *Attr) String(param string) (string, bool)

func (*Attr) SvgString

func (b *Attr) SvgString(param string) (string, bool)

func (*Attr) ToPoint

func (b *Attr) ToPoint(v interface{}) (path.Point, bool)

attempt to coerce into a point

type BasicComponent

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

provides most of the component functionality Note we copy pasta the BAsicElement here because embedding does not work for the param lookup pieces

func (*BasicComponent) Attr

func (b *BasicComponent) Attr() *Attr

returns an attribute finder based on the the original map of this element

func (*BasicComponent) Children

func (b *BasicComponent) Children() []Element

func (*BasicComponent) Defaults

func (b *BasicComponent) Defaults() *dynmap.DynMap

func (*BasicComponent) DmAttr

func (b *BasicComponent) DmAttr(mp *dynmap.DynMap) *Attr

returns an attribute finder based on the passed in dynmap

func (*BasicComponent) ElementType

func (b *BasicComponent) ElementType() string

func (*BasicComponent) HandleTransforms

func (b *BasicComponent) HandleTransforms(self Component, pth path.Path, ctx RenderContext) (path.Path, RenderContext, error)

internal method to handle the transforms

func (*BasicComponent) Id

func (b *BasicComponent) Id() string

func (*BasicComponent) Measure

func (b *BasicComponent) Measure() (float64, float64, error)

measure this component returns w, h Note: this typical calls render, so care should be taken when calling this

func (*BasicComponent) ParamLookerUpper

func (b *BasicComponent) ParamLookerUpper() ParamLookerUpper

func (*BasicComponent) Params

func (b *BasicComponent) Params() *dynmap.DynMap

func (*BasicComponent) Parent

func (b *BasicComponent) Parent() Element

func (*BasicComponent) Render

Render the path. This is typically called by the owning element, which handles the transforms

func (*BasicComponent) RenderContext

func (b *BasicComponent) RenderContext() (RenderContext, bool)

func (*BasicComponent) RenderStart

func (b *BasicComponent) RenderStart(ctx RenderContext)

func (*BasicComponent) SetChildren

func (b *BasicComponent) SetChildren(c []Element)

func (*BasicComponent) SetComponents

func (b *BasicComponent) SetComponents(c []Component)

sets the children componenets

func (*BasicComponent) SetGlobalVariable

func (b *BasicComponent) SetGlobalVariable(key string, val interface{})

Sets a global variable available to all components rendered after this

func (*BasicComponent) SetLocalVariable

func (b *BasicComponent) SetLocalVariable(key string, val interface{})

sets a parameter available to this component and all of its children

func (*BasicComponent) SetParent

func (b *BasicComponent) SetParent(p Element)

func (*BasicComponent) ToDynMap

func (b *BasicComponent) ToDynMap() *dynmap.DynMap

func (*BasicComponent) Transforms

func (b *BasicComponent) Transforms() []*dynmap.DynMap

type BasicElement

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

func (*BasicElement) Attr

func (b *BasicElement) Attr() *Attr

returns an attribute finder based on the the original map of this element

func (*BasicElement) Defaults

func (b *BasicElement) Defaults() *dynmap.DynMap

func (*BasicElement) DmAttr

func (b *BasicElement) DmAttr(mp *dynmap.DynMap) *Attr

returns an attribute finder based on the passed in dynmap

func (*BasicElement) ElementType

func (b *BasicElement) ElementType() string

func (*BasicElement) Id

func (b *BasicElement) Id() string

func (*BasicElement) ParamLookerUpper

func (b *BasicElement) ParamLookerUpper() ParamLookerUpper

func (*BasicElement) Params

func (b *BasicElement) Params() *dynmap.DynMap

func (*BasicElement) SetGlobalVariable

func (b *BasicElement) SetGlobalVariable(key string, val interface{})

Sets a global variable available to all components rendered after this

func (*BasicElement) SetLocalVariable

func (b *BasicElement) SetLocalVariable(key string, val interface{})

sets a parameter available to this component and all of its children

func (*BasicElement) ToDynMap

func (b *BasicElement) ToDynMap() *dynmap.DynMap

type BasicParamLookerUpper

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

func (*BasicParamLookerUpper) Float64

func (p *BasicParamLookerUpper) Float64(param string) (float64, bool)

func (*BasicParamLookerUpper) Lookup

func (p *BasicParamLookerUpper) Lookup(param string) (interface{}, bool)

func (*BasicParamLookerUpper) MustFloat64

func (p *BasicParamLookerUpper) MustFloat64(param string, def float64) float64

func (*BasicParamLookerUpper) MustString

func (p *BasicParamLookerUpper) MustString(param string, def string) string

func (*BasicParamLookerUpper) String

func (p *BasicParamLookerUpper) String(param string) (string, bool)

func (*BasicParamLookerUpper) ToFloat64

func (p *BasicParamLookerUpper) ToFloat64(obj interface{}) (float64, error)

converts the given object

type CleanupTransformFactory

type CleanupTransformFactory struct {
}

func (CleanupTransformFactory) CreateTransform

func (cf CleanupTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (CleanupTransformFactory) TransformTypes

func (cf CleanupTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type Component

type Component interface {
	Element
	// Render the path.  This is typically called by the
	// owning element, which handles the transforms
	// Note that Render should not be ever considered threadsafe
	// and should never be called concurrently
	Render(ctx RenderContext) (path.Path, RenderContext, error)

	// If rendering is currently in progress, this should return the
	// current context
	RenderContext() (RenderContext, bool)

	Transforms() []*dynmap.DynMap
	Parent() Element
	SetParent(element Element)
	// measure this component
	// returns w, h
	// Note: this typical calls render, so care should be taken when calling this
	Measure() (float64, float64, error)
	Children() []Element
}

type ComponentFactory

type ComponentFactory interface {
	CreateComponent(componentType string, dm *dynmap.DynMap, dc *DocumentContext) (Component, error)
	// The list of component types this Factory should be used for
	ComponentTypes() []string
}

type Document

type Document struct {
	*BasicElement
	ElementsByID map[string]Element
	Parts        []*Part
	Context      *DocumentContext
}

top level document, has multiple parts

func ParseDocument

func ParseDocument(dm *dynmap.DynMap, logger *util.HfdLog) (*Document, error)

func ParseDocumentFromJson

func ParseDocumentFromJson(json string, logger *util.HfdLog) (*Document, error)

func ParseDocumentFromPath

func ParseDocumentFromPath(path string, logger *util.HfdLog) (*Document, error)

func (*Document) AllElements

func (d *Document) AllElements() []Element

all the elements that this document contains.

func (*Document) FindElementByID

func (d *Document) FindElementByID(id string) (Element, bool)

func (*Document) FindPartByID

func (d *Document) FindPartByID(id string) (*Part, bool)

type DocumentContext

type DocumentContext struct {
	Params *dynmap.DynMap
	// contains filtered or unexported fields
}

func FindDocumentContext

func FindDocumentContext(c Element) *DocumentContext

returns the document context of the owning document. or nil

func (*DocumentContext) CreateCustomComponent

func (dc *DocumentContext) CreateCustomComponent(componentType string, dm *dynmap.DynMap) (Component, bool, error)

Creates a custom component if possible returns nil, false, nil if there is no custom component available with that type

type DocumentParser

type DocumentParser interface {
	Parse(bytes []byte, logger *util.HfdLog) (*Document, error)
}

type DrawComponent

type DrawComponent struct {
	*BasicComponent
	// contains filtered or unexported fields
}

func (*DrawComponent) Render

type DrawComponentFactory

type DrawComponentFactory struct{}

func (DrawComponentFactory) ComponentTypes

func (dcf DrawComponentFactory) ComponentTypes() []string

The list of component types this Factory should be used for

func (DrawComponentFactory) CreateComponent

func (dcf DrawComponentFactory) CreateComponent(componentType string, dm *dynmap.DynMap, dc *DocumentContext) (Component, error)

type DynMapParamLookerUpper

type DynMapParamLookerUpper struct {
	*dynmap.DynMap
}

a lookerupper based on a single dynmap. mostly useful for tests

func (*DynMapParamLookerUpper) Float64

func (p *DynMapParamLookerUpper) Float64(param string) (float64, bool)

func (*DynMapParamLookerUpper) Lookup

func (p *DynMapParamLookerUpper) Lookup(param string) (interface{}, bool)

func (*DynMapParamLookerUpper) String

func (p *DynMapParamLookerUpper) String(param string) (string, bool)

func (*DynMapParamLookerUpper) ToFloat64

func (p *DynMapParamLookerUpper) ToFloat64(value interface{}) (float64, error)

type Element

type Element interface {
	// The id of this element.
	// note: this should be guarenteed to be set
	Id() string
	ElementType() string

	ToDynMap() *dynmap.DynMap

	// The defaults for this element.
	// Defaults should be accessed LAST, after the entire
	// graph has been searched for the value.
	// Note - defaults currently have limited use, since they
	// are not used when evaluating expressions
	Defaults() *dynmap.DynMap
	// @Deprecated
	Params() *dynmap.DynMap

	SetLocalVariable(key string, val interface{})
	SetGlobalVariable(key string, val interface{})

	// Looks up values in the params map, if no value is found
	// this should recursively search parent elements until
	// it is found
	ParamLookerUpper() ParamLookerUpper
}

func CtoE

func CtoE(components []Component) []Element

Array of components to an array of elements

func FindElementByID

func FindElementByID(id string, element Element) (Element, error)

type Factories

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

func AppContext

func AppContext() *Factories

Constructs a Factories instance with the components and transforms we know about..

func (*Factories) AddComponentFactory

func (c *Factories) AddComponentFactory(cf ComponentFactory)

func (*Factories) AddPartTransformerFactory

func (c *Factories) AddPartTransformerFactory(tf PartTransformerFactory)

func (*Factories) AddTransformFactory

func (c *Factories) AddTransformFactory(tf TransformFactory)

func (*Factories) DocumentParser

func (c *Factories) DocumentParser() DocumentParser

func (*Factories) FileLoader

func (c *Factories) FileLoader() FileLoader

func (*Factories) Init

func (c *Factories) Init(componentFactories []ComponentFactory,
	transformFactories []TransformFactory,
	partTransformerFactories []PartTransformerFactory,
	segOps path.SegmentOperators,
	documentParser DocumentParser,
	fileLoader FileLoader,
	svgParser SVGParser,
)

func (*Factories) MakeBasicComponent

func (c *Factories) MakeBasicComponent(dm *dynmap.DynMap) *BasicComponent

func (*Factories) MakeBasicElement

func (c *Factories) MakeBasicElement(dm *dynmap.DynMap) *BasicElement

func (*Factories) MakeComponent

func (c *Factories) MakeComponent(dm *dynmap.DynMap, dc *DocumentContext) (Component, error)

Makes a component from the DynMap, there must be a field called "type"

func (*Factories) MakeComponents

func (c *Factories) MakeComponents(dm []*dynmap.DynMap, dc *DocumentContext) ([]Component, error)

func (*Factories) MakePartTransformer

func (c *Factories) MakePartTransformer(transformType string, dm *dynmap.DynMap, part *Part) (PartTransformer, error)

func (*Factories) MakePartTransformers

func (c *Factories) MakePartTransformers(dm []*dynmap.DynMap, part *Part) ([]PartTransformer, error)

func (*Factories) MakeTransform

func (c *Factories) MakeTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (*Factories) MakeTransforms

func (c *Factories) MakeTransforms(dm []*dynmap.DynMap, element Element) ([]path.PathTransform, error)

finds the transforms under the given key

func (*Factories) ParseSVG

func (c *Factories) ParseSVG(svg string, logger *util.HfdLog) (path.Path, error)

func (*Factories) Precision

func (c *Factories) Precision() int

func (*Factories) SegmentOperators

func (c *Factories) SegmentOperators() path.SegmentOperators

func (*Factories) SetFileLoader

func (c *Factories) SetFileLoader(fl FileLoader)

type FileLoader

type FileLoader interface {
	LoadBytes(filename string) ([]byte, error)
}

type GroupComponent

type GroupComponent struct {
	*BasicComponent
	// contains filtered or unexported fields
}

func (*GroupComponent) Children

func (cc *GroupComponent) Children() []Element

func (*GroupComponent) Render

type GroupComponentFactory

type GroupComponentFactory struct{}

func (GroupComponentFactory) ComponentTypes

func (ccf GroupComponentFactory) ComponentTypes() []string

The list of component types this Factory should be used for

func (GroupComponentFactory) CreateComponent

func (ccf GroupComponentFactory) CreateComponent(componentType string, mp *dynmap.DynMap, dc *DocumentContext) (Component, error)

type JoinTransformFactory

type JoinTransformFactory struct {
}

func (JoinTransformFactory) CreateTransform

func (tf JoinTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (JoinTransformFactory) TransformTypes

func (cf JoinTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type Label

type Label struct {
	Text     string
	Position path.PathAttr
}

type LathePartTransform

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

func (*LathePartTransform) TransformPart

func (lpt *LathePartTransform) TransformPart(part *RenderedPart, ctx RenderContext) ([]*RenderedPart, error)

type MatrixTransformFactory

type MatrixTransformFactory struct {
	Values []float64
}

func (MatrixTransformFactory) CreateTransform

func (tf MatrixTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (MatrixTransformFactory) TransformTypes

func (tf MatrixTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type MirrorTransformFactory

type MirrorTransformFactory struct {
	Axis transforms.Axis
}

func (MirrorTransformFactory) CreateTransform

func (tf MirrorTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (MirrorTransformFactory) TransformTypes

func (tf MirrorTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type MoveTransformFactory

type MoveTransformFactory struct {
}

func (MoveTransformFactory) CreateTransform

func (tf MoveTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (MoveTransformFactory) TransformTypes

func (tf MoveTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type OffsetTransformFactory

type OffsetTransformFactory struct {
}

func (OffsetTransformFactory) CreateTransform

func (tf OffsetTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (OffsetTransformFactory) TransformTypes

func (tf OffsetTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type OversizeStrategy

type OversizeStrategy int32

What to do when a rendered piece is too big for the document?

const (
	// break the piece using the specified CutLine
	Split OversizeStrategy = 0
	// leave the document the same size but spill off the edge
	Spill OversizeStrategy = 1
)

type ParamLookerUpper

type ParamLookerUpper interface {
	Lookup(param string) (interface{}, bool)
	// attempt to convert the given object to a float.
	// if this is a number than that will be returned
	// if it is a string, the string will be evaluated
	ToFloat64(value interface{}) (float64, error)
	MustString(param string, def string) string
	String(param string) (string, bool)
	MustFloat64(param string, def float64) float64
	Float64(param string) (float64, bool)
}

type Part

type Part struct {
	*BasicComponent
	PartTransformers []PartTransformer
}

individual part (like a box face) Each part should have its own 0,0 base coordinate system.

func (*Part) Document

func (p *Part) Document() *Document

gets the owning document

func (*Part) Render

func (p *Part) Render(ctx RenderContext) (path.Path, RenderContext, error)

render a single part. This satisfies the Component interface, typically RenderPart should be used instead as that will honor the repeats or splits

func (*Part) RenderPart

func (p *Part) RenderPart(ctx RenderContext) ([]*RenderedPart, error)

type PartFactory

type PartFactory struct{}

since Part is also a component we use a factory for it

func (PartFactory) ComponentTypes

func (pf PartFactory) ComponentTypes() []string

The list of component types this Factory should be used for

func (PartFactory) CreateComponent

func (pf PartFactory) CreateComponent(componentType string, mp *dynmap.DynMap, dc *DocumentContext) (Component, error)

type PartLatheTransformerFactory

type PartLatheTransformerFactory struct{}

func (PartLatheTransformerFactory) CreateTransformer

func (pf PartLatheTransformerFactory) CreateTransformer(transformType string, dm *dynmap.DynMap, part *Part) (PartTransformer, error)

func (PartLatheTransformerFactory) TransformerTypes

func (cf PartLatheTransformerFactory) TransformerTypes() []string

// The list of component types this Factory should be used for

type PartSplitter

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

func (*PartSplitter) TransformPart

func (ps *PartSplitter) TransformPart(part *RenderedPart, ctx RenderContext) ([]*RenderedPart, error)

type PartSplitterTransformerFactory

type PartSplitterTransformerFactory struct{}

func (PartSplitterTransformerFactory) CreateTransformer

func (pf PartSplitterTransformerFactory) CreateTransformer(transformType string, dm *dynmap.DynMap, part *Part) (PartTransformer, error)

func (PartSplitterTransformerFactory) TransformerTypes

func (cf PartSplitterTransformerFactory) TransformerTypes() []string

// The list of component types this Factory should be used for

type PartTransformer

type PartTransformer interface {
	TransformPart(part *RenderedPart, ctx RenderContext) ([]*RenderedPart, error)
}

type PartTransformerFactory

type PartTransformerFactory interface {
	CreateTransformer(transformType string, dm *dynmap.DynMap, part *Part) (PartTransformer, error)
	// The list of component types this Factory should be used for
	TransformerTypes() []string
}

type PlanSet

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

a collection of documents as you add items this will create more documents potentially splitting items when they wont fit.

func NewPlanSet

func NewPlanSet(doc *Document) *PlanSet

func (*PlanSet) Document

func (p *PlanSet) Document() *Document

ONLY FOR TESTING

func (*PlanSet) Init

func (p *PlanSet) Init(ctx RenderContext) error

func (*PlanSet) InitWithPartsFilter added in v1.0.1

func (p *PlanSet) InitWithPartsFilter(ctx RenderContext, filter func(p *RenderedPart) bool) error

func (*PlanSet) RenderZip

func (ps *PlanSet) RenderZip(filename string, w *zip.Writer, ctx RenderContext) error

renders all the documents into the passed in zip writer

func (*PlanSet) SVGDocuments

func (p *PlanSet) SVGDocuments() []*SVGDocument

type RenderContext

type RenderContext struct {
	Origin path.Point
	Cursor path.Point
	Log    *util.HfdLog
}

func RepeatRender

func RepeatRender(ctx RenderContext, component Component, maxX, maxY float64) (path.Path, RenderContext, error)

func (RenderContext) Clone

func (c RenderContext) Clone() RenderContext

type RenderStrategy

type RenderStrategy int32

What is the strategy when all the pieces don't fit in the Document?

const (
	// Render into multiple documents
	MultiDocument RenderStrategy = 0
	// Resize a single document
	// THis will scale the document in both directions
	ResizeDocument RenderStrategy = 1
)

type RenderedPart

type RenderedPart struct {
	Part   *Part
	Path   path.Path
	Width  float64
	Height float64
	Label  Label
}

type ReorderTransformFactory

type ReorderTransformFactory struct {
}

func (ReorderTransformFactory) CreateTransform

func (tf ReorderTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (ReorderTransformFactory) TransformTypes

func (cf ReorderTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type RepeatComponent

type RepeatComponent struct {
	*BasicComponent
	// contains filtered or unexported fields
}

func (*RepeatComponent) Render

type RepeatComponentFactory

type RepeatComponentFactory struct{}

func (RepeatComponentFactory) ComponentTypes

func (rcf RepeatComponentFactory) ComponentTypes() []string

The list of component types this Factory should be used for

func (RepeatComponentFactory) CreateComponent

func (rcf RepeatComponentFactory) CreateComponent(componentType string, dm *dynmap.DynMap, dc *DocumentContext) (Component, error)

type ReverseTransformFactory

type ReverseTransformFactory struct {
}

func (ReverseTransformFactory) CreateTransform

func (tf ReverseTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (ReverseTransformFactory) TransformTypes

func (cf ReverseTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type RotateScaleTransformFactory

type RotateScaleTransformFactory struct {
}

func (RotateScaleTransformFactory) CreateTransform

func (tf RotateScaleTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (RotateScaleTransformFactory) TransformTypes

func (tf RotateScaleTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type RotateTransformFactory

type RotateTransformFactory struct {
}

func (RotateTransformFactory) CreateTransform

func (tf RotateTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (RotateTransformFactory) TransformTypes

func (tf RotateTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type SVGDocument

type SVGDocument struct {
	Name string

	// document width
	Width float64

	// document height
	Height float64

	Units Units

	// how much padding between things in the document?
	Padding float64

	// render the size into the document?
	// most cases this should be true,
	// false is useful for resizable in a browser window
	RenderSize bool

	// how many decimal places to render
	Precision int

	SegmentOperators path.SegmentOperators

	CutStyle   string
	LabelStyle string
	// contains filtered or unexported fields
}

a standard document

func NewSVGDocument

func NewSVGDocument(w float64, h float64, unit Units) *SVGDocument

Creates a new document defaults to settings for .2" Lowes style plywood

func (*SVGDocument) Add

func (d *SVGDocument) Add(p *RenderedPart, ctx RenderContext) (bool, error)

adds a renderable creator into this document. Returns true if it was able to fit, false otherwise.

func (*SVGDocument) Clone

func (d *SVGDocument) Clone() *SVGDocument

clones this document meta data, minus any items in it TODO: do we want to clone the renderables as well?

func (*SVGDocument) Parts

func (d *SVGDocument) Parts() []*Part

func (*SVGDocument) WriteSVG

func (d *SVGDocument) WriteSVG(ctx RenderContext, writer io.Writer)

writes the whole svg document

type SVGParser

type SVGParser interface {
	ParseSVG(svg string, logger *util.HfdLog) (path.Path, error)
}

type ScaleTransformFactory

type ScaleTransformFactory struct {
}

func (ScaleTransformFactory) CreateTransform

func (tf ScaleTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (ScaleTransformFactory) TransformTypes

func (tf ScaleTransformFactory) TransformTypes() []string

// The list of component types this Factory should be used for

type SliceTransformFactory

type SliceTransformFactory struct {
}

func (SliceTransformFactory) CreateTransform

func (tf SliceTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (SliceTransformFactory) TransformTypes

func (tf SliceTransformFactory) TransformTypes() []string

The list of component types this Factory should be used for

type TransformFactory

type TransformFactory interface {
	CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)
	// The list of component types this Factory should be used for
	TransformTypes() []string
}

type TrimTransformFactory

type TrimTransformFactory struct {
}

func (TrimTransformFactory) CreateTransform

func (tf TrimTransformFactory) CreateTransform(transformType string, dm *dynmap.DynMap, element Element) (path.PathTransform, error)

func (TrimTransformFactory) TransformTypes

func (tf TrimTransformFactory) TransformTypes() []string

The list of component types this Factory should be used for

type Units

type Units struct {
	Name string
	Abv  string
}
var MilliMeters Units = Units{
	"MilliMeters", "mm",
}

func MustUnits

func MustUnits(in string, defaultUnits Units) Units

func NewUnits

func NewUnits(in string) (Units, bool)

* Returns the requested units. and true. * Else returns MM, false

func (Units) FromInch

func (u Units) FromInch(in float64) float64

func (Units) FromMM

func (u Units) FromMM(mm float64) float64

Jump to

Keyboard shortcuts

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