-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added Style Attribute customisation for Shapes
feat: Added more helper methods for Diagram.cs
- Loading branch information
Showing
6 changed files
with
157 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
using D2; | ||
using D2.Enums; | ||
using D2.Writers; | ||
Check failure on line 3 in Examples/Program.cs GitHub Actions / build
|
||
|
||
var A = new Shape("A", "Starting Point"); | ||
var B = new Shape("B", "Ending Point"); | ||
var C = new Shape("C", "Middle Point", ShapeType.Hexagon); | ||
|
||
A.WithStyle("fill", "green"); | ||
B.WithStyle("fill", "red"); | ||
C.WithStyle("fill", "blue"); | ||
|
||
var basicTemplate = Diagram.Create() | ||
.Add(A) | ||
.Add(B) | ||
.Add(C) | ||
.Add(new Connection(A, C)) | ||
.Add(new Connection(C, B, "Hello World!")); | ||
.Connect(A, C) | ||
.Connect(C, B); | ||
|
||
// Each component overrides ToString() to return the D2 code for that instance | ||
Console.WriteLine(basicTemplate); | ||
Console.WriteLine("Basic Template:"); | ||
Console.WriteLine(basicTemplate); | ||
|
||
var styledTemplate = Diagram.Create() | ||
.CreateShape("D", type: ShapeType.Circle) | ||
.CreateShape("E", "Styled Shape", ShapeType.Hexagon) | ||
.CreateShape("F", "Styled Diamond Shape", ShapeType.Diamond) | ||
.CreateDirectionalConnection("D", "E", "Styled Connection", new ArrowheadOptions(ArrowheadType.CrowsFootManyRequired, "Filled Triangle")) | ||
.CreateBidirectionalConnection("E", "F", "Bidirectional Connection", | ||
new ArrowheadOptions(ArrowheadType.CrowsFootManyRequired), | ||
new ArrowheadOptions(ArrowheadType.CrowsFootManyRequired)) | ||
.CreateConnection("F", "D") | ||
.CreateMarkdownShape("G", @" # I can do headers | ||
- lists | ||
- lists | ||
And other normal markdown stuff") | ||
.CreateLatexShape("H", @"\\lim_{h \\rightarrow 0 } \\frac{f(x+h)-f(x)}{h}") | ||
.CreateBidirectionalConnection("G", "H"); | ||
|
||
Console.WriteLine("Styled Template:"); | ||
Console.WriteLine(styledTemplate); |