本文整理汇总了Golang中github.com/sksullivan/plot/vg/draw.Canvas.ClipPolygonY方法的典型用法代码示例。如果您正苦于以下问题:Golang Canvas.ClipPolygonY方法的具体用法?Golang Canvas.ClipPolygonY怎么用?Golang Canvas.ClipPolygonY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sksullivan/plot/vg/draw.Canvas
的用法示例。
在下文中一共展示了Canvas.ClipPolygonY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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)
}
}