avyos.dev/pkg/graphics/pixmap
package pixmap
Overview
No package-level documentation is provided.
| Export Group | Count |
|---|---|
| Constants | 0 |
| Variables | 1 |
| Functions | 15 |
| Types | 2 |
Variables
ColorBlack, ColorWhite, ColorRed, ColorGreen, ColorBlue, ColorGray, ColorLightGray, ColorDarkGray, ColorTransparent
var (
ColorBlack = color.NRGBA{R: 0, G: 0, B: 0, A: 255}
ColorWhite = color.NRGBA{R: 255, G: 255, B: 255, A: 255}
ColorRed = color.NRGBA{R: 255, G: 0, B: 0, A: 255}
ColorGreen = color.NRGBA{R: 0, G: 255, B: 0, A: 255}
ColorBlue = color.NRGBA{R: 0, G: 0, B: 255, A: 255}
ColorGray = color.NRGBA{R: 128, G: 128, B: 128, A: 255}
ColorLightGray = color.NRGBA{R: 200, G: 200, B: 200, A: 255}
ColorDarkGray = color.NRGBA{R: 64, G: 64, B: 64, A: 255}
ColorTransparent = color.NRGBA{}
)Functions
BGRA32
func BGRA32(c color.Color) uint32Blend
func Blend(fg, bg color.NRGBA) color.NRGBABlend composites fg over bg in non-premultiplied NRGBA space.
NewColor
func NewColor(r, g, b, a uint8) color.NRGBANewColorHex
func NewColorHex(hex uint32) color.NRGBANewColorRGB
func NewColorRGB(r, g, b uint8) color.NRGBARGB565
func RGB565(c color.Color) uint16RGBA32
func RGBA32(c color.Color) uint32RectCenter
func RectCenter(r image.Rectangle) image.PointRectContainsPoint
func RectContainsPoint(r image.Rectangle, p image.Point) boolRectContainsXY
func RectContainsXY(r image.Rectangle, x, y int) boolRectInsetAll
func RectInsetAll(r image.Rectangle, amount int) image.RectangleRectInsetLTRB
func RectInsetLTRB(r image.Rectangle, top, right, bottom, left int) image.RectangleRectIntersects
func RectIntersects(a, b image.Rectangle) boolRectXYWH
func RectXYWH(x, y, w, h int) image.RectangleToNRGBA
func ToNRGBA(c color.Color) color.NRGBATypes
Buffer
type Buffer struct {
Width int
Height int
Stride int
Format PixelFormat
Data []byte
// contains filtered or unexported fields
}Buffer represents a pixel buffer for drawing. It implements draw.Image with Bounds/At/Set methods.
Functions
BufferFromImage
func BufferFromImage(img image.Image) *BufferBufferFromImage copies any image.Image into a buffer.
New
func New(width, height int) *BufferNew creates a software canvas with the given dimensions.
NewBuffer
func NewBuffer(width, height int) *BufferNewBuffer creates a new buffer with the given dimensions (BGRA format).
Wrap
func Wrap(buf *Buffer) *BufferWrap treats an existing buffer as a software canvas.
Methods
At
func (b *Buffer) At(x, y int) color.ColorAt returns the pixel color at x,y.
Blit
func (b *Buffer) Blit(src *Buffer, x, y int)Blit copies src onto b at x,y with alpha blending.
BlitOpaque
func (b *Buffer) BlitOpaque(src *Buffer, x, y int)BlitOpaque copies src onto b and forces source alpha to 255.
BlitOpaqueRect
func (b *Buffer) BlitOpaqueRect(src *Buffer, srcRect image.Rectangle, x, y int)BlitOpaqueRect copies srcRect from src onto b at x,y and forces alpha to 255.
BlitRect
func (b *Buffer) BlitRect(src *Buffer, srcRect image.Rectangle, x, y int)BlitRect copies srcRect from src onto b at x,y with alpha blending.
BlitScaled
func (b *Buffer) BlitScaled(src *Buffer, srcRect, dstRect image.Rectangle)BlitScaled copies srcRect from src to dstRect on b using bilinear sampling.
Bounds
func (b *Buffer) Bounds() image.RectangleBounds returns buffer bounds for image/draw interoperability.
Buffer
func (b *Buffer) Buffer() *BufferBuffer returns the backing buffer.
Clear
func (b *Buffer) Clear(c color.Color)Clear fills entire buffer.
ClearClip
func (b *Buffer) ClearClip()ClearClip removes any active drawing clip.
Clip
func (b *Buffer) Clip() (image.Rectangle, bool)Clip returns the active clip rectangle and whether clipping is enabled.
ColorModel
func (b *Buffer) ColorModel() color.ModelColorModel returns NRGBA model for image/draw interoperability.
DrawBuffer
func (b *Buffer) DrawBuffer(src *Buffer, dst image.Rectangle)DrawBuffer scales and draws a source buffer into dst.
DrawImage
func (b *Buffer) DrawImage(src image.Image, dst image.Rectangle)DrawImage scales and draws any image.Image into dst.
DrawLine
func (b *Buffer) DrawLine(x0, y0, x1, y1 int, c color.Color)DrawLine draws a line using Bresenham algorithm.
DrawRect
func (b *Buffer) DrawRect(r image.Rectangle, c color.Color)DrawRect draws a rectangle outline.
DrawRoundedRect
func (b *Buffer) DrawRoundedRect(r image.Rectangle, radius int, c color.Color)DrawRoundedRect draws rounded rectangle outline.
FillRect
func (b *Buffer) FillRect(r image.Rectangle, c color.Color)FillRect fills r with c.
FillRoundedRect
func (b *Buffer) FillRoundedRect(r image.Rectangle, radius int, c color.Color)FillRoundedRect fills r with rounded corners.
GetPixel
func (b *Buffer) GetPixel(x, y int) color.NRGBAGetPixel returns pixel color at x,y.
Image
func (b *Buffer) Image() draw.ImageImage returns the backing draw.Image.
Resize
func (b *Buffer) Resize(width, height int)Resize resizes the buffer, reusing backing memory when capacity allows.
Set
func (b *Buffer) Set(x, y int, c color.Color)Set writes a pixel using color.Color for image/draw interoperability.
SetClip
func (b *Buffer) SetClip(r image.Rectangle)SetClip restricts subsequent drawing operations to r intersected with bounds.
SetPixel
func (b *Buffer) SetPixel(x, y int, c color.Color)SetPixel sets a pixel at x,y.
Size
func (b *Buffer) Size() (width, height int)Size returns canvas dimensions.
SubBuffer
func (b *Buffer) SubBuffer(r image.Rectangle) *BufferSubBuffer copies r region into a new buffer.
PixelFormat
type PixelFormat intPixelFormat represents the pixel format of a buffer.
Constants
PixelFormatBGRA, PixelFormatRGBA, PixelFormatRGB565
const (
PixelFormatBGRA PixelFormat = iota
PixelFormatRGBA
PixelFormatRGB565
)