Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Drawing lines with DelphiX

  1. #1

    Drawing lines with DelphiX

    How can I draw a line with the DelphiX component? I can't see any functions whom does this.

  2. #2

    Drawing lines with DelphiX

    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]

  3. #3

    Drawing lines with DelphiX

    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 :?:

  4. #4

    Drawing lines with DelphiX

    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;

  5. #5

    Drawing lines with DelphiX

    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.

  6. #6

    Drawing lines with DelphiX

    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.

  7. #7

    Drawing lines with DelphiX

    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...

  8. #8

    Drawing lines with DelphiX

    It's just that the lines are random generated and curved. So neither an image or a rectangle would work.

  9. #9

    Drawing lines with DelphiX

    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?

  10. #10

    Drawing lines with DelphiX

    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!!!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •