Documentation
¶
Index ¶
- Constants
- func GetAlpsStabOffset(size float64) (float64, error)
- func GetCherryStabOffset(size float64) (float64, error)
- func SurfaceArea(paths []Path) float64
- type Bounds
- type Case
- type CustomPolygon
- type Export
- type KAD
- func (k *KAD) Draw() error
- func (k *KAD) DrawHoles()
- func (k *KAD) DrawLayout()
- func (k *KAD) DrawOutputFiles() error
- func (k *KAD) FinalizeLayerDimensions()
- func (k *KAD) FinalizePolygons()
- func (k *KAD) GetPokerHoles() Path
- func (k *KAD) GetSandwichHoles() Path
- func (k *KAD) InitCaseEdges()
- func (k *KAD) InitCaseLayers()
- func (k *KAD) ParseLayout() error
- func (k *KAD) ParsePoints(points_str, rel_to_str string, rel_center bool) []Path
- func (k *KAD) StoreLocalFiles()
- func (k *KAD) StoreSwiftFiles()
- func (k *KAD) UpdateBounds(path Path, init bool)
- func (k *KAD) UpdateLayerDimensions()
- type Key
- func (key *Key) Draw(k *KAD, c Point, ctx Key, init bool)
- func (key *Key) DrawAlpsStab(k *KAD, c Point, ctx Key, vertical, flip_stab bool)
- func (key *Key) DrawCherryCostarStab(k *KAD, c Point, ctx Key, vertical, flip_stab bool)
- func (key *Key) DrawCherryStab(k *KAD, c Point, ctx Key, vertical, flip_stab bool)
- func (key *Key) DrawCostarStab(k *KAD, c Point, ctx Key, vertical, flip_stab bool)
- type Layer
- type Path
- type Point
- type Result
- type ResultDetails
- type SvgWrapper
- type UploadCtl
Constants ¶
const ( CASE_NONE = "" CASE_POKER = "poker" CASE_SANDWICH = "sandwich" TOPLAYER = "top" SWITCHLAYER = "switch" BOTTOMLAYER = "bottom" CLOSEDLAYER = "closed" OPENLAYER = "open" TOPLAYER_NAME = "Top Layer" SWITCHLAYER_NAME = "Switch Layer" BOTTOMLAYER_NAME = "Bottom Layer" CLOSEDLAYER_NAME = "Closed Layer" OPENLAYER_NAME = "Open Layer" )
const ( PRECISION float64 = 1000 OVERLAP = 0.001 STORE_SWIFT = "swift" STORE_LOCAL = "local" )
const ( SWITCHMX = 1 SWITCHMXALPS = 2 SWITCHMXH = 3 SWITCHALPS = 4 STABREMOVE = 0 STABCHERRYCOSTAR = 1 STABCHERRY = 2 STABCOSTAR = 3 STABALPS = 4 )
const (
CLIP_DIST = 0.7 // In order to just clean duplicate points: .7*.7 = 0.49 < 0.5
)
Variables ¶
This section is empty.
Functions ¶
func GetAlpsStabOffset ¶
func GetCherryStabOffset ¶
func SurfaceArea ¶
Types ¶
type Case ¶
type Case struct {
Type string `json:"case-type"`
HoleDiameter float64 `json:"mount-holes-size"`
Holes int `json:"mount-holes-num"`
EdgeWidth float64 `json:"mount-holes-edge"`
LeftWidth float64
RightWidth float64
TopWidth float64
BottomWidth float64
Xholes int
Yholes int
RemovePokerSlots bool `json:"poker-slots-remove"`
UsbLocation float64 `json:"usb-location"`
UsbWidth float64 `json:"usb-width"`
}
type CustomPolygon ¶
type CustomPolygon struct {
Diameter float64 `json:"diameter"`
Height float64 `json:"height"`
Layers []string `json:"layers"`
Op string `json:"op"`
Points string `json:"points"`
Polygon string `json:"polygon"`
Radius float64 `json:"radius"`
RelTo string `json:"rel_to"`
RelAbs string `json:"-"`
Width float64 `json:"width"`
}
type KAD ¶
type KAD struct {
Hash string
UOM string
U1 float64 `json:"key-unit"`
DMZ float64
Width float64
Height float64
LayoutCenter Point
CaseCenter Point
Fillet float64 `json:"fillet"`
Kerf float64 `json:"kerf"`
Xoff float64
TopPad float64 `json:"top-padding"`
LeftPad float64 `json:"left-padding"`
RightPad float64 `json:"right-padding"`
BottomPad float64 `json:"bottom-padding"`
Xgrow float64 `json:"grow_x"`
Ygrow float64 `json:"grow_y"`
SwitchType int `json:"switch-type"`
StabType int `json:"stab-type"`
Case Case `json:"case"`
CustomPolygons []CustomPolygon `json:"custom"`
RawLayout []interface{} `json:"layout"`
Layout [][]Key `json:"-"` // ignore in 'unmarshal'
Svgs map[string]SvgWrapper
Layers map[string]*Layer
SvgStyle string
LineColor string `json:"line-color"`
LineWeight float64 `json:"line-weight"`
Result Result
Bounds Bounds
Swift *swift.Connection
SwiftBucket string
FileStore string
FileDirectory string
FileServePath string
}
func (*KAD) DrawHoles ¶
func (k *KAD) DrawHoles()
Draw the holes for the KAD based on the type of case selected.
func (*KAD) DrawLayout ¶
func (k *KAD) DrawLayout()
Draw the switch and stabilizer openings for this KAD layout.
func (*KAD) DrawOutputFiles ¶
Initialize the SVG files and their File writers.
func (*KAD) FinalizeLayerDimensions ¶
func (k *KAD) FinalizeLayerDimensions()
Finalize the polygons before they go for file processing
func (*KAD) FinalizePolygons ¶
func (k *KAD) FinalizePolygons()
Finalize the polygons before they go for file processing
func (*KAD) GetPokerHoles ¶
Get the Path for a Poker case hole placement.
func (*KAD) GetSandwichHoles ¶
Get the Path for a Sandwich case hole placement.
func (*KAD) InitCaseEdges ¶
func (k *KAD) InitCaseEdges()
func (*KAD) InitCaseLayers ¶
func (k *KAD) InitCaseLayers()
func (*KAD) ParseLayout ¶
Parse the layout and populate all the important information in the KAD object.
func (*KAD) ParsePoints ¶
Parse the points passed in for custom polygons
func (*KAD) StoreLocalFiles ¶
func (k *KAD) StoreLocalFiles()
Store and serve the generated SVG files locally.
func (*KAD) StoreSwiftFiles ¶
func (k *KAD) StoreSwiftFiles()
Store the generated SVG files in an object store.
func (*KAD) UpdateBounds ¶
determine the size of the canvas by checking the bounds of the keys.
func (*KAD) UpdateLayerDimensions ¶
func (k *KAD) UpdateLayerDimensions()
update the dimensions of the kad based on what has been added
type Key ¶
type Key struct {
Width float64 `json:"w"` // width in key units
Height float64 `json:"h"` // height in key units
AltWidth float64 `json:"w2"` // alternate width in key units for strangely shaped keys
AltHeight float64 `json:"h2"` // alternate height in key units for strangely shaped keys
Xrel float64 `json:"x"` // x relative position in key units
Yrel float64 `json:"y"` // y relative position in key units
Xabs float64 `json:"rx"` // x absolute position in key units
Yabs float64 `json:"ry"` // y absolute position in key units
Xalt float64 `json:"x2"` // x relative position in key units for strangely shaped keys
Yalt float64 `json:"y2"` // y relative position in key units for strangely shaped keys
Type int `json:"_t"` // switch type as int
Stab int `json:"_s"` // stab type as int
Kerf float64 `json:"_k"` // kerf for this key
Custom string `json:"_c"` // center point as custom index
Stacked bool
Bounds Path
Rotate float64 `json:"_r"` // rotate switch opening in degrees
RotateStab float64 `json:"_rs"` // rotate stabilizer opening in degrees
RotateCluster float64 `json:"r"` // rotate the following cluster of keys (in degrees)
}
func (*Key) DrawAlpsStab ¶
draw the alps stabilizer
func (*Key) DrawCherryCostarStab ¶
path for cherry + costar stabilizer
func (*Key) DrawCherryStab ¶
path for cherry stabilizer
type Path ¶
type Path []Point
func CirclePolygon ¶
create a circle as a polygon with each quarter made up of 's' segments.
func FromClipperPath ¶
func RoundRectanglePolygon ¶
create a rectangle as a polygon with optional rounded corners. set 'r' and 's' to zero to have a non-rounded corner.
func SuperellipsePolygon ¶
create a superellipse as a polygon with each quarter made up of 's' segments.
func (Path) Rel ¶
Sets the path to the absolute positioning of the Path relative to an origin Point 'r'.
func (Path) RotatePath ¶
Rotates each point in a set and rotates them 'r' degrees around 'a'.
func (Path) SplitOnAxis ¶
SplitOnAxis path to be drawn by SVGo
func (Path) ToClipperPath ¶
type Result ¶
type Result struct {
HasLayers bool `json:"has_layers"`
Plates []string `json:"plates"`
Formats []string `json:"formats"`
Details map[string]*ResultDetails `json:"details"`
}