如何在开罗重设当前点? [英] How to reset the current point in cairo?

查看:122
本文介绍了如何在开罗重设当前点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从cairo文档中,我可以看到一些功能,例如文本toy-API cairo_show_text()需要设置当前点.我们可以使用 cairo_move_to()设置当前点,然后调用 cairo_show_text(),它将光栅化所需位置的文本.

From cairo documentation, I can see that some functions, for instance the Text toy-API cairo_show_text() needs a current point to be set. We can set the current point with cairo_move_to(), and then calling cairo_show_text() it will rasterize the text in the desired location.

顺便说一句,这引起了一个错误,因为在光栅化文本之后,我正在笔触路径,该路径(通过最初调用 cairo_move_to()来设置文本的当前点)具有错误的点

Btw, this caused a bug, because after rasterizing text, I was stroking a path, which (with that initial call to cairo_move_to() to set the current point for the text) had wrong points.

我通过在调用 cairo_show_text()之后立即调用 cairo_stroke()解决了该错误,并且似乎可以正常工作,因为它重置了当前点.

I solved this bug by calling cairo_stroke() immediately after calling cairo_show_text(), and it seems to work, since it resets the current point.

似乎调用 cairo_close_path()而不是 cairo_stroke()并没有帮助.它没有重置当前点.我认为这很奇怪.为什么?

It seems that calling cairo_close_path() instead of cairo_stroke() hasn't been helpful. It didn't reset the current point. And I think this is quite strange. Why?

我的最后一个问题是:是否有适当的方法来重置当前点?我认为应该有.

My final question is: is there a proper way to reset the current point? I think there should be.

推荐答案

来自

cairo_new_path()

cairo_new_path ()

清除当前路径.通话之后,将没有路径,也没有当前点.

Clears the current path. After this call there will be no path and no current point.

出于完整性考虑:还有一个功能不能清除当前路径:

For completeness: There is also this function which does not clear the current path:

来自 https://www.cairographics.org/manual/cairo-Paths.html#cairo-new-sub-path

cairo_new_sub_path()

cairo_new_sub_path ()

开始一个新的子路径.请注意,现有路径不会受到影响.通话后将没有当前点.

Begin a new sub-path. Note that the existing path is not affected. After this call there will be no current point.

在许多情况下,由于新的子路径通常以cairo_move_to()开始,因此不需要此调用.

In many cases, this call is not needed since new sub-paths are frequently started with cairo_move_to().

使用 cairo_arc()调用之一开始新的子路径时,对 cairo_new_sub_path()的调用特别有用.这使事情变得容易,因为不再需要为调用 cairo_move_to()的调用手动计算弧的初始坐标.

A call to cairo_new_sub_path() is particularly useful when beginning a new sub-path with one of the cairo_arc() calls. This makes things easier as it is no longer necessary to manually compute the arc's initial coordinates for a call to cairo_move_to().

这篇关于如何在开罗重设当前点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆