Skip to content

Commit

Permalink
fix: Accept strokeWidth as float, cast to int (#28)
Browse files Browse the repository at this point in the history
* fix: Accept strokeWidth as float, cast to int

* fix: Round up strokeWidth
  • Loading branch information
sindrel authored Oct 12, 2023
1 parent d7dd81c commit 36a3830
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions internal/conversion/gliffy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -165,7 +166,7 @@ func AddElements(addChildren bool, input datastr.ExcalidrawScene, objects []data
shape.DashStyle = StrokeStyleConvExcGliffy(element.StrokeStyle)
shape.FillColor = FillColorConvExcGliffy(element.BackgroundColor)
shape.StrokeColor = element.StrokeColor
shape.StrokeWidth = element.StrokeWidth
shape.StrokeWidth = int64(math.Round(element.StrokeWidth))
shape.Opacity = element.Opacity * 0.01

if element.FillStyle != "solid" {
Expand Down Expand Up @@ -208,7 +209,7 @@ func AddElements(addChildren bool, input datastr.ExcalidrawScene, objects []data

line.DashStyle = StrokeStyleConvExcGliffy(element.StrokeStyle)
line.StrokeColor = element.StrokeColor
line.StrokeWidth = element.StrokeWidth
line.StrokeWidth = int64(math.Round(element.StrokeWidth))
line.FillColor = "none"
line.StartArrowRotation = "auto"
line.EndArrowRotation = "auto"
Expand Down
2 changes: 1 addition & 1 deletion internal/datastructures/excalidraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ExcalidrawScene struct {
StrokeColor string `json:"strokeColor"`
StrokeSharpness string `json:"strokeSharpness"`
StrokeStyle string `json:"strokeStyle"`
StrokeWidth int64 `json:"strokeWidth"`
StrokeWidth float64 `json:"strokeWidth"`
Text string `json:"text"`
TextAlign string `json:"textAlign"`
Type string `json:"type"`
Expand Down

0 comments on commit 36a3830

Please sign in to comment.