How can I draw a line with the DelphiX component? I can't see any functions whom does this.
How can I draw a line with the DelphiX component? I can't see any functions whom does this.
This is done quite easily. It's actually not much different from drawing a line on the form's canvas.
[pascal]
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
//enter coords to the point you start drawing
DXDraw1.Surface.Canvas.MoveTo(10,10);
//enter coords to the endpoint of your line
DXDraw1.Surface.Canvas.LineTo(100,100);
//never forget this line when drawing on the canvas!
DXDraw1.Surface.Canvas.Release;
DxDraw1.Flip;
end;
procedure TForm1.DXDraw1Initialize(Sender: TObject);
begin
DXDraw1.Surface.Canvas.Pen.Color:=clRed;
end;
end.[/pascal]
Just make make you release the canvas again, else bad things will happen.
Displaying a text is should be easy now
[pascal]
DXDraw1.surface.Canvas.Textout(100,100,'Welcome to DGDev!');
[/pascal]
[size=9px][Edited by BlueCat - hope you don't mind Traveler, I pascal-ed your code tags :twisted: ][/size]
Thanks, everything works fine now, except that the background of the text is white.
Does anybody know how to make it black, or even better, transparent :?:
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
with DXDraw1.Surface.Canvas do
begin
Brush.Style:=bsClear;
Font.Color:=clRed;
TextOut(100,100,'Welcome to DGDev!');
Release;
end;
DXDraw1.Flip;
end;
Your code is correct DraculaLin, although I would recommend placing these 2 lines
Brush.Style:=bsClear;
Font.Color:=clRed;
in a initialization procedure, like I did in my sample. There's no need to change the brushstyle and font color every cycle.
Thanks again, but I've still one more question:
How can I fill everything beneath the lines, very fast.
I've tried with
[pascal]DXDraw1.Surface.Canvas.FloodFill(400,595,clRed,fsB order);[/pascal]
But that was way to slow.
Floodfill is indeed very slow. You'd be better off drawing a rectangle (you must also change the brush style in case you still have the style set to bsclear) or, even better use an image...
It's just that the lines are random generated and curved. So neither an image or a rectangle would work.
I have no idea if this would be faster, but couldn't you draw a rectangle starting two pixels away (leaving a small hole) from the lowest one in your curved-line-thing, and then floodfill whats left?
hi ALLLLLLLL
Now the answers here all work very well....
BUT here is a further question..
How can you draw lines and/or text so they appear on top of sprites
cheeeeeerrrrrrrssssss ato
The Universe is all right here!!!
Bookmarks