gpt4 book ai didi

go - 如何在 GoLang 中编写折线

转载 作者:数据小太阳 更新时间:2023-10-29 03:41:31 26 4
gpt4 key购买 nike

我想用坐标集在 go lang 中打印一个“Polyline()”函数:

x      y
300 250
400 350
250 600

我不明白这个结构:

Polyline(x []int, y []int, s ...string)

请展示如何在 GoLang 中携带这条折线

最佳答案

package svg

import "github.com/ajstarks/svgo"

Package svg generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (http://www.w3.org/TR/SVG11/). Output goes to the specified io.Writer.

func (*SVG) Polyline

func (svg *SVG) Polyline(x []int, y []int, s ...string)

Polyline draws connected lines between coordinates, with optional style. Standard Reference: http://www.w3.org/TR/SVG11/shapes.html#PolylineElement

例如,

x := []int{300, 400, 250}
y := []int{250, 350, 600}
s := []string{`fill="none"`}
canvas.Polyline(x, y, s...)

关于go - 如何在 GoLang 中编写折线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26641273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com