当前位置: 首页>>代码示例>>Golang>>正文


Golang SVG.Start方法代码示例

本文整理汇总了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
}
开发者ID:suapapa,项目名称:go_braille,代码行数:33,代码来源:svg.go

示例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
}
开发者ID:suapapa,项目名称:go_braille,代码行数:53,代码来源:svg.go


注:本文中的github.com/ajstarks/svgo.SVG.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。