gonum / plot

A repository for plotting and visualizing data
BSD 3-Clause "New" or "Revised" License
2.75k stars 204 forks source link

vg: consider migrating vg.Length and vg.Point to x/image/math/fixed #265

Open sbinet opened 8 years ago

sbinet commented 8 years ago

The package golang.org/x/image/math/fixed defines fixed point integer types such as fixed.Int26_6 and fixed.Int52_12 (and corresponding Point and Rectangle struct types).

migrating vg.Length from:

package vg
type Length float64

to:

package vg
import "golang.org/x/image/math/fixed"
type Length fixed.Int26_6

would (perhaps) ease interoperabiliy with all the other 2D packages.

eaburns commented 8 years ago

I don't think we should do this. The image/math/fixed package is there for rasterizing images. Rasterization uses integer-addressed pixels, and fixed-point values make this easier. Vg deals with vector graphics, which work in floating point space. Sure, rounding may happen in the way-way-back end, but all the libraries called by the Canvases provide work in floats. Using fixed-point types would make our lives more difficult.

sbinet commented 8 years ago

fair enough. what about shiny/unit.Unit then? https://godoc.org/golang.org/x/exp/shiny/unit

(yes, shiny is still experimental...)

eaburns commented 8 years ago

I may be OK with that, but I wouldn't be in a huge rush to do it. I'm not bothered because shiny's experimental; it's made by "core go developers" and sits in a github.com/golang repo, so it's guaranteed to be viewed as the standard UI package for Go. The thing that bothers me is that a package like 'unit' isn't shiny specific; it's more generally applicable, for example, gonum/plot could very well use it. I would prefer to wait to see if they move it out of the shiny directory. It seems strange to create a plot using a seemingly-shiny-specific unit package.