Documentation
¶
Overview ¶
This package contains several structs for drawing, all following a similar convention:
Structs have a constructor function that takes basic arguments for that type, ie:
func NewLineDrawer(draw.Image, image.Point, image.Point, color.Color)
All functions in the Drawer structs return a pointer to itself to allow chaining:
NewLineDrawer(src, start, end, color.RGBA{255, 0, 0, 255}).SetThickness(10).Draw()
This also allows you to reuse an instance:
lineDrawer := NewLineDrawer(draw.Image, image.Point, image.Point, color.Color).Draw() lineDrawer = lineDrawer.SetStart(image.Pt(0, 50)).Draw()
This construct allows easy addition of new features without compromising reverse compatibilty.
Index ¶
- func Blend(img draw.Image, x int, y int, c color.Color)
- func ColorToRGBA(c color.Color) color.RGBA
- func Fill(img draw.Image, color color.Color)
- type LineDrawer
- func (this *LineDrawer) Draw() *LineDrawer
- func (this *LineDrawer) SetColor(c color.Color) *LineDrawer
- func (this *LineDrawer) SetEnd(end image.Point) *LineDrawer
- func (this *LineDrawer) SetImage(img draw.Image) *LineDrawer
- func (this *LineDrawer) SetStart(start image.Point) *LineDrawer
- func (this *LineDrawer) SetThickness(thick float64) *LineDrawer
- type RectDrawer
- func (this *RectDrawer) Draw() *RectDrawer
- func (this *RectDrawer) SetColor(color color.Color) *RectDrawer
- func (this *RectDrawer) SetFilled(isFilled bool) *RectDrawer
- func (this *RectDrawer) SetImage(img draw.Image) *RectDrawer
- func (this *RectDrawer) SetRect(rect image.Rectangle) *RectDrawer
- func (this *RectDrawer) SetThickness(thickness int) *RectDrawer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blend ¶
Performs alpha blending on the pixel on img.At(x,y). While draw.Set(x,y) *sets* the color to c, Blend uses the existing background to create a new color that is a mix of the existing annew color. This is similar to treating the two colors as stained glass windows laying over eachother. Not that if the new color is completely opache, Blend() and Set() have the same result.
func ColorToRGBA ¶
A convineice function that creates a color.RGBA struct from color.Color interface. While fairly straitforward, tedious conversions need to be made to change between uint32 and uint8.
Types ¶
type LineDrawer ¶
type LineDrawer struct {
// contains filtered or unexported fields
}
func NewLineDrawer ¶
func (*LineDrawer) Draw ¶
func (this *LineDrawer) Draw() *LineDrawer
func (*LineDrawer) SetColor ¶
func (this *LineDrawer) SetColor(c color.Color) *LineDrawer
func (*LineDrawer) SetEnd ¶
func (this *LineDrawer) SetEnd(end image.Point) *LineDrawer
func (*LineDrawer) SetImage ¶
func (this *LineDrawer) SetImage(img draw.Image) *LineDrawer
func (*LineDrawer) SetStart ¶
func (this *LineDrawer) SetStart(start image.Point) *LineDrawer
func (*LineDrawer) SetThickness ¶
func (this *LineDrawer) SetThickness(thick float64) *LineDrawer
type RectDrawer ¶
type RectDrawer struct {
// contains filtered or unexported fields
}
func NewRectDrawer ¶
Draws rect in color onto img. rect must be well-formed (see Rectangle.Canon()).
func (*RectDrawer) Draw ¶
func (this *RectDrawer) Draw() *RectDrawer
func (*RectDrawer) SetColor ¶
func (this *RectDrawer) SetColor(color color.Color) *RectDrawer
func (*RectDrawer) SetFilled ¶
func (this *RectDrawer) SetFilled(isFilled bool) *RectDrawer
func (*RectDrawer) SetImage ¶
func (this *RectDrawer) SetImage(img draw.Image) *RectDrawer
func (*RectDrawer) SetRect ¶
func (this *RectDrawer) SetRect(rect image.Rectangle) *RectDrawer
func (*RectDrawer) SetThickness ¶
func (this *RectDrawer) SetThickness(thickness int) *RectDrawer