diff --git a/frontend/lab/samples/ifs/img/randrect.evy b/frontend/lab/samples/ifs/img/randrect.evy index 337e833f..a933d1bf 100644 --- a/frontend/lab/samples/ifs/img/randrect.evy +++ b/frontend/lab/samples/ifs/img/randrect.evy @@ -1,19 +1,11 @@ fill (hsl 270 100 50 10) width 0.2 for range 60 - x := roundedRand1 * 100 - y := roundedRand1 * 100 - s1 := roundedRand1 * 25 + 2 - s2 := roundedRand1 * 25 + 2 + x := rand1 * 100 + y := rand1 * 100 + s1 := rand1 * 25 + 2 + s2 := rand1 * 25 + 2 move x-s1*0.5 y-s2*0.5 rect s1 s2 end - -// roundedRand1 is a rounding rand1 function, to avoid rounding differences on -// Mac and Linux. -func roundedRand1:num - r := rand1 * 1024 - r = round r - return r / 1024 -end diff --git a/frontend/lab/samples/ifs/img/randrect.svg b/frontend/lab/samples/ifs/img/randrect.svg index bc7b339f..4533d72c 100644 --- a/frontend/lab/samples/ifs/img/randrect.svg +++ b/frontend/lab/samples/ifs/img/randrect.svg @@ -9,65 +9,365 @@ > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkg/cli/svg/runtime.go b/pkg/cli/svg/runtime.go index b540e816..eeaa04bd 100644 --- a/pkg/cli/svg/runtime.go +++ b/pkg/cli/svg/runtime.go @@ -90,7 +90,14 @@ func (rt *GraphicsPlatform) transformY(y float64) float64 { } func (rt *GraphicsPlatform) scale(s float64) float64 { - return scaleFactor * s + // The float64 cast here acts as a barrier against a fused multiply/ + // subtraction ARM64 instruction so that this multiply and a subtraction + // done by the caller of this function are not fused into a single ARM64 + // instruction. This causes rounding differences when it is not used + // and causes the generated SVG files to have slight differences depending + // on which platform it is run. + // https://go.dev/ref/spec#Floating_point_operators + return float64(scaleFactor * s) } func (rt *GraphicsPlatform) nonDefaultAttr() Attr {