Jump to content

UniCanvas is black the first time being used


Woutero

Recommended Posts

Sherzod

I'm using a UniCanvas but the very first time I draw something on it, its starts off being black even though the Brush Color is clWhite?

The following code always show a black Canvas the very first time its used. When the code is executed a second time thereafter the background is white as it should be.

UniCanvas1.Clear;
UniCanvas1.Brush.Color:=clWhite;     
UniCanvas1.MoveTo(X1, Y1);
UniCanvas1.LineTo(X2, Y2);

 

If I just execute the first two lines once:

UniCanvas1.Clear;
UniCanvas1.Brush.Color:=clWhite;     

I end up with a black canvas.

The UniCanvas sits on a UniPanel.

I'm using UniGUI Complete Professional V1.90.0.1560 

 

Another question: Is there any way to display Text on a UniCanvas?

 

Link to comment
Share on other sites

Using Clear clears the canvas, making it black.

Setting the brush color only sets the brush color, and does not affect the canvas.

To fill a rectangle with the current brush color, use the fillRect function.

The lineTo function draws a line with pen.color and pen.width with the current pen.style.

E.g.:

with UniCanvas1 do
begin
  Clear;
  Brush.Color:=clWhite;     
  FillRect(0, 0, 100, 100);
  Pen.width:=2;
  Pen.Color:=clBlack;
  MoveTo(X1, Y1);
  LineTo(X2, Y2);
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...