Skip to content

Commit

Permalink
Merge pull request #58 from owulveryck/control-pane-svg
Browse files Browse the repository at this point in the history
control pane svg
  • Loading branch information
owulveryck authored Jan 17, 2023
2 parents 9d9fd2b + 8ea1bb1 commit 4bfe4a9
Show file tree
Hide file tree
Showing 19 changed files with 1,087 additions and 785 deletions.
26 changes: 17 additions & 9 deletions components/wardley/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ const (

// A Component is an element of the map
type Component struct {
id int64
Placement image.Point // The placement of the component on a rectangle 100x100
Label string
LabelPlacement image.Point // LabelPlacement is relative to the placement
Type wardleyToGo.ComponentType
RenderingLayer int //The position of the element on the picture
Configured bool
EvolutionPos int
Color color.Color
id int64
Placement image.Point // The placement of the component on a rectangle 100x100
Label string
LabelPlacement image.Point // LabelPlacement is relative to the placement
Type wardleyToGo.ComponentType
RenderingLayer int //The position of the element on the picture
Configured bool
EvolutionPos int
Color color.Color
AbsoluteVisibility int
}

// GetAbsoluteVisibility returns the visibility of the component as seen from the anchor
func (c *Component) GetAbsoluteVisibility() int {
return c.AbsoluteVisibility
}

func (c *Component) Attributes() []dotencoding.Attribute {
Expand Down Expand Up @@ -143,6 +149,7 @@ func (c *Component) marshalSVGPipeline(e *xml.Encoder, canvas image.Rectangle, c
return e.Encode(svg.Transform{
Translate: coords,
Components: components,
//Classes: []string{fmt.Sprintf("visibility%v", c.AbsoluteVisibility)},
})
}
func (c *Component) marshalSVG(e *xml.Encoder, canvas image.Rectangle, col svg.Color) error {
Expand Down Expand Up @@ -204,6 +211,7 @@ func (c *Component) marshalSVG(e *xml.Encoder, canvas image.Rectangle, col svg.C
return e.Encode(svg.Transform{
Translate: coords,
Components: components,
//Classes: []string{fmt.Sprintf("visibility%v", c.AbsoluteVisibility)},
})
}

Expand Down
20 changes: 14 additions & 6 deletions components/wardley/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ import (
)

type Collaboration struct {
F, T wardleyToGo.Component
Label string
Type wardleyToGo.EdgeType
RenderingLayer int
Visibility int
F, T wardleyToGo.Component
Label string
Type wardleyToGo.EdgeType
RenderingLayer int
Visibility int
AbsoluteVisibility int
}

// GetAbsoluteVisibility returns the visibility of the component as seen from the anchor
func (c *Collaboration) GetAbsoluteVisibility() int {
return c.AbsoluteVisibility
}

func (c *Collaboration) Attributes() []dotencoding.Attribute {
Expand Down Expand Up @@ -74,6 +80,8 @@ func (c *Collaboration) MarshalSVG(e *xml.Encoder, canvas image.Rectangle) error
F: coordsF,
T: coordsT,
StrokeWidth: "1",
//Class: []string{fmt.Sprintf("visibility%v", c.AbsoluteVisibility)},
Class: []string{},
}
switch c.Type {
case RegularEdge:
Expand All @@ -82,7 +90,7 @@ func (c *Collaboration) MarshalSVG(e *xml.Encoder, canvas image.Rectangle) error
line.MarkerEnd = "url(#arrow)"
line.StrokeDashArray = []int{5, 5}
line.Stroke = svg.Red
line.Class = "evolutionEdge"
line.Class = append(line.Class, "evolutionEdge")
case EvolvedEdge:
line.Stroke = svg.Red
}
Expand Down
22 changes: 11 additions & 11 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" />

<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("wtg.wasm"), go.importObject)
.then((result) => {
go.run(result.instance);
})
.then(instance => {
onceLoaded(document);
});
</script>
</head>
<body>
<pre id="editor">
Expand Down Expand Up @@ -114,6 +103,17 @@

<script src="script.js"></script>
<script src="svg-pan-zoom.min.js" type="text/javascript" charset="utf-8"></script>
<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("wtg.wasm"), go.importObject)
.then((result) => {
go.run(result.instance);
})
.then(instance => {
onceLoaded(document);
});
</script>

</body>
</html>
Loading

0 comments on commit 4bfe4a9

Please sign in to comment.