Documentation
¶
Index ¶
- func AddConst(doc *psrt.Document, name, value string) error
- func AddFont(doc *psrt.Document, url string) error
- func AddMask(doc *psrt.Document, pageName string, mask psrt.Mask, ...) error
- func AddPage(doc *psrt.Document, page psrt.Page, before, after string) error
- func AddPathMask(doc *psrt.Document, pageName string, mask psrt.PathMask, ...) error
- func AddText(doc *psrt.Document, pageName string, text psrt.Text, ...) error
- func FindMaskByIndex(page *psrt.Page, index int) (*psrt.Mask, int, error)
- func FindPage(doc *psrt.Document, name string) (*psrt.Page, error)
- func FindPageIndex(doc *psrt.Document, name string) (int, error)
- func FindPathMaskByIndex(page *psrt.Page, index int) (*psrt.PathMask, int, error)
- func FindTextByIndex(page *psrt.Page, index int) (*psrt.Text, int, error)
- func FormatDocument(doc *psrt.Document) ([]byte, error)
- func LoadDocument(path string) (psrt.Document, error)
- func MergeStyle(style psrt.Style, partial json.RawMessage) (psrt.Style, error)
- func MovePage(doc *psrt.Document, pageName, before, after string) error
- func NudgeTextPosition(doc *psrt.Document, pageName string, textIndex int, delta PositionFields) error
- func ParseTextIndex(s string) (int, error)
- func RemoveConst(doc *psrt.Document, name string) error
- func RemoveFont(doc *psrt.Document, url string) error
- func RemoveMask(doc *psrt.Document, pageName string, maskIndex int) error
- func RemoveMaskStyleKey(doc *psrt.Document, pageName string, maskIndex int, key string) error
- func RemovePage(doc *psrt.Document, name string) error
- func RemovePageStyleKey(doc *psrt.Document, pageName, key string) error
- func RemovePathMask(doc *psrt.Document, pageName string, maskIndex int) error
- func RemovePathMaskStyleKey(doc *psrt.Document, pageName string, maskIndex int, key string) error
- func RemoveStyleKey(style psrt.Style, key string) (psrt.Style, error)
- func RemoveText(doc *psrt.Document, pageName string, textIndex int) error
- func RemoveTextStyleKey(doc *psrt.Document, pageName string, textIndex int, key string) error
- func RenamePage(doc *psrt.Document, oldName, newName string) error
- func ReorderTextByDelta(doc *psrt.Document, pageName string, textIndex, delta int) error
- func ReorderTextRelative(doc *psrt.Document, pageName string, textIndex int, ...) error
- func ReorderTextTo(doc *psrt.Document, pageName string, textIndex, to int) error
- func RevertConstReferences(doc *psrt.Document, name, value string)
- func SaveDocument(doc *psrt.Document, path string) error
- func SetMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos MaskPositionFields) error
- func SetMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, ...) error
- func SetPagePath(doc *psrt.Document, pageName, path string) error
- func SetPageStyle(doc *psrt.Document, pageName string, key, value string, ...) error
- func SetPathMaskPath(doc *psrt.Document, pageName string, maskIndex int, path string) error
- func SetPathMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos PathMaskPositionFields) error
- func SetPathMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, ...) error
- func SetStyleKey(style psrt.Style, key, value string) (psrt.Style, error)
- func SetTextContent(doc *psrt.Document, pageName string, textIndex int, content string, ...) error
- func SetTextPosition(doc *psrt.Document, pageName string, textIndex int, pos PositionFields) error
- func SetTextStyle(doc *psrt.Document, pageName string, textIndex int, key, value string, ...) error
- func SubstituteConstReferences(doc *psrt.Document, name, value string)
- type MaskPositionFields
- type PathMaskPositionFields
- type PositionFields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMask ¶
func AddMask(doc *psrt.Document, pageName string, mask psrt.Mask, beforeIndex, afterIndex int) error
AddMask inserts a mask block on a page.
func AddPathMask ¶
func AddPathMask(doc *psrt.Document, pageName string, mask psrt.PathMask, beforeIndex, afterIndex int) error
AddPathMask inserts a path mask block on a page.
func AddText ¶
func AddText(doc *psrt.Document, pageName string, text psrt.Text, beforeIndex, afterIndex int) error
AddText inserts a new text block on a page.
func FindMaskByIndex ¶
FindMaskByIndex delegates to psrt.FindMaskByIndex.
func FindPageIndex ¶
FindPageIndex returns the slice index of a page by name.
func FindPathMaskByIndex ¶
FindPathMaskByIndex delegates to psrt.FindPathMaskByIndex.
func FindTextByIndex ¶
FindTextByIndex returns the text block with the given Index field on a page.
func FormatDocument ¶
FormatDocument serialises a document to PSRT bytes.
func LoadDocument ¶
LoadDocument parses a PSRT file from path.
func MergeStyle ¶
MergeStyle shallow-merges partial JSON into the existing style.
func NudgeTextPosition ¶
func NudgeTextPosition(doc *psrt.Document, pageName string, textIndex int, delta PositionFields) error
NudgeTextPosition adds deltas to X, Y, Width and/or TextSize. Only non-nil fields in delta are applied.
func ParseTextIndex ¶
ParseTextIndex parses --index flag value.
func RemoveConst ¶
RemoveConst reverts @name@ to the stored value, then deletes the constant.
func RemoveFont ¶
RemoveFont removes a font URL.
func RemoveMask ¶
RemoveMask deletes a mask by index field.
func RemoveMaskStyleKey ¶
RemoveMaskStyleKey removes a style property from a mask block.
func RemovePage ¶
RemovePage deletes a page by name.
func RemovePageStyleKey ¶
RemovePageStyleKey removes a style property from a page.
func RemovePathMask ¶
RemovePathMask deletes a path mask by index field.
func RemovePathMaskStyleKey ¶
RemovePathMaskStyleKey removes a style property from a path mask block.
func RemoveStyleKey ¶
RemoveStyleKey removes a property from a style JSON object.
func RemoveText ¶
RemoveText removes a text block by Index field.
func RemoveTextStyleKey ¶
RemoveTextStyleKey removes a style property from a text block.
func RenamePage ¶
RenamePage changes a page name.
func ReorderTextByDelta ¶
ReorderTextByDelta moves a text block by a delta in slice order.
func ReorderTextRelative ¶
func ReorderTextRelative(doc *psrt.Document, pageName string, textIndex int, beforeIndex, afterIndex int) error
ReorderTextRelative moves a text block before or after another text index in the page slice.
func ReorderTextTo ¶
ReorderTextTo moves a text block to an absolute slice position.
func RevertConstReferences ¶
RevertConstReferences replaces @name@ with the original value across the document.
func SaveDocument ¶
SaveDocument formats and writes a PSRT document to path.
func SetMaskPosition ¶
func SetMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos MaskPositionFields) error
SetMaskPosition sets mask X, Y, Width and/or Height (percent).
func SetMaskStyle ¶
func SetMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, partial json.RawMessage) error
SetMaskStyle merges a style property on a mask block.
func SetPagePath ¶
SetPagePath updates the page image URL.
func SetPageStyle ¶
func SetPageStyle(doc *psrt.Document, pageName string, key, value string, partial json.RawMessage) error
SetPageStyle merges style properties on a page.
func SetPathMaskPath ¶
SetPathMaskPath replaces the SVG path `d` data of a path mask block. Validation mirrors flushPathMaskBlock's parse-time checks (see psrt/parser.go): the path must be non-empty, syntactically valid SVG path data, and describe a single shape (RF-7).
func SetPathMaskPosition ¶
func SetPathMaskPosition(doc *psrt.Document, pageName string, maskIndex int, pos PathMaskPositionFields) error
SetPathMaskPosition sets path mask X, Y, Width and/or Height (percent).
func SetPathMaskStyle ¶
func SetPathMaskStyle(doc *psrt.Document, pageName string, maskIndex int, key, value string, partial json.RawMessage) error
SetPathMaskStyle merges a style property on a path mask block.
func SetStyleKey ¶
SetStyleKey sets a single property on a style JSON object. value is raw JSON (e.g. "#fff", "\"600\"", "true").
func SetTextContent ¶
func SetTextContent(doc *psrt.Document, pageName string, textIndex int, content string, appendContent bool) error
SetTextContent updates text content (replace or append).
func SetTextPosition ¶
SetTextPosition sets X, Y, Width and/or TextSize to absolute values. Only non-nil fields in pos are applied.
func SetTextStyle ¶
func SetTextStyle(doc *psrt.Document, pageName string, textIndex int, key, value string, partial json.RawMessage) error
SetTextStyle merges style properties on a text block.
func SubstituteConstReferences ¶
SubstituteConstReferences replaces literal value with @name@ across the document.
Types ¶
type MaskPositionFields ¶
type MaskPositionFields struct {
X, Y, Width, Height *float64
}
MaskPositionFields holds optional mask coordinate updates.
func (MaskPositionFields) IsEmpty ¶
func (p MaskPositionFields) IsEmpty() bool
type PathMaskPositionFields ¶
type PathMaskPositionFields struct {
X, Y, Width, Height *float64
}
PathMaskPositionFields holds optional path mask coordinate updates.
func (PathMaskPositionFields) IsEmpty ¶
func (p PathMaskPositionFields) IsEmpty() bool
type PositionFields ¶
type PositionFields struct {
X, Y, Width, TextSize *float64
}
PositionFields holds optional coordinate updates (nil = leave unchanged).