func newNullBrush() *nullBrush { lb := &win.LOGBRUSH{LbStyle: win.BS_NULL} hBrush := win.CreateBrushIndirect(lb) if hBrush == 0 { panic("failed to create null brush") } return &nullBrush{hBrush: hBrush} }
func NewHatchBrush(color Color, style HatchStyle) (*HatchBrush, error) { lb := &win.LOGBRUSH{LbStyle: win.BS_HATCHED, LbColor: win.COLORREF(color), LbHatch: uintptr(style)} hBrush := win.CreateBrushIndirect(lb) if hBrush == 0 { return nil, newError("CreateBrushIndirect failed") } return &HatchBrush{hBrush: hBrush, color: color, style: style}, nil }
func NewSolidColorBrush(color Color) (*SolidColorBrush, error) { lb := &win.LOGBRUSH{LbStyle: win.BS_SOLID, LbColor: win.COLORREF(color)} hBrush := win.CreateBrushIndirect(lb) if hBrush == 0 { return nil, newError("CreateBrushIndirect failed") } return &SolidColorBrush{hBrush: hBrush, color: color}, nil }
func NewBitmapBrush(bitmap *Bitmap) (*BitmapBrush, error) { if bitmap == nil { return nil, newError("bitmap cannot be nil") } lb := &win.LOGBRUSH{LbStyle: win.BS_DIBPATTERN, LbColor: win.DIB_RGB_COLORS, LbHatch: uintptr(bitmap.hPackedDIB)} hBrush := win.CreateBrushIndirect(lb) if hBrush == 0 { return nil, newError("CreateBrushIndirect failed") } return &BitmapBrush{hBrush: hBrush, bitmap: bitmap}, nil }