Documentation
¶
Index ¶
- func Bool(v bool) *bool
- func Float64(v float64) *float64
- func NewSeed() float64
- func NumberString(v float64) string
- func String(v string) *string
- type Config
- type Drawable
- type Generator
- func (g *Generator) Arc(x, y, width, height, start, stop float64, closed bool, options *Options) Drawable
- func (g *Generator) Circle(x, y, diameter float64, options *Options) Drawable
- func (g *Generator) Curve(points []Point, options *Options) Drawable
- func (g *Generator) DefaultOptions() ResolvedOptions
- func (g *Generator) Ellipse(x, y, width, height float64, options *Options) Drawable
- func (g *Generator) Line(x1, y1, x2, y2 float64, options *Options) Drawable
- func (g *Generator) LinearPath(points []Point, options *Options) Drawable
- func (g *Generator) OpsToPath(drawing OpSet) string
- func (g *Generator) Path(pathData string, options *Options) Drawable
- func (g *Generator) Polygon(points []Point, options *Options) Drawable
- func (g *Generator) Rectangle(x, y, width, height float64, options *Options) Drawable
- func (g *Generator) ToPaths(d Drawable) []PathInfo
- type Line
- type Op
- type OpSet
- type OpSetType
- type OpType
- type Options
- type PathInfo
- type PatternInfo
- type Point
- type Rectangle
- type ResolvedOptions
- type Surface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSeed ¶
func NewSeed() float64
NewSeed returns a nondeterministic seed in Rough.js's supported range.
func NumberString ¶
NumberString formats v the way JavaScript coerces a Number to a string. It is useful when surrounding SVG serialization must remain byte-compatible with Rough.js output.
Types ¶
type Config ¶
type Config struct {
Options *Options `json:"options,omitempty"`
}
Config configures a Generator.
type Drawable ¶
type Drawable struct {
Shape string
Options *ResolvedOptions
Sets []OpSet
}
Drawable is the source-shaped output of Generator drawing methods.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates Rough.js-compatible drawing operations.
A Generator retains the same mutable default-option random state as Rough.js. Its methods are safe for concurrent use, though callers that need independent deterministic streams should use separate generators.
func NewGenerator ¶
NewGenerator creates a generator. A nil config uses Rough.js 4.6.6's defaults. The optional surface supplies patterned-path fallback dimensions.
func (*Generator) Arc ¶
func (g *Generator) Arc(x, y, width, height, start, stop float64, closed bool, options *Options) Drawable
Arc creates a rough elliptical arc.
func (*Generator) DefaultOptions ¶
func (g *Generator) DefaultOptions() ResolvedOptions
DefaultOptions returns a value copy of the generator's current defaults.
func (*Generator) LinearPath ¶
LinearPath creates an open rough path through points.
func (*Generator) OpsToPath ¶
OpsToPath serializes operations using Rough.js's SVG punctuation and number formatting.
type OpSet ¶
type OpSet struct {
Type OpSetType `json:"type"`
Ops []Op `json:"ops"`
Size *Point `json:"size,omitempty"`
Path string `json:"path,omitempty"`
}
OpSet is one ordered set of path operations.
type Options ¶
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"`
}
Options contains optional Rough.js drawing options. Pointer fields preserve the distinction between an omitted option and an explicit zero value.
type PathInfo ¶
type PathInfo struct {
D string
Stroke string
StrokeWidth float64
Fill string
Pattern *PatternInfo
}
PathInfo is the SVG-oriented representation of an operation set.
type PatternInfo ¶
type PatternInfo struct {
X float64
Y float64
Width float64
Height float64
ViewBox string
PatternUnits string
Path PathInfo
}
PatternInfo describes the pattern used by a patterned SVG path fill.
type ResolvedOptions ¶
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 is retained for source compatibility with v0.1.0. Rough.js
// 4.6.6 computes the gain per line and no longer mutates this field.
RoughnessGain float64
// contains filtered or unexported fields
}
ResolvedOptions is the complete option set used by the renderer.