-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
clipToRect not correctly applied to fillGlyphRun within rotated context #193
Comments
Apologies, this problem is actually not about glyphs, as the above images show the clipping is also not being correctly applied to simple lines and rectangle strokes. This simplified code listing demonstrates: // Outer and inner rectangles
const BLRect outer_rect{0, 0, 50, 100};
const BLRect inner_rect{-30, -30, 60, 60};
// Make test image and context
const auto test_width = 200;
const auto test_height = 200;
BLImage img(test_width, test_height, BL_FORMAT_PRGB32);
BLContext ctx(img);
ctx.clearAll();
// Draw image boundary
ctx.setStrokeStyle(BLRgba32{255, 255, 0, 255});
ctx.strokeRect(BLRect{0, 0, test_width, test_height});
// Move the origin to the centre of the image
const auto origin_x = test_width * 0.5;
const auto origin_y = test_height * 0.5;
ctx.translate(origin_x, origin_y);
// Rotate everything around the centre
const auto degrees = 35.0;
static const constexpr double to_radians = 3.1415926535 / 180;
ctx.rotate(degrees * to_radians); // <<-------- ROTATE
// Clip with inner rectangle
ctx.clipToRect(inner_rect); // <<--------------- CLIP
// Position rectangles over the origin
ctx.save();
ctx.translate(-outer_rect.w * 0.5, -outer_rect.h * 0.5);
// Draw outer rect and lines
ctx.setStrokeStyle(BLRgba32(0, 128, 255, 255));
ctx.strokeRect(outer_rect);
ctx.strokeLine(BLLine{0, 0, outer_rect.w, outer_rect.h});
ctx.strokeLine(BLLine{0, outer_rect.h, outer_rect.w, 0});
ctx.restore();
// Draw inner rect used for clipping
ctx.setStrokeStyle(BLRgba32(255, 0, 0, 255));
ctx.strokeRect(inner_rect); The actual clipping is performed inside what seems suspiciously similar to the screen-space extents of the transformed clipping rect. |
This is an unimplemented feature at the moment. It's on the roadmap, I will focus on this after new stroking engine is merged. |
Thanks. Out of interest, do you publish your development roadmap anywhere? |
Yeah the current roadmap is here: In general all features mentioned on roadmap are planned, and those blue (in progress) have high priority and the work has already started. |
Hi,
Glyph rendering doesn't seem to honour clipping when the glyph and clip-rect are rotated. What follows is a fairly indepth demo of precise control over glyph positioning. The objective here is to place a glyph at the centre of the image with very specific scaling, rotate and clip it. See the four images at the bottom which show the behaviour with and without rotation and clipping.
Many of the steps below are not required to trigger this bug (assuming that is what this is), but because of the complexities of positioning glyphs accurately/correctly I felt it necessary to set out a full demo.
Set up a font and size it for precise control over ascent+descent height:
Create the output image and bind the context, set the origin to the centre of the image:
Draw a rotated glyph with clipping:
Results:
With no rotation and no clipping:
With no rotation, but with clipping:
With rotation, and no clipping:
With rotation, and with clipping:
The meaning of the coloured rectangles are as follows:
You can see in the last image the clipping rectangle is not transformed correctly and the result is incorrect clipping. This demo was compiled and run under MinGW-w64, GCC.
Thanks,
Nathan
The text was updated successfully, but these errors were encountered: