commit
6614000fe5
8 changed files with 100 additions and 92 deletions
|
|
@ -355,13 +355,13 @@ func (sd *sequenceDiagram) placeActors() {
|
|||
}
|
||||
|
||||
// addLifelineEdges adds a new edge for each actor in the graph that represents the its lifeline
|
||||
// ┌──────────────┐
|
||||
// │ actor │
|
||||
// └──────┬───────┘
|
||||
// │
|
||||
// │ lifeline
|
||||
// │
|
||||
// │
|
||||
// . ┌──────────────┐
|
||||
// . │ actor │
|
||||
// . └──────┬───────┘
|
||||
// . │
|
||||
// . │ lifeline
|
||||
// . │
|
||||
// . │
|
||||
func (sd *sequenceDiagram) addLifelineEdges() {
|
||||
endY := 0.
|
||||
if len(sd.messages) > 0 {
|
||||
|
|
@ -433,17 +433,17 @@ func (sd *sequenceDiagram) placeNotes() {
|
|||
}
|
||||
|
||||
// placeSpans places spans over the object lifeline
|
||||
// ┌──────────┐
|
||||
// │ actor │
|
||||
// └────┬─────┘
|
||||
// ┌─┴──┐
|
||||
// │ │
|
||||
// |span|
|
||||
// │ │
|
||||
// └─┬──┘
|
||||
// │
|
||||
// lifeline
|
||||
// │
|
||||
// . ┌──────────┐
|
||||
// . │ actor │
|
||||
// . └────┬─────┘
|
||||
// . ┌─┴──┐
|
||||
// . │ │
|
||||
// . |span|
|
||||
// . │ │
|
||||
// . └─┬──┘
|
||||
// . │
|
||||
// . lifeline
|
||||
// . │
|
||||
func (sd *sequenceDiagram) placeSpans() {
|
||||
// quickly find the span center X
|
||||
rankToX := make(map[int]float64)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ func ParseValue(value string) (d2ast.Value, error) {
|
|||
// - streaming parser isn't really helpful.
|
||||
// - just read into a string even and decode runes forward/back as needed
|
||||
// - the whole file essentially exists within the parser as the AST anyway...
|
||||
//
|
||||
// TODO: ast struct that combines map & errors and pass that around
|
||||
type parser struct {
|
||||
path string
|
||||
|
|
@ -315,10 +316,12 @@ func (p *parser) commit() {
|
|||
//
|
||||
// TODO: make each parse function read its delimiter and return nil if not as expected
|
||||
// TODO: lookahead *must* always be empty in between parse calls. you either commit or
|
||||
//
|
||||
// rewind in each function. if you don't, you pass a hint.
|
||||
//
|
||||
// TODO: omg we don't need two buffers, just a single lookahead and an index...
|
||||
// TODO: get rid of lookaheadPos or at least never use directly. maybe rename to beforePeekPos?
|
||||
//
|
||||
// or better yet keep positions in the lookahead buffer.
|
||||
// ok so plan here is to get rid of lookaheadPos and add a rewindPos that stores
|
||||
// the pos to rewind to.
|
||||
|
|
|
|||
|
|
@ -55,24 +55,24 @@ func (segment Segment) Intersections(otherSegment Segment) []*Point {
|
|||
// If there is no floor or ceiling, negative or positive infinity is used, respectively
|
||||
// The direction is inferred, e.g. b/c the passed in segment is vertical, it's inferred we want horizontal bounds
|
||||
// buffer says how close the segment can be, on both axes, to other segments given
|
||||
// │ │
|
||||
// │ │
|
||||
// │ │
|
||||
// │ │
|
||||
// │ non-overlap
|
||||
// │
|
||||
// │
|
||||
// │
|
||||
// │ segment
|
||||
// │ │
|
||||
// │ │ ceil
|
||||
// │ │ │
|
||||
// │ │
|
||||
// floor │ │
|
||||
// │
|
||||
// │
|
||||
// │
|
||||
// │
|
||||
// . │ │
|
||||
// . │ │
|
||||
// . │ │
|
||||
// . │ │
|
||||
// . │ non-overlap
|
||||
// . │
|
||||
// . │
|
||||
// . │
|
||||
// . │ segment
|
||||
// . │ │
|
||||
// . │ │ ceil
|
||||
// . │ │ │
|
||||
// . │ │
|
||||
// . floor │ │
|
||||
// . │
|
||||
// . │
|
||||
// . │
|
||||
// . │
|
||||
// NOTE: the assumption is that all segments given are orthogonal
|
||||
func (segment *Segment) GetBounds(segments []*Segment, buffer float64) (float64, float64) {
|
||||
ceil := math.Inf(1)
|
||||
|
|
|
|||
|
|
@ -175,22 +175,22 @@ func NewShape(shapeType string, box *geo.Box) Shape {
|
|||
// p is the prev point (used to calculate slope)
|
||||
// s is the point on the actual shape border that'll be returned
|
||||
//
|
||||
// p
|
||||
// │
|
||||
// │
|
||||
// ▼
|
||||
// ┌────r─────────────────────────┐
|
||||
// │ │
|
||||
// │ │ │
|
||||
// │ │ xxxxxxxx │
|
||||
// │ ▼ xxxxx xxxx │
|
||||
// │ sxxx xx │
|
||||
// │ x xx │
|
||||
// │ xx xx │
|
||||
// │ x xx │
|
||||
// │ xx xxx │
|
||||
// │ xxxx xxxx │
|
||||
// └──────xxxxxxxxxxxxxx──────────┘
|
||||
// . p
|
||||
// . │
|
||||
// . │
|
||||
// . ▼
|
||||
// . ┌────r─────────────────────────┐
|
||||
// . │ │
|
||||
// . │ │ │
|
||||
// . │ │ xxxxxxxx │
|
||||
// . │ ▼ xxxxx xxxx │
|
||||
// . │ sxxx xx │
|
||||
// . │ x xx │
|
||||
// . │ xx xx │
|
||||
// . │ x xx │
|
||||
// . │ xx xxx │
|
||||
// . │ xxxx xxxx │
|
||||
// . └──────xxxxxxxxxxxxxx──────────┘
|
||||
func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo.Point {
|
||||
if shape.Is("") || shape.IsRectangular() {
|
||||
return rectBorderPoint
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ func init() {
|
|||
// Ruler allows for effiecient and convenient text drawing.
|
||||
//
|
||||
// To create a Ruler object, use the New constructor:
|
||||
//
|
||||
// txt := text.New(pixel.ZV, text.NewAtlas(face, text.ASCII))
|
||||
//
|
||||
// As suggested by the constructor, a Ruler object is always associated with one font face and a
|
||||
|
|
@ -39,15 +40,18 @@ func init() {
|
|||
// contained in the face variable and is capable of drawing ASCII characters.
|
||||
//
|
||||
// Here we create a Ruler object which can draw ASCII and Katakana characters:
|
||||
//
|
||||
// txt := text.New(0, text.NewAtlas(face, text.ASCII, text.RangeTable(unicode.Katakana)))
|
||||
//
|
||||
// Similarly to IMDraw, Ruler functions as a buffer. It implements io.Writer interface, so writing
|
||||
// text to it is really simple:
|
||||
//
|
||||
// fmt.Print(txt, "Hello, world!")
|
||||
//
|
||||
// Newlines, tabs and carriage returns are supported.
|
||||
//
|
||||
// Finally, if we want the written text to show up on some other Target, we can draw it:
|
||||
//
|
||||
// txt.Draw(target)
|
||||
//
|
||||
// Ruler exports two important fields: Orig and Dot. Dot is the position where the next character
|
||||
|
|
@ -93,6 +97,7 @@ type Ruler struct {
|
|||
// will be initially set to orig.
|
||||
//
|
||||
// Here we create a Ruler capable of drawing ASCII characters using the Go Regular font.
|
||||
//
|
||||
// ttf, err := truetype.Parse(goregular.TTF)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue