Comments on: Critical Decision for DRAW Still Needed
Our plan is to finish the beta of the new SVG DRAW command (based on AGG) by the end of this month. As I mentioned last week, there are a number of issues, but one important issue needs to be solved very soon: the transformation matrix context.
Here is the basic situation. When writing vector graphic descriptions, you may want to perform a transformation on the coordinate system. For example part of your drawing might be rotated by 45 degrees. This rotation can be expressed using a ROTATE command (or by providing a new matrix, see below).
Often you only want the ROTATE to affect a few elements of the graphics. For example, maybe you only want a box to be affected, not commands that follow. There are four ways to represent this "isolation" of the ROTATE command:
1) Using a PUSH and POP stack:
push rotate 45 box 10x10 100x100 pop
2) Adding a block for the rotated commands.
rotate 45 [box 10x10 100x100]
3) Having the ROTATE work like a state attribute within a block. Here the GROUP command implies a PUSH/POP kind of operation:
group [rotate 45 box 10x10 100x100]
4) Putting the translation parameters into their own block.
matrix [rotate 45] [box 10x10 100x100]
You might think that (2) looks the best (it's the simplest), and I would agree. But, it becomes a problem when more than one transformation is applied. For example, if scaling is also needed, then it would be written as:
rotate 45 [scale 2 [box 10x10 100x100]]
and that needlessly pushes and pops the transformation stack.
The 3rd form would write add the SCALE as:
group [rotate 45 scale 2 box 10x10 100x100]
And, the 4th would be:
matrix [rotate 45 scale 2] [box 10x10 100x100]
The advantages of this 4th form is that isolates the specification of the transformation itself. You could easily substitute other transformation information in its place, something you might do in a drawing tool for example. It might also be used to allow the direct specification of the transformation matrix.
The transformation matrix is a matrix of the form:
| a c e | | b d f | | 0 0 1 |
and can be written as the block [a b c d e f]. The MATRIX command above would allow that form as well:
matrix [1 2 3 4 5 6] [box 10x10 100x100]
Which form we pick is an important design decision because it must allow for easy creation and modification of vector descriptions. In addition, we must be absolutely sure that we preserve the semantics of translating SVG file formats into this REBOL block format. Otherwise images will be rendered incorrectly.
Please contact Cyphre or me if you have insights or experience in this issue. Thanks.
Post a Comment:
You can post a comment here. Keep it on-topic.