Skip to content

Commit

Permalink
evy: Fix initial cursor position in SVG export
Browse files Browse the repository at this point in the history
Fix initial cursor position in SVG export. We had it at `0 0` which is correct,
only that it wasn't transposed. Which means that the Evy program

	circle N

would render a circle at `0 100` instead of `0 0`.
  • Loading branch information
juliaogris committed Aug 23, 2024
1 parent 1647446 commit 23d63a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/lab/samples/intro/img/coords-30-60.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pkg/cli/svg/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func NewGraphicsRuntime() *GraphicsRuntime {
},
},
}
rt.x = rt.transformX(0)
rt.y = rt.transformY(0)
rt.Clear("white")
return rt
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/cli/svg/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ func TestRuntimeCircleRect(t *testing.T) {
rt.Color("red")
rt.Circle(10)
rt.Gridn(10, "hsl(0deg 100% 0% / 50%)")

assertSVG(t, "testdata/circle-rect.svg", rt)
}

func TestRuntimeQuarterCircle(t *testing.T) {
rt := newTestRuntime()
rt.Circle(100) // should be centered at 0 0
assertSVG(t, "testdata/quarter-circle.svg", rt)
}

func TestRuntimeEllipse(t *testing.T) {
rt := newTestRuntime()
rt.Ellipse(50, 85, 30, 10, 0, 0, 0)
Expand Down
6 changes: 6 additions & 0 deletions pkg/cli/svg/testdata/quarter-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 23d63a2

Please sign in to comment.