23 lines
522 B
Go
23 lines
522 B
Go
|
package imaging
|
||
|
|
||
|
import (
|
||
|
"image"
|
||
|
"image/color"
|
||
|
)
|
||
|
|
||
|
// CreateCanvas creates a new image canvas with the specified width and height
|
||
|
func createCanvas(width, height int) *image.RGBA {
|
||
|
canvas := image.NewRGBA(image.Rect(0, 0, width, height))
|
||
|
clearCanvas(canvas, color.Black)
|
||
|
return canvas
|
||
|
}
|
||
|
|
||
|
func clearCanvas(img *image.RGBA, backgroundColor color.Color) {
|
||
|
bounds := img.Bounds()
|
||
|
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
|
||
|
for x := bounds.Min.X; x < bounds.Max.X; x++ {
|
||
|
img.Set(x, y, backgroundColor)
|
||
|
}
|
||
|
}
|
||
|
}
|