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


Golang Point26_6.X方法代码示例

本文整理汇总了Golang中golang.org/x/image/math/fixed.Point26_6.X方法的典型用法代码示例。如果您正苦于以下问题:Golang Point26_6.X方法的具体用法?Golang Point26_6.X怎么用?Golang Point26_6.X使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在golang.org/x/image/math/fixed.Point26_6的用法示例。


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

示例1: DrawString

// DrawString draws s at p and returns p advanced by the text extent. The text
// is placed so that the left edge of the em square of the first character of s
// and the baseline intersect at p. The majority of the affected pixels will be
// above and to the right of the point, but some may be below or to the left.
// For example, drawing a string that starts with a 'J' in an italic font may
// affect pixels below and left of the point.
//
// p is a fixed.Point26_6 and can therefore represent sub-pixel positions.
func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, error) {
	if c.f == nil {
		return fixed.Point26_6{}, errors.New("freetype: DrawText called with a nil font")
	}
	prev, hasPrev := truetype.Index(0), false
	for _, rune := range s {
		index := c.f.Index(rune)
		if hasPrev {
			kern := c.f.Kern(c.scale, prev, index)
			if c.hinting != font.HintingNone {
				kern = (kern + 32) &^ 63
			}
			p.X += kern
		}
		advanceWidth, mask, offset, err := c.glyph(index, p)
		if err != nil {
			return fixed.Point26_6{}, err
		}
		p.X += advanceWidth
		glyphRect := mask.Bounds().Add(offset)
		dr := c.clip.Intersect(glyphRect)
		if !dr.Empty() {
			mp := image.Point{0, dr.Min.Y - glyphRect.Min.Y}
			draw.DrawMask(c.dst, dr, c.src, image.ZP, mask, mp, draw.Over)
		}
		prev, hasPrev = index, true
	}
	return p, nil
}
开发者ID:walesey,项目名称:go-engine,代码行数:37,代码来源:freetype.go

示例2: Advance

func (self rightToLeft) Advance(face font.Face, origin fixed.Point26_6, dot fixed.Point26_6, prev rune, char rune) (begin fixed.Point26_6, end fixed.Point26_6) {
	if char == '\n' {
		dot.X = origin.X
		dot.Y += face.Metrics().Height
		return dot, dot
	}

	if prev != 0 {
		dot.X -= face.Kern(prev, char)
	}

	dot.X -= advance(face, char)
	return dot, dot
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:14,代码来源:direction.go


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