MCPcopy Index your code
hub / github.com/gonum/plot / NewImage

Function NewImage

plotter/image.go:29–52  ·  view source on GitHub ↗

NewImage creates a new image plotter. Image will plot img inside the rectangle defined by the (xmin, ymin) and (xmax, ymax) points given in the data space. The img will be scaled to fit inside the rectangle.

(img image.Image, xmin, ymin, xmax, ymax float64)

Source from the content-addressed store, hash-verified

27// (xmin, ymin) and (xmax, ymax) points given in the data space.
28// The img will be scaled to fit inside the rectangle.
29func NewImage(img image.Image, xmin, ymin, xmax, ymax float64) *Image {
30 if src, ok := img.(*image.Uniform); ok {
31 img = uniform{
32 src,
33 image.Rect(0, 0, int(xmax-xmin+0.5), int(ymax-ymin+0.5)),
34 }
35 }
36 bounds := img.Bounds()
37 cols := bounds.Dx()
38 rows := bounds.Dy()
39 dx := math.Abs(xmax-xmin) / float64(cols)
40 dy := math.Abs(ymax-ymin) / float64(rows)
41 return &Image{
42 img: img,
43 cols: cols,
44 rows: rows,
45 xmin: xmin,
46 xmax: xmax,
47 dx: dx,
48 ymin: ymin,
49 ymax: ymax,
50 dy: dy,
51 }
52}
53
54// Plot implements the Plot method of the plot.Plotter interface.
55func (img *Image) Plot(c draw.Canvas, p *plot.Plot) {

Callers 5

ExampleImageFunction · 0.92
ExampleImage_logFunction · 0.92
ExampleImage_uniformFunction · 0.92
plotRasterizedMethod · 0.85
PlotMethod · 0.85

Calls 1

BoundsMethod · 0.80

Tested by 3

ExampleImageFunction · 0.74
ExampleImage_logFunction · 0.74
ExampleImage_uniformFunction · 0.74