1. Thick lines

Hello, I'm trying yo write a drawing program at the moment and a question:
I have bean using draw_line() but that can only draw lines 1 pixel thick
and I nead verible line thicknes, any one know how to do this?

Thomas Parslow (PatRat)
--E-Mail:    mailto:patrat at geocities.com
--Internet:  http://www3.mistral.co.uk/billparsl/tom.htm (general page)
--                                                          OR
--               http://www3.mistral.co.uk/billparsl/index.htm (Ratty page)
--
--                                                        () _ _ ()
--                                                         (o    o)
--                                                          =\o/=

new topic     » topic index » view message » categorize

2. Re: Thick lines

PatRat wrote:

> Hello, I'm trying yo write a drawing program at the moment and a question:
> I have bean using draw_line() but that can only draw lines 1 pixel thick
> and I nead verible line thicknes, any one know how to do this?

Parameters:
        points: sequence containing the points (same as when you use draw_line)
        color: color of the line
        thick: thickness of the line. I think you can use negative values to,
so
                you can choose the side to be thickenned.

Example: thick_line({{100,100},{200,200},{250,150}},BLUE,10)
   Draws a 10 pixel thick line connecting the specified points.

----CUT----
function thick_line(sequence points, integer color, integer thick)
    for loop = 1 to length(points)-1 do
        for loop2 = 0 to thick do

        end for
    end for
end function
----CUT----

Check it, I haven't test it. Hope it works ;)

--
Regards,
        Daniel Berstein
        architek at geocities.com
        http://www.geocities.com/SiliconValley/Heights/9316

new topic     » goto parent     » topic index » view message » categorize

3. Re: Thick lines

Patrat wrote:

> Hello, I'm trying yo write a drawing program at the moment and a question:
> I have bean using draw_line() but that can only draw lines 1 pixel thick
> and I nead verible line thicknes, any one know how to do this?

        Well, all the drawing routines of Euphoria let you go out of the
screen without trouble, you then could try drawing circles from the
beginning until the end of the line, just calculate the difference.
This would create the same effect as seen in many drawing programs.

Xstep = beginX - endX
Ystep = beginY - endY

        Further, you need to know the square root of ((Xstep * 2) +
(Ystep * 2). Ask about Pythagoras to someone, he's the guy that
figurred this out. But with that square root you now the *real*
length of the line, Divide Xstep by this value and Ystep too. Store
those divided values in atoms called: small_x and small_y

[CODE THIS PIECE YOURSELF WITH THE ABOVE EXPLENATION]
[I DO NOT KNOW WHICH ROUTINES TO USE, BROWSE THE LIBRARY.DOC]

        Then simple have a couple of loops like this:

for posX = 1 to beginX-endX step small_x
        for posY = t to beginY-endY step small_y

                [Here you should draw a circle in the width you want.]

        end for
end for

        And now you should have be able to make thick lines with beautifull
rounded begin and end points.

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view message » categorize

4. Re: Thick lines

>And now you should have be able to make thick lines with beautifull
>rounded begin and end points.

>Ralf Nieuwenhuijsen
>nieuwen at xs4all.nl

Oh, now I see what you mean! You mean drawing ellipses!

Ad

new topic     » goto parent     » topic index » view message » categorize

5. Re: Thick lines

> Oh, now I see what you mean! You mean drawing ellipses!

        Now i think about it, you're right, that's what it does and it's
problely really slow too, so suggest using the other method posted by
Daniel Bernstein. But after calling that routine draw an circle of
the SAME size at the begin and end point to get beatifull rounded
corners!!

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu