improve docstrings of image.go

This commit is contained in:
Stani 2015-07-08 00:49:12 +02:00
parent 62e23c1693
commit 437a88ccda

View file

@ -34,9 +34,7 @@ type ImageGraphicContext struct {
DPI int DPI int
} }
/** // NewGraphicContext creates a new Graphic context from an image.
* Create a new Graphic context from an image
*/
func NewGraphicContext(img draw.Image) *ImageGraphicContext { func NewGraphicContext(img draw.Image) *ImageGraphicContext {
var painter Painter var painter Painter
switch selectImage := img.(type) { switch selectImage := img.(type) {
@ -48,7 +46,7 @@ func NewGraphicContext(img draw.Image) *ImageGraphicContext {
return NewGraphicContextWithPainter(img, painter) return NewGraphicContextWithPainter(img, painter)
} }
// Create a new Graphic context from an image and a Painter (see Freetype-go) // NewGraphicContextWithPainter creates a new Graphic context from an image and a Painter (see Freetype-go)
func NewGraphicContextWithPainter(img draw.Image, painter Painter) *ImageGraphicContext { func NewGraphicContextWithPainter(img draw.Image, painter Painter) *ImageGraphicContext {
width, height := img.Bounds().Dx(), img.Bounds().Dy() width, height := img.Bounds().Dx(), img.Bounds().Dy()
dpi := 92 dpi := 92
@ -274,7 +272,7 @@ func (gc *ImageGraphicContext) paint(rasterizer *raster.Rasterizer, color color.
gc.Current.Path.Clear() gc.Current.Path.Clear()
} }
/**** second method ****/ // Stroke strokes the paths with the color specified by SetStrokeColor
func (gc *ImageGraphicContext) Stroke(paths ...*PathStorage) { func (gc *ImageGraphicContext) Stroke(paths ...*PathStorage) {
paths = append(paths, gc.Current.Path) paths = append(paths, gc.Current.Path)
gc.strokeRasterizer.UseNonZeroWinding = true gc.strokeRasterizer.UseNonZeroWinding = true
@ -294,7 +292,7 @@ func (gc *ImageGraphicContext) Stroke(paths ...*PathStorage) {
gc.paint(gc.strokeRasterizer, gc.Current.StrokeColor) gc.paint(gc.strokeRasterizer, gc.Current.StrokeColor)
} }
/**** second method ****/ // Fill fills the paths with the color specified by SetFillColor
func (gc *ImageGraphicContext) Fill(paths ...*PathStorage) { func (gc *ImageGraphicContext) Fill(paths ...*PathStorage) {
paths = append(paths, gc.Current.Path) paths = append(paths, gc.Current.Path)
gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule.UseNonZeroWinding() gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule.UseNonZeroWinding()
@ -307,7 +305,7 @@ func (gc *ImageGraphicContext) Fill(paths ...*PathStorage) {
gc.paint(gc.fillRasterizer, gc.Current.FillColor) gc.paint(gc.fillRasterizer, gc.Current.FillColor)
} }
/* second method */ // FillStroke first fills the paths and than strokes them
func (gc *ImageGraphicContext) FillStroke(paths ...*PathStorage) { func (gc *ImageGraphicContext) FillStroke(paths ...*PathStorage) {
gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule.UseNonZeroWinding() gc.fillRasterizer.UseNonZeroWinding = gc.Current.FillRule.UseNonZeroWinding()
gc.strokeRasterizer.UseNonZeroWinding = true gc.strokeRasterizer.UseNonZeroWinding = true