本文整理汇总了Golang中github.com/sksullivan/plot/vg/draw.Canvas.ClipLinesXY方法的典型用法代码示例。如果您正苦于以下问题:Golang Canvas.ClipLinesXY方法的具体用法?Golang Canvas.ClipLinesXY怎么用?Golang Canvas.ClipLinesXY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sksullivan/plot/vg/draw.Canvas
的用法示例。
在下文中一共展示了Canvas.ClipLinesXY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Plot
// Plot implements the Plotter interface, drawing a line
// that connects each point in the Line.
func (f *Function) Plot(c draw.Canvas, p *plot.Plot) {
trX, trY := p.Transforms(&c)
d := (p.X.Max - p.X.Min) / float64(f.Samples-1)
line := make([]draw.Point, f.Samples)
for i := range line {
x := p.X.Min + float64(i)*d
line[i].X = trX(x)
line[i].Y = trY(f.F(x))
}
c.StrokeLines(f.LineStyle, c.ClipLinesXY(line)...)
}
示例2: 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)...)
}
}
示例3: 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)...)
}
示例4: Plot
// Plot draws the Line, implementing the plot.Plotter
// interface.
func (pts *Line) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)
ps := make([]draw.Point, len(pts.XYs))
for i, p := range pts.XYs {
ps[i].X = trX(p.X)
ps[i].Y = trY(p.Y)
}
if pts.ShadeColor != nil && len(ps) > 0 {
c.SetColor(*pts.ShadeColor)
minY := trY(plt.Y.Min)
var pa vg.Path
pa.Move(ps[0].X, minY)
for i := range pts.XYs {
pa.Line(ps[i].X, ps[i].Y)
}
pa.Line(ps[len(pts.XYs)-1].X, minY)
pa.Close()
c.Fill(pa)
}
c.StrokeLines(pts.LineStyle, c.ClipLinesXY(ps)...)
}