本文整理汇总了Golang中github.com/gonum/plot/vg/vgimg.PngCanvas.SetLineWidth方法的典型用法代码示例。如果您正苦于以下问题:Golang PngCanvas.SetLineWidth方法的具体用法?Golang PngCanvas.SetLineWidth怎么用?Golang PngCanvas.SetLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gonum/plot/vg/vgimg.PngCanvas
的用法示例。
在下文中一共展示了PngCanvas.SetLineWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestGraphicGrobs
func TestGraphicGrobs(t *testing.T) {
// Output
file, err := os.Create("grobs.png")
if err != nil {
t.Fatalf("%", err)
}
pngCanvas := vgimg.PngCanvas{Canvas: vgimg.New(10*vg.Inch, 8*vg.Inch)}
vg.Initialize(pngCanvas)
pngCanvas.Translate(-5*vg.Inch, -4*vg.Inch)
dot := func(x, y float64) {
pngCanvas.Push()
pngCanvas.SetColor(BuiltinColors["red"])
pngCanvas.SetLineWidth(5)
var p vg.Path
xr := vg.Length(x) * vg.Inch
yr := vg.Length(y) * vg.Inch
p.Move(xr-5, yr-5)
p.Line(xr-5, yr+5)
p.Line(xr+5, yr+5)
p.Line(xr+5, yr-5)
p.Close()
pngCanvas.Fill(p)
pngCanvas.Pop()
}
dot(0, 0)
dot(5, 0)
dot(0, 4)
allVP := Viewport{
X0: 0,
Y0: 0,
Width: 10 * vg.Inch,
Height: 8 * vg.Inch,
Canvas: pngCanvas,
}
innerVP := allVP.Sub(0.05, 0.05, 0.9, 0.9)
bg := GrobRect{xmin: 0, ymin: 0, xmax: 1, ymax: 1, fill: BuiltinColors["gray80"]}
bg.Draw(innerVP)
cols := []string{"red", "green", "blue", "cyan", "magenta", "yellow",
"white", "gray", "black"}
// Draw points in all shapes, three sizes and all builtin colors.
points := []Grob{}
x, y := 0.1, 0.1
for shape := DotPoint; shape <= StarPoint; shape++ {
for size := 2; size < 7; size += 2 {
y = 0.05
for _, col := range cols {
g := GrobPoint{
x: x,
y: y,
size: float64(size),
shape: shape,
color: BuiltinColors[col],
}
points = append(points, g)
y += 0.035
}
x += 0.021
}
}
x, y = 0.02, 0.05
for _, col := range cols {
g := GrobText{
x: x,
y: y,
text: col,
size: 10,
color: BuiltinColors[col],
vjust: 0.5,
hjust: 0,
}
points = append(points, g)
y += 0.035
}
x, y = 0.121, 0.36
for shape := DotPoint; shape <= StarPoint; shape++ {
dy := float64(shape%2) * 0.015
g := GrobText{
x: x,
y: y + dy,
text: shape.String(),
size: 10,
color: BuiltinColors["black"],
vjust: 0.5,
hjust: 0.5,
}
points = append(points, g)
x += 3 * 0.021
}
for _, grob := range points {
grob.Draw(innerVP)
}
// Draw lines with different styles and widths.
lines := []Grob{}
x, y = 0.1, 0.45
//.........这里部分代码省略.........