本文整理汇总了Golang中github.com/ajstarks/svgo.SVG.Start方法的典型用法代码示例。如果您正苦于以下问题:Golang SVG.Start方法的具体用法?Golang SVG.Start怎么用?Golang SVG.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ajstarks/svgo.SVG
的用法示例。
在下文中一共展示了SVG.Start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DrawLabel
func DrawLabel(s *svg.SVG, bs string) *BrailleCanvas {
var c BrailleCanvas
// TODO: they hard coded
c.dotSize = 12
c.pageMarginTop = 3
c.pageMarginBottom = 3
c.pageMarginLeft = 3
c.pageMarginRight = 3
c.gapCell = 3
c.canvasW = c.pageMarginLeft + c.pageMarginRight
c.canvasW += c.dotSize * 2 * utf8.RuneCountInString(bs)
c.canvasW += c.gapCell*utf8.RuneCountInString(bs) - 1
c.canvasH = c.pageMarginTop + c.pageMarginBottom
c.canvasH += c.dotSize * 3
s.Start(c.canvasW, c.canvasH)
x := c.pageMarginLeft
y := c.pageMarginTop
for _, b := range bs {
if b&0x2800 != 0x2800 {
log.Printf("0x%x is not a braille character!\n", b)
continue
}
Draw(s, b, x, y, c.dotSize)
x += (c.dotSize * 2) + c.gapCell
}
return &c
}
示例2: DrawPage30
func DrawPage30(s *svg.SVG, bs string) *BrailleCanvas {
var c BrailleCanvas
// TODO: they hard coded
c.dotSize = 12
c.pageMarginTop = 10
c.pageMarginBottom = 10
c.pageMarginLeft = 10
c.pageMarginRight = 10
c.gapCell = 3
c.gapLine = 16
c.lineCellsCnt = 30
c.canvasW = c.pageMarginLeft + c.pageMarginRight
c.canvasW += c.dotSize * 2 * 30
c.canvasW += c.gapCell*30 - 1
lineCnt := calcLines(bs, 30)
c.canvasH = c.pageMarginTop + c.pageMarginBottom
c.canvasH += c.dotSize * 3 * lineCnt
c.canvasH += c.gapLine*lineCnt - 1
s.Start(c.canvasW, c.canvasH)
x := c.pageMarginLeft
y := c.pageMarginTop
lines := strings.Split(bs, "\n")
ri := 0
for _, line := range lines {
for _, b := range line {
if ri == 30 {
x = c.pageMarginLeft
y += (c.dotSize * 3) + c.gapLine
ri = 0
}
if b&0x2800 != 0x2800 {
log.Printf("0x%x is not a braille character!\n", b)
continue
}
Draw(s, b, x, y, c.dotSize)
ri += 1
x += (c.dotSize * 2) + c.gapCell
}
x = c.pageMarginLeft
y += (c.dotSize * 3) + c.gapLine
ri = 0
}
return &c
}