drawing

package
v0.0.0-...-86ed2ac Latest Latest
Warning

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

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

Documentation

Overview

Package drawing defines Drawing struct for DXF.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SectionTypeString

func SectionTypeString(s SectionType) string

SectionTypeString converts SectionType to string. If SectionType is out of range, it returns empty string.

Types

type Drawing

type Drawing struct {
	FileName     string
	Layers       map[string]*table.Layer
	Groups       map[string]*object.Group
	Styles       map[string]*table.Style
	CurrentLayer *table.Layer
	CurrentStyle *table.Style

	Sections []Section

	PlotStyle handle.Handler
	// contains filtered or unexported fields
}

Drawing contains DXF drawing data.

func New

func New() *Drawing

New creates a new Drawing.

func (*Drawing) AddEntity

func (d *Drawing) AddEntity(e entity.Entity)

AddEntity adds a new entity.

func (*Drawing) AddLayer

func (d *Drawing) AddLayer(name string, cl color.ColorNumber, lt *table.LineType, setcurrent bool) (*table.Layer, error)

AddLayer adds a new layer with given name, color and line type. If setcurrent is true, set current layer to it.

func (*Drawing) AddLineType

func (d *Drawing) AddLineType(name string, desc string, ls ...float64) (*table.LineType, error)

AddLineType adds a new linetype.

func (*Drawing) AddStyle

func (d *Drawing) AddStyle(name string, fontname, bigfontname string, setcurrent bool) (*table.Style, error)

AddStyle adds a new text style. If setcurrent is true, set current style to it.

func (*Drawing) AddToGroup

func (d *Drawing) AddToGroup(name string, es ...entity.Entity) error

AddToGroup adds given entities to the named group. If the named group doesn't exist, returns error.

func (*Drawing) ChangeLayer

func (d *Drawing) ChangeLayer(name string) error

ChangeLayer changes current layer to the named layer.

func (*Drawing) Circle

func (d *Drawing) Circle(x, y, z, r float64) (*entity.Circle, error)

Circle creates a new CIRCLE at (x, y, z) with radius r.

func (*Drawing) Entities

func (d *Drawing) Entities() entity.Entities

Entities returns slice of all entities contained in Drawing.

func (*Drawing) Group

func (d *Drawing) Group(name, desc string, es ...entity.Entity) (*object.Group, error)

Group adds given entities to the named group. If the named group doesn't exist, create it.

func (*Drawing) Header

func (d *Drawing) Header() *header.Header

func (*Drawing) Layer

func (d *Drawing) Layer(name string, setcurrent bool) (*table.Layer, error)

Layer returns the named layer if exists. If setcurrent is true, set current layer to it.

func (*Drawing) Line

func (d *Drawing) Line(x1, y1, z1, x2, y2, z2 float64) (*entity.Line, error)

Line creates a new LINE from (x1, y1, z1) to (x2, y2, z2).

func (*Drawing) LineType

func (d *Drawing) LineType(name string) (*table.LineType, error)

LineType returns the named line type if exists.

func (*Drawing) LwPolyline

func (d *Drawing) LwPolyline(closed bool, vertices ...[]float64) (*entity.LwPolyline, error)

LwPolyline creates a new LWPOLYLINE with given vertices.

func (*Drawing) Point

func (d *Drawing) Point(x, y, z float64) (*entity.Point, error)

Point creates a new POINT at (x, y, z).

func (*Drawing) Polyline

func (d *Drawing) Polyline(closed bool, vertices ...[]float64) (*entity.Polyline, error)

Polyline creates a new POLYLINE with given vertices.

func (*Drawing) Save

func (d *Drawing) Save() error

Save saves the drawing file. If it is the first time, use SaveAs(filename).

func (*Drawing) SaveAs

func (d *Drawing) SaveAs(filename string) error

SaveAs saves the drawing file as given filename.

func (*Drawing) SetExt

func (d *Drawing) SetExt()

func (*Drawing) Style

func (d *Drawing) Style(name string, setcurrent bool) (*table.Style, error)

Style returns the named text style if exists. If setcurrent is true, set current style to it.

func (*Drawing) Text

func (d *Drawing) Text(str string, x, y, z, height float64) (*entity.Text, error)

Text creates a new TEXT str at (x, y, z) with given height.

func (*Drawing) ThreeDFace

func (d *Drawing) ThreeDFace(points [][]float64) (*entity.ThreeDFace, error)

ThreeDFace creates a new 3DFACE with given points.

type Section

type Section interface {
	WriteTo(format.Formatter)
	SetHandle(*int)
}

Section is interface for DXF sections.

type SectionType

type SectionType int

SectionType represents Section names (code 2)

const (
	HEADER SectionType = iota
	CLASSES
	TABLES
	BLOCKS
	ENTITIES
	OBJECTS
	ACDSDATA
)

Section name: code 2

func SectionTypeValue

func SectionTypeValue(s string) SectionType

SectionTypeValue converts string to SectionType. If string is unknown SectionType, it returns -1.

Jump to

Keyboard shortcuts

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