I'd like to get back to this clipping procedure, which as far as I understand is the SMP translation of this windows GDI+ clipping technique. As far as clipping i concerned, it works as it should, but the text rendering sucks. I didn't realize this at first because I was working with white text on black background. In the code below, I added some text in the clipped region and changed the colours to make the problem visible.
include(fb.ComponentPath + "docs\\helpers.js");
let font = gdi.Font("segoe UI", 16);
let myRegion = new PaintRegion(100, 100, 200, 200)
function on_paint(gr){
gr.FillSolidRect(0, 0, window.Width, window.Height, colours.DarkGray);
gr.GdiDrawText("TEST", font, colours.White,110, 70, 100, 20)
myRegion.paint(gr);
}
function PaintRegion(x, y, w, h){
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.paint = (gr) => {
gr.FillSolidRect(this.x, this.y, this.w, this.h, colours.Pink);
var clipImg = gdi.CreateImage(this.w, this.h)
var grClip = clipImg.GetGraphics();
grClip.GdiDrawText("TEST", font, colours.White, 10, 10, 100, 20)
grClip.DrawEllipse(100, 50, 200, 200, 2, colours.White);
clipImg.ReleaseGraphics(grClip);
gr.DrawImage(clipImg, this.x, this.y, this.w, this.h, 0, 0, this.w, this.h)
}
}
In the attached picture you can see the outcome. The first line of text on gray background is drawn with the regular graphics object passed by the on_paint callback, the one below, in the pink clipped region is drawn with the clipped graphics object. SetTextRenderingHint and SetSmoothingMode didn't help.
How can I avoid this blurred effect?