...

Package label

import "oss.terrastruct.com/d2/lib/label"
Overview
Index

Overview ▾

Constants

const CENTER_LABEL_POSITION = 2.0 / 4.0

These are % locations where labels will be placed along the connection

const LEFT_LABEL_POSITION = 1.0 / 4.0

This is the space between a node border and its outside label

const PADDING = 5
const RIGHT_LABEL_POSITION = 3.0 / 4.0

type Position

type Position int8
const (
    Unset Position = iota

    OutsideTopLeft
    OutsideTopCenter
    OutsideTopRight

    OutsideLeftTop
    OutsideLeftMiddle
    OutsideLeftBottom

    OutsideRightTop
    OutsideRightMiddle
    OutsideRightBottom

    OutsideBottomLeft
    OutsideBottomCenter
    OutsideBottomRight

    InsideTopLeft
    InsideTopCenter
    InsideTopRight

    InsideMiddleLeft
    InsideMiddleCenter
    InsideMiddleRight

    InsideBottomLeft
    InsideBottomCenter
    InsideBottomRight

    UnlockedTop
    UnlockedMiddle
    UnlockedBottom
)

func FromString

func FromString(s string) Position

func (Position) GetPointOnBox

func (labelPosition Position) GetPointOnBox(box *geo.Box, padding, width, height float64) *geo.Point

func (Position) GetPointOnRoute

func (labelPosition Position) GetPointOnRoute(route geo.Route, strokeWidth, labelPercentage, width, height float64) (point *geo.Point, index int)

return the top left point of a width x height label at the given label position on the route also return the index of the route segment that point is on

func (Position) IsEdgePosition

func (position Position) IsEdgePosition() bool

func (Position) IsOnEdge

func (position Position) IsOnEdge() bool

func (Position) IsOutside

func (position Position) IsOutside() bool

func (Position) IsShapePosition

func (position Position) IsShapePosition() bool

func (Position) IsUnlocked

func (position Position) IsUnlocked() bool

func (Position) Mirrored

func (position Position) Mirrored() Position

func (Position) String

func (position Position) String() string