Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite rendering to care about more complex transforms #149

Open
meyfa opened this issue Feb 21, 2022 · 0 comments
Open

Rewrite rendering to care about more complex transforms #149

meyfa opened this issue Feb 21, 2022 · 0 comments
Labels
enhancement Improvement to an existing feature
Milestone

Comments

@meyfa
Copy link
Owner

meyfa commented Feb 21, 2022

Renderers such as the rect renderer currently assume only translation and scale transforms are present. This means that e.g. rotated rects cannot be rendered. Instead of computing the bottom-right corner AFTER the transform was applied to the top-left edge and size, we have to compute each corner first and then map them separately.

The following renderer types are affected:

  • rect
  • ellipse
  • image
  • text

Rect and ellipse can probably be implemented somewhat effectively by generating an equivalent path and rendering that via the path renderer (which supports every type of transform quite well). Transforming embedded SVG images should be doable, but embedded raster images might require a lot of work. For PHP >= 5.5.0 there is imageaffine() but I have no idea what to do on PHP 5.3 or 5.4. Text can be rotated via imagettftext(), but not skewed or non-uniformly scaled.

@meyfa meyfa added the enhancement Improvement to an existing feature label Feb 21, 2022
@meyfa meyfa added this to the v0.12.0 milestone Feb 21, 2022
meyfa added a commit that referenced this issue Mar 6, 2022
This implements one part of issue #149. By basing the renderer for
rectangles off of the path painting algorithms, we can easily obtain
rotated and skewed rectangles. This would be very difficult to do
manually especially for rectangles with rounded corners. Now, we can
simply use the arc approximator to construct a polygon.

I was torn between basing the RectRenderer off of either the
PathRenderer, which would be the obvious choice but would require
needlessly constructing an intermediate command array, or the
PolygonRenderer, which means we have to work with the ArcApproximator on
a lower level but possibly get better performance. I chose the latter.
meyfa added a commit that referenced this issue Mar 6, 2022
This implements one part of issue #149. By basing the renderer for
rectangles off of the path painting algorithms, we can easily obtain
rotated and skewed rectangles. This would be very difficult to do
manually especially for rectangles with rounded corners. Now, we can
simply use the arc approximator to construct a polygon.

I was torn between basing the RectRenderer off of either the
PathRenderer, which would be the obvious choice but would require
needlessly constructing an intermediate command array, or the
PolygonRenderer, which means we have to work with the ArcApproximator on
a lower level but possibly get better performance. I chose the latter.
@meyfa meyfa modified the milestones: v0.12.0, v0.13.0, v0.14.0 Dec 7, 2022
@meyfa meyfa modified the milestones: v0.14.0, v0.15.0 Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant