[solved] Need fast InvertRect for canvas lazarus / 31-LCL ---------------------------------------------------------------------- AlexTP · 2015-03-09 18:36 My example of fast invert rect; It's OK on Win, but bad on Linux/Gtk2: i see left edge of rect is painted white. 1pix line at left and top. Bug? Other way to do fast invert? Quoteprocedure CanvasInvertRect(C: TCanvas; const R: TRect); var   N: TColor; begin   N:= C.Brush.Color;   C.Pen.Color:= clWhite;   C.Brush.Color:= clWhite;   C.Pen.Width:= 1;   C.Pen.Mode:= pmXor;   C.Rectangle(R);   C.Pen.Mode:= pmCopy;   C.Rectangle(Rect(0, 0, 0, 0)); //update pen.mode   C.Brush.Color:= N; end; ---------------------------------------------------------------------- mm7 · 2015-03-10 21:21 May be brushed area overlaps with left side of the rectangle frame. Try to draw smaller rectangle with just the brush and then draw brushless rectangle with xor pen as frame. ---------------------------------------------------------------------- AlexTP · 2015-03-10 21:34 Tks. I fixed by SynEdit code Code: [Select]procedure CanvasInvertRect(C: TCanvas; const R: TRect; AColor: TColor); var   X: integer;   AM: TAntialiasingMode; begin   if not Assigned(_Pen) then     _Pen:= TPen.Create;   AM:= C.AntialiasingMode;   _Pen.Assign(C.Pen);   X:= (R.Left+R.Right) div 2;   C.Pen.Mode:= pmNotXor;   C.Pen.Style:= psSolid;   C.Pen.Color:= AColor;   C.AntialiasingMode:= amOff;   C.Pen.EndCap:= pecFlat;   C.Pen.Width:= R.Right-R.Left;   C.MoveTo(X, R.Top);   C.LineTo(X, R.Bottom);   C.Pen.Assign(_Pen);   C.AntialiasingMode:= AM;   C.Rectangle(0, 0, 0, 0); //apply pen end; solved..