[PD] Creating a line in Gem

Cyrille Henry ch at chnry.net
Tue Dec 18 17:24:37 CET 2012



Le 18/12/2012 17:10, Antoine Villeret a écrit :
> hi,
>
> just to notice, I used to use [GEMglBegin] -> [GEMglVertex2d] ->
> [GEMglVertex2d] -> [GEMglEnd] structure to draw line directly on
> screen
> the first GEMglVertex2d is the starting point, the second the end point
> in conjunction with [gemlist] you can draw line with an arbitrary
> number of segments which is -- but it's only my point of view -- more
> convinient than using multiple rectangles (and it's also more
> efficient because there is no extra point)
with a message [res 2<, a [curve 2 did not draw extra point.
width is change thanks to the width message.
cheers
c

> the line width is set with the [GEMglLineWidth] object...
> a good example for that is the pix_opencv_countours-help.pd patch
> which is in pix_opencv (but i know it's not really easy to find it nor
> to build it but we are currently working to improve that)
>
> best
>
> a
> --
> do it yourself
> http://antoine.villeret.free.fr
> http://drii.ensad.fr
> --
> Google lit ce mail...
> si vous refusez cela, utilisez l'adresse antoine.villeret [at] free.fr
> pour me contacter
>
>
> 2012/12/18 Alexandros Drymonitis <adrcki at gmail.com>:
>> Thanks Cyrille, this is what I wanted.
>>
>>
>> On Tue, Dec 18, 2012 at 2:25 PM, Cyrille Henry <ch at chnry.net> wrote:
>>>
>>> hello,
>>>
>>> ok, i can see why it's complicated to use rectangle in this situation.
>>> But i did not see the problem of the curve object.
>>>
>>>
>>> in order to "give this line an angle", i think it's best to use the rotate
>>> object than the shear.
>>>
>>> computation are not that hard with rectangle if you do it right :
>>> gemhead
>>> translateXYZ <- give random position
>>> rotateXYZ  <- give Z rotation
>>> scaleXYZ 0 1 1 <- change X scale to grow
>>> translate 0.5 0 0 <- to move the primitive so that it's not center
>>> rectangle 0.5 0.1 <- 0.1 is line width
>>>
>>> starting point is given by the initial translate.
>>> ending point is just : starting point + cos(angle)*line length for X
>>> coordinate,
>>> replace cos with sin for Y position (be aware that Gem is in deg, while pd
>>> is in rad)
>>>
>>>
>>>
>>> but if you prefer having random initial position and random final
>>> position, then a [curve 2] object can be more helpful.
>>>
>>> see both solution in attachment.
>>>
>>>
>>> cheers
>>> Cyrille
>>>
>>>
>>>
>>>
>>> Le 18/12/2012 12:46, Alexandros Drymonitis a écrit :
>>>>
>>>> Hi all,
>>>>
>>>> I've been trying to render a line in Gem, so I'm wondering if it's best
>>>> to use [curve] (which is actually a curve as it indicates), or [rectangle]
>>>> with a very small x value, so that it looks like a line.
>>>> My problem is that I want to give this line an angle, so I've been using
>>>> [shearXY] for now. I also want to make the line grow from nothing to the
>>>> full desired length, but with [rectangle] it will grow from the middle, so
>>>> in order to make it grow from the starting point to the ending point, you
>>>> have to give [rectangle] a continuous x,y offset.
>>>> This way it's really hard to determine the starting and ending point of
>>>> the line. So, If for example the x,y coordinates of the starting and ending
>>>> point are random, then the angle and length will also be random and you'll
>>>> have to manipulate three different objects simultaneously ([rectangle],
>>>> [translate] and [shearXY]), and I'm not sure if I can find the formula for
>>>> all these calculations.
>>>> Is there an easier technique for this?
>>>>
>>>>
>>>> _______________________________________________
>>>> Pd-list at iem.at mailing list
>>>> UNSUBSCRIBE and account-management ->
>>>> http://lists.puredata.info/listinfo/pd-list
>>>>
>>
>>
>> _______________________________________________
>> Pd-list at iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>



More information about the Pd-list mailing list