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


Golang svgo.SVG类代码示例

本文整理汇总了Golang中github.com/ajstarks/svgo.SVG的典型用法代码示例。如果您正苦于以下问题:Golang SVG类的具体用法?Golang SVG怎么用?Golang SVG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SVG类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: relationsGroup

func (c *Canvas) relationsGroup(canvas *svg.SVG) {
	canvas.Gid("relations")
	defer canvas.Gend()
	for _, relation := range c.relations {
		relation.usage(canvas)
	}
}
开发者ID:jdonson,项目名称:jujusvg,代码行数:7,代码来源:canvas.go

示例2: servicesGroup

func (c *Canvas) servicesGroup(canvas *svg.SVG) {
	canvas.Gid("services")
	defer canvas.Gend()
	for _, service := range c.services {
		service.usage(canvas, c.iconIds)
	}
}
开发者ID:jdonson,项目名称:jujusvg,代码行数:7,代码来源:canvas.go

示例3: 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

示例4: 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

示例5: usage

// usage creates any necessary tags for actually using the service in the SVG.
func (s *service) usage(canvas *svg.SVG, iconIds map[string]string) {
	canvas.Use(
		s.point.X,
		s.point.Y,
		"#serviceBlock",
		fmt.Sprintf(`id=%q`, s.name))
	if len(s.iconSrc) > 0 {
		canvas.Use(
			s.point.X+serviceBlockSize/2-iconSize/2,
			s.point.Y+serviceBlockSize/2-iconSize/2,
			"#"+iconIds[s.charmPath],
			fmt.Sprintf(`width="%d" height="%d"`, iconSize, iconSize),
		)
	} else {
		canvas.Image(
			s.point.X+serviceBlockSize/2-iconSize/2,
			s.point.Y+serviceBlockSize/2-iconSize/2,
			iconSize,
			iconSize,
			s.iconUrl,
		)
	}
	canvas.Textlines(
		s.point.X+serviceBlockSize/2,
		s.point.Y+serviceBlockSize/6,
		[]string{s.name},
		serviceBlockSize/10,
		0,
		"#505050",
		"middle")
}
开发者ID:jdonson,项目名称:jujusvg,代码行数:32,代码来源:canvas.go

示例6: definition

func (c *Canvas) definition(canvas *svg.SVG) {
	canvas.Def()
	defer canvas.DefEnd()

	// Service block.
	canvas.Group(`id="serviceBlock"`,
		`transform="scale(0.8)"`)
	io.WriteString(canvas.Writer, assets.ServiceModule)
	canvas.Gend() // Gid

	// Relation health circle.
	canvas.Gid("healthCircle")
	canvas.Circle(
		healthCircleRadius,
		healthCircleRadius,
		healthCircleRadius,
		fmt.Sprintf("stroke:%s;fill:none;stroke-width:%dpx", relationColor, relationLineWidth),
	)
	canvas.Circle(
		healthCircleRadius,
		healthCircleRadius,
		healthCircleRadius/2,
		fmt.Sprintf("fill:%s", relationColor),
	)
	canvas.Gend()

	// Service and relation specific defs.
	for _, relation := range c.relations {
		relation.definition(canvas)
	}
	for _, service := range c.services {
		service.definition(canvas, c.iconsRendered, c.iconIds)
	}
}
开发者ID:jdonson,项目名称:jujusvg,代码行数:34,代码来源:canvas.go

示例7: drawDot

func drawDot(c *svg.SVG, x, y, s int) {
	//c.Rect(x, y, s, s, "fill:none; stroke:yellow")
	c.Circle(x+s/2, y+s/2, s/3)
}
开发者ID:suapapa,项目名称:go_braille,代码行数:4,代码来源:svg.go


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