Documentation
¶
Index ¶
- Constants
- func IsLayerPullback(legs []LayerLeg) bool
- func LayerDuration(root *d2target.Diagram) (int, error)
- func ProgressBoardGap(center, width, lineHeight, previousEnd int) (left, right int, ok bool)
- func ProgressColor(themeID *int64, overrides *d2target.ThemeOverrides) string
- func ProgressLineHeight(width, height int) int
- func ProgressTickX(elapsed, total int64, width int) int
- func PullbackPosition(legCount int, progress float64) (leg int, local float64)
- func ResolveProgressColor(themeID *int64, overrides *d2target.ThemeOverrides, explicit string) (string, error)
- func TranslationTracks(board *d2target.Diagram) map[string]d2scene.Track
- func ValidateSVGIconLoop(root *d2target.Diagram, boardPath []string, intervalMS, zoomMS int) error
- func Wrap(rootDiagram *d2target.Diagram, svgs [][]byte, renderOpts d2svg.RenderOpts, ...) ([]byte, error)
- func WrapTimed(rootDiagram *d2target.Diagram, svgs [][]byte, renderOpts d2svg.RenderOpts, ...) ([]byte, error)
- func WrapTimeline(rootDiagram *d2target.Diagram, boardPath []string, frames []Frame, ...) ([]byte, error)
- type Frame
- func AppendBoardFrames(frames []Frame, board *d2target.Diagram, intervalMS int) []Frame
- func RenderSVGFrames(root *d2target.Diagram, boardPath []string, frames []Frame, ...) ([]Frame, [][]byte, error)
- func SVGTimeline(root *d2target.Diagram, boardPath []string, intervalMS, zoomMS int) ([]Frame, error)
- func SceneTimeline(root *d2target.Diagram, intervalMS, zoomMS int) ([]Frame, error)
- func Timeline(root *d2target.Diagram, intervalMS int) ([]Frame, error)
- type IconTimeline
- func (tl *IconTimeline) Active(board *d2target.Diagram) bool
- func (tl *IconTimeline) MissingIconSample(board *d2target.Diagram, startMS, endMS int, samples []int) (int, bool)
- func (tl *IconTimeline) Sample(board, picture *d2target.Diagram, elapsedMS int) *d2target.Diagram
- func (tl *IconTimeline) ScenePicture(board *d2target.Diagram, frame Frame) *d2target.Diagram
- type LayerLeg
- type LayerNavigation
- type LayerPose
- type LayerRouteTiming
- type LayerZoom
- type PullbackPose
Constants ¶
const ProgressGap = 8
ProgressGap is the clear space between the artwork canvas and the line, in output pixels.
const ProgressHeight = 6
ProgressHeight is the maximum playback progress line height in output pixels.
const ProgressTrackOpacity = 0.24
ProgressTrackOpacity is the fraction of the automatic progress color shown in the unplayed part of the bar.
Variables ¶
This section is empty.
Functions ¶
func IsLayerPullback ¶ added in v0.10.1
IsLayerPullback reports whether the route travels through linked ancestors.
func LayerDuration ¶ added in v0.10.1
LayerDuration reads the transition duration from the document root, even when only a subtree will be exported.
func ProgressBoardGap ¶ added in v0.10.1
ProgressBoardGap returns a cut at a board boundary. Leave at least one gap-width of track between cuts and at the ends so a densely repeated tour can still show how much time has elapsed. Coordinates are relative to the bar.
func ProgressColor ¶ added in v0.10.1
func ProgressColor(themeID *int64, overrides *d2target.ThemeOverrides) string
ProgressColor returns the contrast-checked inverse of the theme's canvas.
func ProgressLineHeight ¶ added in v0.10.1
ProgressLineHeight is 1% of the shorter canvas side, rounded to whole pixels.
func ProgressTickX ¶ added in v0.10.1
ProgressTickX places a board boundary on the output clock. An internal boundary stays inside the canvas even if its time rounds to an edge.
func PullbackPosition ¶ added in v0.10.1
PullbackPosition maps route progress to a leg and its local progress. The easing starts and stops the whole camera move, rather than each leg.
func ResolveProgressColor ¶ added in v0.10.1
func ResolveProgressColor(themeID *int64, overrides *d2target.ThemeOverrides, explicit string) (string, error)
ResolveProgressColor selects explicit paint or the theme canvas's automatic ink.
func TranslationTracks ¶ added in v0.10.1
TranslationTracks returns rigid translations of unchanged artwork in a validated board. A nil result keeps the original render-and-hold sequence. Matrices translate the first sample's integer geometry; compiler-provided motion offsets distinguish continuous trajectories from authored holds.
func ValidateSVGIconLoop ¶ added in v0.10.1
ValidateSVGIconLoop checks an explicitly selected animation without creating per-frame pictures. A single drawable SVG runs its icon clocks continuously.
func WrapTimed ¶ added in v0.10.0
func WrapTimed(rootDiagram *d2target.Diagram, svgs [][]byte, renderOpts d2svg.RenderOpts, durationsMS []int) ([]byte, error)
WrapTimed composes independently rendered SVG frames on a shared playback clock.
func WrapTimeline ¶ added in v0.10.1
func WrapTimeline(rootDiagram *d2target.Diagram, boardPath []string, frames []Frame, svgs [][]byte, renderOpts d2svg.RenderOpts, durationMS int) ([]byte, error)
WrapTimeline plays every frame in order, zooming through linked layers. Activating a layer link pauses the tour to explore that layer and its steps. boardPath identifies the selected subtree relative to the document root.
Types ¶
type Frame ¶ added in v0.10.0
type Frame struct {
Diagram *d2target.Diagram
DurationMS int
// TweenSample distinguishes an already sampled transition from a board
// whose independent shape and connection animations still need sampling.
TweenSample bool
// ElapsedMS is the local time of a sampled frame within its board.
ElapsedMS int
// contains filtered or unexported fields
}
Frame is a diagram held for a duration on the playback timeline.
func AppendBoardFrames ¶ added in v0.10.0
AppendBoardFrames expands one validated, drawable board. Raster exporters impose their own traversal limits before expanding its samples.
func RenderSVGFrames ¶ added in v0.10.1
func RenderSVGFrames(root *d2target.Diagram, boardPath []string, frames []Frame, opts d2svg.RenderOpts, zoomMS int, render func(*d2target.Diagram) ([]byte, error)) ([]Frame, [][]byte, error)
RenderSVGFrames renders the artwork for WrapTimeline. A straight or eased translation of otherwise identical artwork needs only a few reference poses. Check the emitted SVG too, since bundling, appendices and custom renderers can change it.
func SVGTimeline ¶ added in v0.10.1
func SVGTimeline(root *d2target.Diagram, boardPath []string, intervalMS, zoomMS int) ([]Frame, error)
SVGTimeline also accounts for the travel time of linked-layer zooms when rendering a selected subtree of the document.
func SceneTimeline ¶ added in v0.10.1
SceneTimeline prepares board-local icon clocks for finite native playback. A camera can revisit an exact board at time zero or extend its final hold.
func Timeline ¶ added in v0.10.0
Timeline returns the same root, layer, scenario and step order as a normal multiboard export, inserting incoming transition samples immediately before each board.
func (Frame) Picture ¶ added in v0.10.1
Picture returns the artwork for this frame, including any render-time icon schedule.
func (Frame) StartFraction ¶ added in v0.10.1
StartFraction restores the fraction of a millisecond omitted by ElapsedMS for uniform tweens. Explicit millisecond boundaries have no remainder.
type IconTimeline ¶ added in v0.10.1
type IconTimeline struct {
// contains filtered or unexported fields
}
IconTimeline can seek to any time within an authored board. Entry states retain only the copies still in flight, independently of the length of a hold.
func NewIconTimeline ¶ added in v0.10.1
func NewIconTimeline(root *d2target.Diagram, intervalMS int) (*IconTimeline, error)
func (*IconTimeline) Active ¶ added in v0.10.1
func (tl *IconTimeline) Active(board *d2target.Diagram) bool
func (*IconTimeline) MissingIconSample ¶ added in v0.10.1
func (tl *IconTimeline) MissingIconSample(board *d2target.Diagram, startMS, endMS int, samples []int) (int, bool)
MissingIconSample chooses a time inside the board's hold if the proposed storyboard samples all miss the moving artwork. Work depends on the number of streams, regardless of how long it takes for the next departure.
func (*IconTimeline) Sample ¶ added in v0.10.1
Sample keeps the route of picture (which may be a tween), and evaluates the icon clock at elapsedMS since the beginning of the authored board.
func (*IconTimeline) ScenePicture ¶ added in v0.10.1
ScenePicture gives a fixed native scene its carried icons and launch clock. Render that scene with timestamps measured from the beginning of its board.
type LayerLeg ¶ added in v0.10.1
LayerLeg visits two boards through a shape on their enclosing board.
type LayerNavigation ¶ added in v0.10.1
type LayerNavigation struct {
// contains filtered or unexported fields
}
LayerNavigation resolves links between authored boards in a validated export tree. Tween samples are artwork, never navigation destinations.
func NewLayerNavigation ¶ added in v0.10.1
func NewLayerNavigation(root *d2target.Diagram, boardPath []string) *LayerNavigation
NewLayerNavigation indexes a selected subtree. boardPath is its absolute D2 target path relative to root, e.g. ["layers", "api"].
func (*LayerNavigation) HasLayerPortal ¶ added in v0.10.1
func (nav *LayerNavigation) HasLayerPortal() bool
HasLayerPortal reports whether an authored shape can take the camera between two drawable boards in this export tree.
func (*LayerNavigation) Route ¶ added in v0.10.1
func (nav *LayerNavigation) Route(from, to *d2target.Diagram) []LayerLeg
Route follows real portals up to the common layer and back down into the destination. A direct link takes precedence over the longer tree path. No route exists between two steps on the same layer or across a missing portal.
type LayerPose ¶ added in v0.10.1
type LayerPose struct {
Scale, DX, DY, Opacity float64
}
LayerPose maps artwork to viewport coordinates as scale*point + (DX,DY).
type LayerRouteTiming ¶ added in v0.10.1
type LayerRouteTiming struct {
// contains filtered or unexported fields
}
LayerRouteTiming divides the configured movement time among the legs of a linked-layer route and holds each intermediate board at its resting pose.
func NewLayerRouteTiming ¶ added in v0.10.1
func NewLayerRouteTiming(legs, movementMS int) LayerRouteTiming
NewLayerRouteTiming plans a route with the configured aggregate movement time.
func (LayerRouteTiming) DurationMS ¶ added in v0.10.1
func (t LayerRouteTiming) DurationMS() int
DurationMS returns the full travel window, including intermediate holds.
func (LayerRouteTiming) Leg ¶ added in v0.10.1
func (t LayerRouteTiming) Leg(index int) (startMS, durationMS float64)
Leg returns the start and duration of one camera move in milliseconds.
type LayerZoom ¶ added in v0.10.1
type LayerZoom struct {
Focus *d2target.Shape
Inward bool
// contains filtered or unexported fields
}
LayerZoom moves through the linking shape on the enclosing board.
func (LayerZoom) Portal ¶ added in v0.10.1
Portal returns the camera's focus in its enclosing board's viewport.
type PullbackPose ¶ added in v0.10.1
PullbackPose includes a blur radius in output pixels, independent of scale.
func PullbackPoses ¶ added in v0.10.1
func PullbackPoses(viewport, previous, portal, next image.Rectangle, local float64) (parent, child PullbackPose)
PullbackPoses returns the parent and child on the same camera. The previous portal is in child coordinates. The next portal is in the next ancestor's coordinates. Empty neighbors mark the first and last boards.
Source Files
¶
- compact.go
- d2animate.go
- icon_timeline.go
- layer_icon_clocks.go
- layer_links.go
- layer_playback.go
- layer_pullback.go
- layer_route_timing.go
- layer_timeline.go
- layer_viewport.go
- layer_zoom.go
- motion_candidates.go
- native_motion.go
- partial_motion.go
- progress.go
- progress_ticks.go
- render_timeline.go
- static_shapes.go
- timeline.go
- translation.go
- wire_motion.go