package rough
type Point [2 ]float64
type Line [2 ]Point
type Rectangle struct {
X float64
Y float64
Width float64
Height float64
}
type Config struct {
Options *Options `json:"options,omitempty"`
}
type Surface struct {
Width float64 `json:"width"`
Height float64 `json:"height"`
}
type Options struct {
MaxRandomnessOffset *float64 `json:"maxRandomnessOffset,omitempty"`
Roughness *float64 `json:"roughness,omitempty"`
Bowing *float64 `json:"bowing,omitempty"`
Stroke *string `json:"stroke,omitempty"`
StrokeWidth *float64 `json:"strokeWidth,omitempty"`
CurveFitting *float64 `json:"curveFitting,omitempty"`
CurveTightness *float64 `json:"curveTightness,omitempty"`
CurveStepCount *float64 `json:"curveStepCount,omitempty"`
Fill *string `json:"fill,omitempty"`
FillStyle *string `json:"fillStyle,omitempty"`
FillWeight *float64 `json:"fillWeight,omitempty"`
HachureAngle *float64 `json:"hachureAngle,omitempty"`
HachureGap *float64 `json:"hachureGap,omitempty"`
Simplification *float64 `json:"simplification,omitempty"`
DashOffset *float64 `json:"dashOffset,omitempty"`
DashGap *float64 `json:"dashGap,omitempty"`
ZigzagOffset *float64 `json:"zigzagOffset,omitempty"`
Seed *float64 `json:"seed,omitempty"`
StrokeLineDash []float64 `json:"strokeLineDash,omitempty"`
StrokeLineDashOffset *float64 `json:"strokeLineDashOffset,omitempty"`
FillLineDash []float64 `json:"fillLineDash,omitempty"`
FillLineDashOffset *float64 `json:"fillLineDashOffset,omitempty"`
DisableMultiStroke *bool `json:"disableMultiStroke,omitempty"`
DisableMultiStrokeFill *bool `json:"disableMultiStrokeFill,omitempty"`
PreserveVertices *bool `json:"preserveVertices,omitempty"`
FixedDecimalPlaceDigits *float64 `json:"fixedDecimalPlaceDigits,omitempty"`
FillShapeRoughnessGain *float64 `json:"fillShapeRoughnessGain,omitempty"`
}
func Float64 (v float64 ) *float64 { return &v }
func String (v string ) *string { return &v }
func Bool (v bool ) *bool { return &v }
type ResolvedOptions struct {
MaxRandomnessOffset float64
Roughness float64
Bowing float64
Stroke string
StrokeWidth float64
CurveFitting float64
CurveTightness float64
CurveStepCount float64
Fill string
FillStyle string
FillWeight float64
HachureAngle float64
HachureGap float64
Simplification float64
DashOffset float64
DashGap float64
ZigzagOffset float64
Seed float64
StrokeLineDash []float64
StrokeLineDashOffset float64
FillLineDash []float64
FillLineDashOffset float64
DisableMultiStroke bool
DisableMultiStrokeFill bool
PreserveVertices bool
FixedDecimalPlaceDigits *float64
FillShapeRoughnessGain float64
RoughnessGain float64
randomizer *randomState
}
type OpType string
const (
OpMove OpType = "move"
OpBCurveTo OpType = "bcurveTo"
OpLineTo OpType = "lineTo"
OpQCurveTo OpType = "qcurveTo"
)
type OpSetType string
const (
OpSetPath OpSetType = "path"
OpSetFillPath OpSetType = "fillPath"
OpSetFillSketch OpSetType = "fillSketch"
OpSetPath2DFill OpSetType = "path2Dfill"
OpSetPath2DPattern OpSetType = "path2Dpattern"
)
type Op struct {
Op OpType `json:"op"`
Data []float64 `json:"data"`
}
type OpSet struct {
Type OpSetType `json:"type"`
Ops []Op `json:"ops"`
Size *Point `json:"size,omitempty"`
Path string `json:"path,omitempty"`
}
type Drawable struct {
Shape string
Options *ResolvedOptions
Sets []OpSet
}
type PathInfo struct {
D string
Stroke string
StrokeWidth float64
Fill string
Pattern *PatternInfo
}
type PatternInfo struct {
X float64
Y float64
Width float64
Height float64
ViewBox string
PatternUnits string
Path PathInfo
}
func defaultResolvedOptions() ResolvedOptions {
return ResolvedOptions {
MaxRandomnessOffset : 2 ,
Roughness : 1 ,
Bowing : 1 ,
Stroke : "#000" ,
StrokeWidth : 1 ,
CurveFitting : 0.95 ,
CurveTightness : 0 ,
CurveStepCount : 9 ,
FillStyle : "hachure" ,
FillWeight : -1 ,
HachureAngle : -41 ,
HachureGap : -1 ,
DashOffset : -1 ,
DashGap : -1 ,
ZigzagOffset : -1 ,
Seed : 0 ,
DisableMultiStroke : false ,
DisableMultiStrokeFill : false ,
PreserveVertices : false ,
FillShapeRoughnessGain : 0.8 ,
RoughnessGain : 1 ,
}
}
func mergeOptions(base ResolvedOptions , o *Options ) ResolvedOptions {
if o == nil {
return base
}
if o .MaxRandomnessOffset != nil {
base .MaxRandomnessOffset = *o .MaxRandomnessOffset
}
if o .Roughness != nil {
base .Roughness = *o .Roughness
}
if o .Bowing != nil {
base .Bowing = *o .Bowing
}
if o .Stroke != nil {
base .Stroke = *o .Stroke
}
if o .StrokeWidth != nil {
base .StrokeWidth = *o .StrokeWidth
}
if o .CurveFitting != nil {
base .CurveFitting = *o .CurveFitting
}
if o .CurveTightness != nil {
base .CurveTightness = *o .CurveTightness
}
if o .CurveStepCount != nil {
base .CurveStepCount = *o .CurveStepCount
}
if o .Fill != nil {
base .Fill = *o .Fill
}
if o .FillStyle != nil {
base .FillStyle = *o .FillStyle
}
if o .FillWeight != nil {
base .FillWeight = *o .FillWeight
}
if o .HachureAngle != nil {
base .HachureAngle = *o .HachureAngle
}
if o .HachureGap != nil {
base .HachureGap = *o .HachureGap
}
if o .Simplification != nil {
base .Simplification = *o .Simplification
}
if o .DashOffset != nil {
base .DashOffset = *o .DashOffset
}
if o .DashGap != nil {
base .DashGap = *o .DashGap
}
if o .ZigzagOffset != nil {
base .ZigzagOffset = *o .ZigzagOffset
}
if o .Seed != nil {
base .Seed = *o .Seed
}
if o .StrokeLineDash != nil {
base .StrokeLineDash = append ([]float64 (nil ), o .StrokeLineDash ...)
}
if o .StrokeLineDashOffset != nil {
base .StrokeLineDashOffset = *o .StrokeLineDashOffset
}
if o .FillLineDash != nil {
base .FillLineDash = append ([]float64 (nil ), o .FillLineDash ...)
}
if o .FillLineDashOffset != nil {
base .FillLineDashOffset = *o .FillLineDashOffset
}
if o .DisableMultiStroke != nil {
base .DisableMultiStroke = *o .DisableMultiStroke
}
if o .DisableMultiStrokeFill != nil {
base .DisableMultiStrokeFill = *o .DisableMultiStrokeFill
}
if o .PreserveVertices != nil {
base .PreserveVertices = *o .PreserveVertices
}
if o .FixedDecimalPlaceDigits != nil {
v := *o .FixedDecimalPlaceDigits
base .FixedDecimalPlaceDigits = &v
}
if o .FillShapeRoughnessGain != nil {
base .FillShapeRoughnessGain = *o .FillShapeRoughnessGain
}
return base
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .