-
-
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
Unexpected results with BLPattern #200
Labels
Comments
I think this could be related to JIT pipeline generator not generating the intended code in some configurations, because when I put this to fiddle it shows the correct output: #include <blend2d.h>
BLImage render(const BLContextCreateInfo& cci) {
BLImage imgPattern(300, 300, BL_FORMAT_PRGB32);
double w = imgPattern.width();
double h = imgPattern.height();
double xc = w/2.0;
double yc = h/2.0;
{
BLContext ctxS(imgPattern);
ctxS.fillAll(BLRgba32(0xFFff0000));
ctxS.fillCircle(xc,yc ,0.21*w, BLRgba32(0xFF0000ff));
ctxS.fillCircle(xc,yc, 0.11*w, BLRgba32(0xFF888888));
ctxS.strokeLine(0,0,w,h, BLRgba32(0xFFffff00));
ctxS.strokeLine(0,h,w,0, BLRgba32(0xFFffffff));
ctxS.strokeLine(0,yc,w,yc, BLRgba32(0xFFffffff));
ctxS.strokeLine(xc,0,xc,h, BLRgba32(0xFFffffff));
ctxS.end();
}
// create the main BLContext
BLImage img(400, 400, BL_FORMAT_PRGB32);
BLContext ctx(img);
ctx.clearAll();
ctx.setTransform( {1,0,0,1, 200,200} ); //put the origin at the center of img
BLPattern myPattern;
myPattern.setImage(imgPattern);
// put the origin of the pattern in its center
myPattern.setTransform({1,0,0,1, xc, yc});
// experimental variations :
// myPattern.setTransform({1,0,0,1, xc+0.01, yc}); // it works !
// myPattern.setTransform({1,0,0,1, xc+0.001, yc}); // still wrong
// myPattern.setExtendMode(BL_EXTEND_MODE_REFLECT); // it works !
ctx.setFillStyle(myPattern);
ctx.fillCircle(0,0,90);
ctx.end();
return img;
} |
Marking this as a bug - this needs a test suite to be sure. |
Indeed, this was a bug and it's now fixed in v0.11.0! Thanks for the report! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a stunning test showing an unexpected result with BLPattern.
Tested on Windows with blend2d 'master' branch dated 10-mar-2024.
see code below
What's more surprising is that this minimal code, when excuted with fiddle.blend2d.com,
works correctly !
What I'm trying to do:
On the main BL::context,
draw a circle at the center of the image, filled with with the center of a large pattern.
Here you can see
I've tried many tricks and variations ...
What's stunning is that, if I just add a small displacement (0.01) to the 'center'
of the pattern, I get the correct result
BUT if this displacement is 0.001 , then the result is still wrong.
Then I introduced another variation:
if I set
myPattern.setExtendMode(BL_EXTEND_MODE_REFLECT)
then the result is correct, but I don't understand why, since
I "fetch" just the basic pattern-image, no need to fetch 'extended' parts ..
Please, can you confirm or reject this issue with the latest release ?
---- code ---- tesPattern.cpp
The text was updated successfully, but these errors were encountered: