// SPDX-License-Identifier: MIT// Derived from Rough.js 4.0.4, Copyright (c) 2019 Preet Shihn.package roughimportfunc rotatePoints( []Point, Point, float64) {iflen() == 0 {return } , := [0], [1] := (math.Pi / 180) * , := math.Cos(), math.Sin()for := range { , := [][0], [][1]// JavaScript rounds each multiplication before the following add or // subtract. The jsNumberStep calls prevent Go from fusing these // expressions into FMAs, whose one-ULP difference is observable at the // renderer's length=200 roughness-gain boundary. := jsNumberStep(( - ) * ) := jsNumberStep(( - ) * ) := jsNumberStep(( - ) * ) := jsNumberStep(( - ) * ) [][0] = - + [][1] = + + }}func rotateLines( []Line, Point, float64) { := make([]Point, 0, len()*2)for := range { = append(, [][0], [][1]) }rotatePoints(, , )for := range { [][0], [][1] = [*2], [*2+1] }}func lineLength( Line) float64 {returnmath.Sqrt(math.Pow([0][0]-[1][0], 2) +math.Pow([0][1]-[1][1], 2), )}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.