MCPcopy Create free account
hub / github.com/cogentcore/core / Resize

Method Resize

plot/plot.go:118–128  ·  view source on GitHub ↗

Resize sets the size of the output image to given size. Does nothing if already the right size.

(sz image.Point)

Source from the content-addressed store, hash-verified

116// Resize sets the size of the output image to given size.
117// Does nothing if already the right size.
118func (pt *Plot) Resize(sz image.Point) {
119 if pt.Pixels != nil {
120 ib := pt.Pixels.Bounds().Size()
121 if ib == sz {
122 pt.Size = sz
123 pt.Paint.UnitContext.DPI = pt.DPI
124 return // already good
125 }
126 }
127 pt.SetPixels(image.NewRGBA(image.Rectangle{Max: sz}))
128}
129
130func (pt *Plot) SaveImage(filename string) error {
131 return imagex.Save(pt.Pixels, filename)

Callers 10

drawConfigMethod · 0.95
TestPlotFunction · 0.45
TestLineFunction · 0.45
TestScatterFunction · 0.45
TestLabelsFunction · 0.45
TestBarChartFunction · 0.45
TestBarChartErrFunction · 0.45
TestBarChartStackFunction · 0.45
TestErrBarFunction · 0.45
updatePlotMethod · 0.45

Calls 3

SetPixelsMethod · 0.95
SizeMethod · 0.65
BoundsMethod · 0.45

Tested by 8

TestPlotFunction · 0.36
TestLineFunction · 0.36
TestScatterFunction · 0.36
TestLabelsFunction · 0.36
TestBarChartFunction · 0.36
TestBarChartErrFunction · 0.36
TestBarChartStackFunction · 0.36
TestErrBarFunction · 0.36