in Uncategorized

对GooCanvas Manual的翻译-之Coordinate Spaces and Limits

自己阅读GooCanvas手册时翻译的,可能很多地方有问题,如果您发现错误,请指正!谢谢!
英文原版地址:
http://library.gnome.org/devel/goocanvas/unstable/goocanvas-coordinates.html

翻译内容:

坐标空间和限定

坐标空间和限定-坐标系是如何被使用的

坐标空间

画布中的构件(items)通常都有用一些属性,以便指明它们的位置和大小。举个例子,GooCanvasRect构件具有"x", "y", "width"和"height"属性。

构件还拥有一个变化矩阵(transformation matrix) (比如:"transform"属性)。变化矩阵通过一些方式修改构件的坐标空间。变化包括:平移 (移动原始组件)、 旋转、 缩放和扭曲以及这些变化的组合。应此组件在画布上的最终位置是能够被突然改变的。

在GooCanvas中的简单的动画特征是通过随着时间修改构件的变化矩阵来实现的。(参看goo_canbas_item_animate()。)

由于组件们是存在在一个分层结构中,所以有可能通过简单地改变一个组的变化矩阵去移动或旋转整个组的组件。

在组件自身内使用的坐标空间是参照于“组件空间”的(比如一个GooCanvasRect的"x"和"y"属性被指明的地方)。整个画布所使用的坐标空间是参照于“设备空间”的。“组件空间”和“设备空间”可能一样也可能不一样, 这取决于该组件或它的任意一个父组件是否拥有一个变化矩阵集(set, 也许是设定)。(注意:整个画布是可以同样被卷动或缩放的,这也就意味着在“设备空间”上有一个附加的变化。

用于转换两个坐标空间的函数,例如goo_canvas_convert_to_item_space()和goo_canvas_convert_from_item_space()用于进行设备空间坐标系和组件空间之间的相互转换。


坐标限定 (暂不翻译)

GooCanvas uses the Cairo graphics library to render canvas items. For performance reasons Cairo uses 32-bit fixed point integers
internally when rendering graphics, with 24 bits used for the integer part of values and 8 bits used for the fractional part. This means
that values are limited to roughly +/- 8,388,608. (Prior to Cairo 1.6 16 bits were used for the integer part and 16 bits for the
fractional part, meaning values were limited to +/- 32,768.)

GooCanvas includes code to work around the Cairo limits to some extent. Subclasses of GooCanvasItemSimple (including all builtin items)
can use any desired translation using a transformation matrix. But item space coordinates (modified by any scale, rotation or skew) must
be within the Cairo limits.

It is possible to create new canvas items that avoid the Cairo limits completely. For an example of this see the "Large Items" page in
the GooCanvas demo application, and the corresponding code.

Write a Comment

Comment