本文整理汇总了Golang中github.com/sksullivan/plot/vg/draw.Canvas.FillPolygon方法的典型用法代码示例。如果您正苦于以下问题:Golang Canvas.FillPolygon方法的具体用法?Golang Canvas.FillPolygon怎么用?Golang Canvas.FillPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sksullivan/plot/vg/draw.Canvas
的用法示例。
在下文中一共展示了Canvas.FillPolygon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Plot
// Plot implements the plot.Plotter interface.
func (b *BarChart) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)
for i, ht := range b.Values {
x := b.XMin + float64(i)
xmin := trX(float64(x))
if !c.ContainsX(xmin) {
continue
}
xmin = xmin - b.Width/2 + b.Offset
xmax := xmin + b.Width
bottom := b.stackedOn.BarHeight(i)
ymin := trY(bottom)
ymax := trY(bottom + ht)
pts := []draw.Point{
{xmin, ymin},
{xmin, ymax},
{xmax, ymax},
{xmax, ymin},
}
poly := c.ClipPolygonY(pts)
c.FillPolygon(b.Color, poly)
pts = append(pts, draw.Point{xmin, ymin})
outline := c.ClipLinesY(pts)
c.StrokeLines(b.LineStyle, outline...)
}
}
示例2: Thumbnail
func (b *BarChart) Thumbnail(c *draw.Canvas) {
pts := []draw.Point{
{c.Min.X, c.Min.Y},
{c.Min.X, c.Max.Y},
{c.Max.X, c.Max.Y},
{c.Max.X, c.Min.Y},
}
poly := c.ClipPolygonY(pts)
c.FillPolygon(b.Color, poly)
pts = append(pts, draw.Point{c.Min.X, c.Min.Y})
outline := c.ClipLinesY(pts)
c.StrokeLines(b.LineStyle, outline...)
}
示例3: Plot
// Plot implements the Plotter interface, drawing a line
// that connects each point in the Line.
func (h *Histogram) Plot(c draw.Canvas, p *plot.Plot) {
trX, trY := p.Transforms(&c)
for _, bin := range h.Bins {
pts := []draw.Point{
{trX(bin.Min), trY(0)},
{trX(bin.Max), trY(0)},
{trX(bin.Max), trY(bin.Weight)},
{trX(bin.Min), trY(bin.Weight)},
}
if h.FillColor != nil {
c.FillPolygon(h.FillColor, c.ClipPolygonXY(pts))
}
pts = append(pts, draw.Point{trX(bin.Min), trY(0)})
c.StrokeLines(h.LineStyle, c.ClipLinesXY(pts)...)
}
}
示例4: Thumbnail
// Thumbnail the thumbnail for the Line,
// implementing the plot.Thumbnailer interface.
func (pts *Line) Thumbnail(c *draw.Canvas) {
if pts.ShadeColor != nil {
points := []draw.Point{
{c.Min.X, c.Min.Y},
{c.Min.X, c.Max.Y},
{c.Max.X, c.Max.Y},
{c.Max.X, c.Min.Y},
}
poly := c.ClipPolygonY(points)
c.FillPolygon(*pts.ShadeColor, poly)
points = append(points, draw.Point{c.Min.X, c.Min.Y})
} else {
y := c.Center().Y
c.StrokeLine2(pts.LineStyle, c.Min.X, y, c.Max.X, y)
}
}
示例5: Thumbnail
// Thumbnail draws a rectangle in the given style of the histogram.
func (h *Histogram) Thumbnail(c *draw.Canvas) {
ymin := c.Min.Y
ymax := c.Max.Y
xmin := c.Min.X
xmax := c.Max.X
pts := []draw.Point{
{xmin, ymin},
{xmax, ymin},
{xmax, ymax},
{xmin, ymax},
}
if h.FillColor != nil {
c.FillPolygon(h.FillColor, c.ClipPolygonXY(pts))
}
pts = append(pts, draw.Point{xmin, ymin})
c.StrokeLines(h.LineStyle, c.ClipLinesXY(pts)...)
}