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
|
// addLifelineEdges adds a new edge for each actor in the graph that represents the its lifeline
|
||||||
// ┌──────────────┐
|
// . ┌──────────────┐
|
||||||
// │ actor │
|
// . │ actor │
|
||||||
// └──────┬───────┘
|
// . └──────┬───────┘
|
||||||
// │
|
// . │
|
||||||
// │ lifeline
|
// . │ lifeline
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
func (sd *sequenceDiagram) addLifelineEdges() {
|
func (sd *sequenceDiagram) addLifelineEdges() {
|
||||||
endY := 0.
|
endY := 0.
|
||||||
if len(sd.messages) > 0 {
|
if len(sd.messages) > 0 {
|
||||||
|
|
@ -433,17 +433,17 @@ func (sd *sequenceDiagram) placeNotes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// placeSpans places spans over the object lifeline
|
// placeSpans places spans over the object lifeline
|
||||||
// ┌──────────┐
|
// . ┌──────────┐
|
||||||
// │ actor │
|
// . │ actor │
|
||||||
// └────┬─────┘
|
// . └────┬─────┘
|
||||||
// ┌─┴──┐
|
// . ┌─┴──┐
|
||||||
// │ │
|
// . │ │
|
||||||
// |span|
|
// . |span|
|
||||||
// │ │
|
// . │ │
|
||||||
// └─┬──┘
|
// . └─┬──┘
|
||||||
// │
|
// . │
|
||||||
// lifeline
|
// . lifeline
|
||||||
// │
|
// . │
|
||||||
func (sd *sequenceDiagram) placeSpans() {
|
func (sd *sequenceDiagram) placeSpans() {
|
||||||
// quickly find the span center X
|
// quickly find the span center X
|
||||||
rankToX := make(map[int]float64)
|
rankToX := make(map[int]float64)
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ func ParseValue(value string) (d2ast.Value, error) {
|
||||||
// - streaming parser isn't really helpful.
|
// - streaming parser isn't really helpful.
|
||||||
// - just read into a string even and decode runes forward/back as needed
|
// - 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...
|
// - the whole file essentially exists within the parser as the AST anyway...
|
||||||
|
//
|
||||||
// TODO: ast struct that combines map & errors and pass that around
|
// TODO: ast struct that combines map & errors and pass that around
|
||||||
type parser struct {
|
type parser struct {
|
||||||
path string
|
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: 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
|
// 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.
|
// 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: 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?
|
// TODO: get rid of lookaheadPos or at least never use directly. maybe rename to beforePeekPos?
|
||||||
|
//
|
||||||
// or better yet keep positions in the lookahead buffer.
|
// 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
|
// ok so plan here is to get rid of lookaheadPos and add a rewindPos that stores
|
||||||
// the pos to rewind to.
|
// 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
|
// 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
|
// 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
|
// buffer says how close the segment can be, on both axes, to other segments given
|
||||||
// │ │
|
// . │ │
|
||||||
// │ │
|
// . │ │
|
||||||
// │ │
|
// . │ │
|
||||||
// │ │
|
// . │ │
|
||||||
// │ non-overlap
|
// . │ non-overlap
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// │ segment
|
// . │ segment
|
||||||
// │ │
|
// . │ │
|
||||||
// │ │ ceil
|
// . │ │ ceil
|
||||||
// │ │ │
|
// . │ │ │
|
||||||
// │ │
|
// . │ │
|
||||||
// floor │ │
|
// . floor │ │
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// NOTE: the assumption is that all segments given are orthogonal
|
// NOTE: the assumption is that all segments given are orthogonal
|
||||||
func (segment *Segment) GetBounds(segments []*Segment, buffer float64) (float64, float64) {
|
func (segment *Segment) GetBounds(segments []*Segment, buffer float64) (float64, float64) {
|
||||||
ceil := math.Inf(1)
|
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)
|
// p is the prev point (used to calculate slope)
|
||||||
// s is the point on the actual shape border that'll be returned
|
// s is the point on the actual shape border that'll be returned
|
||||||
//
|
//
|
||||||
// p
|
// . p
|
||||||
// │
|
// . │
|
||||||
// │
|
// . │
|
||||||
// ▼
|
// . ▼
|
||||||
// ┌────r─────────────────────────┐
|
// . ┌────r─────────────────────────┐
|
||||||
// │ │
|
// . │ │
|
||||||
// │ │ │
|
// . │ │ │
|
||||||
// │ │ xxxxxxxx │
|
// . │ │ xxxxxxxx │
|
||||||
// │ ▼ xxxxx xxxx │
|
// . │ ▼ xxxxx xxxx │
|
||||||
// │ sxxx xx │
|
// . │ sxxx xx │
|
||||||
// │ x xx │
|
// . │ x xx │
|
||||||
// │ xx xx │
|
// . │ xx xx │
|
||||||
// │ x xx │
|
// . │ x xx │
|
||||||
// │ xx xxx │
|
// . │ xx xxx │
|
||||||
// │ xxxx xxxx │
|
// . │ xxxx xxxx │
|
||||||
// └──────xxxxxxxxxxxxxx──────────┘
|
// . └──────xxxxxxxxxxxxxx──────────┘
|
||||||
func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo.Point {
|
func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo.Point {
|
||||||
if shape.Is("") || shape.IsRectangular() {
|
if shape.Is("") || shape.IsRectangular() {
|
||||||
return rectBorderPoint
|
return rectBorderPoint
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ func init() {
|
||||||
// Ruler allows for effiecient and convenient text drawing.
|
// Ruler allows for effiecient and convenient text drawing.
|
||||||
//
|
//
|
||||||
// To create a Ruler object, use the New constructor:
|
// To create a Ruler object, use the New constructor:
|
||||||
|
//
|
||||||
// txt := text.New(pixel.ZV, text.NewAtlas(face, text.ASCII))
|
// 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
|
// 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.
|
// 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:
|
// 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)))
|
// 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
|
// Similarly to IMDraw, Ruler functions as a buffer. It implements io.Writer interface, so writing
|
||||||
// text to it is really simple:
|
// text to it is really simple:
|
||||||
|
//
|
||||||
// fmt.Print(txt, "Hello, world!")
|
// fmt.Print(txt, "Hello, world!")
|
||||||
//
|
//
|
||||||
// Newlines, tabs and carriage returns are supported.
|
// 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:
|
// Finally, if we want the written text to show up on some other Target, we can draw it:
|
||||||
|
//
|
||||||
// txt.Draw(target)
|
// txt.Draw(target)
|
||||||
//
|
//
|
||||||
// Ruler exports two important fields: Orig and Dot. Dot is the position where the next character
|
// 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.
|
// will be initially set to orig.
|
||||||
//
|
//
|
||||||
// Here we create a Ruler capable of drawing ASCII characters using the Go Regular font.
|
// Here we create a Ruler capable of drawing ASCII characters using the Go Regular font.
|
||||||
|
//
|
||||||
// ttf, err := truetype.Parse(goregular.TTF)
|
// ttf, err := truetype.Parse(goregular.TTF)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// panic(err)
|
// panic(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue