本文整理汇总了Golang中github.com/skiesel/plot/vg.Length类的典型用法代码示例。如果您正苦于以下问题:Golang Length类的具体用法?Golang Length怎么用?Golang Length使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Length类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: New
func New(w, h vg.Length) *Canvas {
buf := new(bytes.Buffer)
c := &Canvas{
svg: svgo.New(buf),
w: w,
h: h,
buf: buf,
ht: w.Points(),
stk: []context{context{}},
}
// This is like svg.Start, except it uses floats
// and specifies the units.
fmt.Fprintf(buf, `<?xml version="1.0"?>
<!-- Generated by SVGo and Plotinum VG -->
<svg width="%.*gin" height="%.*gin"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">`+"\n",
pr, w/vg.Inch,
pr, h/vg.Inch,
)
// Swap the origin to the bottom left.
// This must be matched with a </g> when saving,
// before the closing </svg>.
c.svg.Gtransform(fmt.Sprintf("scale(1, -1) translate(0, -%.*g)", pr, h.Dots(DPI)))
vg.Initialize(c)
return c
}
开发者ID:skiesel,项目名称:plot,代码行数:30,代码来源:vgsvg.go
示例2: SetLineDash
func (c *Canvas) SetLineDash(ds []vg.Length, offs vg.Length) {
dashes := make([]float64, len(ds))
for i, d := range ds {
dashes[i] = d.Dots(c.DPI())
}
c.gc.SetLineDash(dashes, offs.Dots(c.DPI()))
}
开发者ID:skiesel,项目名称:plot,代码行数:7,代码来源:vgimg.go
示例3: FillString
func (e *Canvas) FillString(fnt vg.Font, x, y vg.Length, str string) {
if e.cur().font != fnt.Name() || e.cur().fsize != fnt.Size {
e.cur().font = fnt.Name()
e.cur().fsize = fnt.Size
fmt.Fprintf(e.buf, "/%s findfont %.*g scalefont setfont\n",
fnt.Name(), pr, fnt.Size)
}
fmt.Fprintf(e.buf, "%.*g %.*g moveto\n", pr, x.Dots(DPI), pr, y.Dots(DPI))
fmt.Fprintf(e.buf, "(%s) show\n", str)
}
开发者ID:skiesel,项目名称:plot,代码行数:10,代码来源:vgeps.go
示例4: FillString
func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string) {
fontStr, ok := fontMap[font.Name()]
if !ok {
panic(fmt.Sprintf("Unknown font: %s", font.Name()))
}
sty := style(fontStr,
elm("font-size", "medium", "%.*gpt", pr, font.Size.Points()),
elm("fill", "#000000", colorString(c.cur().color)))
if sty != "" {
sty = "\n\t" + sty
}
fmt.Fprintf(c.buf, `<text x="%.*g" y="%.*g" transform="scale(1, -1)"%s>%s</text>`+"\n",
pr, x.Dots(DPI), pr, -y.Dots(DPI), sty, str)
}
开发者ID:skiesel,项目名称:plot,代码行数:14,代码来源:vgsvg.go
示例5: FillString
func (c *Canvas) FillString(font vg.Font, x, y vg.Length, str string) {
c.gc.Save()
defer c.gc.Restore()
data, ok := fontMap[font.Name()]
if !ok {
panic(fmt.Sprintf("Font name %s is unknown", font.Name()))
}
if !registeredFont[font.Name()] {
draw2d.RegisterFont(data, font.Font())
registeredFont[font.Name()] = true
}
c.gc.SetFontData(data)
c.gc.SetFontSize(font.Size.Points())
c.gc.Translate(x.Dots(c.DPI()), y.Dots(c.DPI()))
c.gc.Scale(1, -1)
c.gc.FillString(str)
}
开发者ID:skiesel,项目名称:plot,代码行数:18,代码来源:vgimg.go
示例6: SetLineDash
func (e *Canvas) SetLineDash(dashes []vg.Length, o vg.Length) {
cur := e.cur().dashes
dashEq := len(dashes) == len(cur)
for i := 0; dashEq && i < len(dashes); i++ {
if dashes[i] != cur[i] {
dashEq = false
}
}
if !dashEq || e.cur().offs != o {
e.cur().dashes = dashes
e.cur().offs = o
e.buf.WriteString("[")
for _, d := range dashes {
fmt.Fprintf(e.buf, " %.*g", pr, d.Dots(DPI))
}
e.buf.WriteString(" ] ")
fmt.Fprintf(e.buf, "%.*g setdash\n", pr, o.Dots(DPI))
}
}
开发者ID:skiesel,项目名称:plot,代码行数:19,代码来源:vgeps.go
示例7: NewTitle
// NewTitle returns a new Canvas with the given title string.
func NewTitle(w, h vg.Length, title string) *Canvas {
c := &Canvas{
stk: []ctx{ctx{}},
w: w,
h: h,
buf: new(bytes.Buffer),
}
c.buf.WriteString("%%!PS-Adobe-3.0 EPSF-3.0\n")
c.buf.WriteString("%%Creator github.com/skiesel/plot/vg/vgeps\n")
c.buf.WriteString("%%Title: " + title + "\n")
c.buf.WriteString(fmt.Sprintf("%%%%BoundingBox: 0 0 %.*g %.*g\n",
pr, w.Dots(DPI),
pr, h.Dots(DPI)))
c.buf.WriteString(fmt.Sprintf("%%%%CreationDate: %s\n", time.Now()))
c.buf.WriteString("%%Orientation: Portrait\n")
c.buf.WriteString("%%EndComments\n")
c.buf.WriteString("\n")
vg.Initialize(c)
return c
}
开发者ID:skiesel,项目名称:plot,代码行数:21,代码来源:vgeps.go
示例8: SetLineWidth
func (e *Canvas) SetLineWidth(w vg.Length) {
if e.cur().width != w {
e.cur().width = w
fmt.Fprintf(e.buf, "%.*g setlinewidth\n", pr, w.Dots(DPI))
}
}
开发者ID:skiesel,项目名称:plot,代码行数:6,代码来源:vgeps.go
示例9: Translate
func (e *Canvas) Translate(x, y vg.Length) {
fmt.Fprintf(e.buf, "%.*g %.*g translate\n",
pr, x.Dots(DPI), pr, y.Dots(DPI))
}
开发者ID:skiesel,项目名称:plot,代码行数:4,代码来源:vgeps.go
示例10: Translate
func (c *Canvas) Translate(x, y vg.Length) {
c.svg.Gtransform(fmt.Sprintf("translate(%.*g, %.*g)", pr, x.Dots(DPI), pr, y.Dots(DPI)))
c.cur().gEnds++
}
开发者ID:skiesel,项目名称:plot,代码行数:4,代码来源:vgsvg.go
示例11: Translate
func (c *Canvas) Translate(x, y vg.Length) {
c.gc.Translate(x.Dots(c.DPI()), y.Dots(c.DPI()))
}
开发者ID:skiesel,项目名称:plot,代码行数:3,代码来源:vgimg.go
示例12: SetLineWidth
func (c *Canvas) SetLineWidth(w vg.Length) {
c.width = w
c.gc.SetLineWidth(w.Dots(c.DPI()))
}
开发者ID:skiesel,项目名称:plot,代码行数:4,代码来源:vgimg.go
示例13: unit
// unit returns a pdf.Unit, converted from a vg.Length.
func unit(l vg.Length) pdf.Unit {
return pdf.Unit(l.Points()) * pdf.Pt
}
开发者ID:skiesel,项目名称:plot,代码行数:4,代码来源:vgpdf.go
注:本文中的github.com/skiesel/plot/vg.Length类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论