New arrows for ConnectorMorph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

New arrows for ConnectorMorph

Noury Bouraqadi
Hi,

I'd like to have connectors with new arrow shapes (circles, arcs,  
rhombus...)
How can do that? Together with Serge, we had a look on class methods  
such as NCAAConnectorMorph class>>#basicArrow (see code below).
But, we could not figure-out how to easily and cleanly change the  
points to have the expected shape.

Thanks,
Noury
------------
NCAAConnectorMorph class>>#basicArrow
        "glyph 54 from Arrows1"
^(NCLineArrowGlyph withContours: (
(Array new: 1)
        at: 1 put: {
        0.0@0.0 . 0.0@0.0 . -0.5@0.3298 .
        -0.5@0.3298 . -0.5@0.3298 . 0.0@-0.666 .
        0.0@-0.666 . 0.0@-0.666 . 0.5@0.3298 .
        0.5@0.3298 . 0.5@0.3298 . 0.0@0.0 };
        yourself
"clicks 0.0@0.0"
)) offset: 0@0.666;
defaultScale: 3.0;
yourself

------------------------------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
ARMINES - Ecole des Mines de Douai - Dept. I.A.
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group Board
http://www.esug.org

Squeak: a Free Smalltalk
http://www.squeak.org
------------------------------------------------------------------




Reply | Threaded
Open this post in threaded view
|

Re: New arrows for ConnectorMorph

Andreas.Raab
Noury Bouraqadi wrote:
> I'd like to have connectors with new arrow shapes (circles, arcs,
> rhombus...)
> How can do that? Together with Serge, we had a look on class methods
> such as NCAAConnectorMorph class>>#basicArrow (see code below).
> But, we could not figure-out how to easily and cleanly change the points
> to have the expected shape.

This is a quadratic bezier curve. Each segment is made up by three
consecutive points where the first and the third point are start and end
and the intermediate is a control point that describes how the curve is
shaped. To draw straight lines, have the intermediate point coincide
with either start or end. See also (but for cubic beziers) the
description at wikipedia:

   http://en.wikipedia.org/wiki/Bezier_curve

On a related note, be advised that non-rational bezier curves cannot
truthfully approximate circles and other conic sections. To approximate
ellipses see Bezier2Segment class>>makeEllipseSegments: in the 3.9
graphics package. The points you see in Ned's spec are the control
points of such segments (this may be helpful with exploring the exact
shape you are trying to construct).

Hope this helps,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: New arrows for ConnectorMorph

Noury Bouraqadi
Thanks Andreas for your help.
Do you know if there any constraints/dependencies on/between points  
belonging to two different segments defined for the same arrow ?  
Though we know about bezier curves, still we don't fully understand  
the implementation. We'd like to draw an open symbol, something like  
a "lower than" (<) symbol.

Noury
Le 7 sept. 06 à 08:30, Andreas Raab a écrit :

> Noury Bouraqadi wrote:
>> I'd like to have connectors with new arrow shapes (circles, arcs,  
>> rhombus...)
>> How can do that? Together with Serge, we had a look on class  
>> methods such as NCAAConnectorMorph class>>#basicArrow (see code  
>> below).
>> But, we could not figure-out how to easily and cleanly change the  
>> points to have the expected shape.
>
> This is a quadratic bezier curve. Each segment is made up by three  
> consecutive points where the first and the third point are start  
> and end and the intermediate is a control point that describes how  
> the curve is shaped. To draw straight lines, have the intermediate  
> point coincide with either start or end. See also (but for cubic  
> beziers) the description at wikipedia:
>
>   http://en.wikipedia.org/wiki/Bezier_curve
>
> On a related note, be advised that non-rational bezier curves  
> cannot truthfully approximate circles and other conic sections. To  
> approximate ellipses see Bezier2Segment class>>makeEllipseSegments:  
> in the 3.9 graphics package. The points you see in Ned's spec are  
> the control points of such segments (this may be helpful with  
> exploring the exact shape you are trying to construct).
>
> Hope this helps,
>   - Andreas
>

------------------------------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
ARMINES - Ecole des Mines de Douai - Dept. I.A.
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group Board
http://www.esug.org

Squeak: a Free Smalltalk
http://www.squeak.org
------------------------------------------------------------------




Reply | Threaded
Open this post in threaded view
|

Re: New arrows for ConnectorMorph

Andreas.Raab
I have no idea how connectors handle this. If it's mapped straight into
Balloon then it should be the case that you can make up arbitrary
segments but that they should form closed shapes for rendering. E.g.,
instead of a "regular" set of curves like here:
   {
     0@0. 0@0. 1@0. "right"
     1@0. 1@0. 1@1. "down"
     1@1. 1@1. 0@1. "left"
     0@1. 0@1. 0@0. "up"
   }

the following would work just as well in Balloon:

   {
     0@0. 0@0. 1@0. "right"
     1@1. 1@1. 0@1. "left"
     0@1. 0@1. 0@0. "up"
     1@0. 1@0. 1@1. "down"
   }

Since the segments form a closed outline and that is really all that is
required to draw them.

Cheers,
   - Andreas

Noury Bouraqadi wrote:

> Thanks Andreas for your help.
> Do you know if there any constraints/dependencies on/between points
> belonging to two different segments defined for the same arrow ? Though
> we know about bezier curves, still we don't fully understand the
> implementation. We'd like to draw an open symbol, something like a
> "lower than" (<) symbol.
>
> Noury
> Le 7 sept. 06 à 08:30, Andreas Raab a écrit :
>
>> Noury Bouraqadi wrote:
>>> I'd like to have connectors with new arrow shapes (circles, arcs,
>>> rhombus...)
>>> How can do that? Together with Serge, we had a look on class methods
>>> such as NCAAConnectorMorph class>>#basicArrow (see code below).
>>> But, we could not figure-out how to easily and cleanly change the
>>> points to have the expected shape.
>>
>> This is a quadratic bezier curve. Each segment is made up by three
>> consecutive points where the first and the third point are start and
>> end and the intermediate is a control point that describes how the
>> curve is shaped. To draw straight lines, have the intermediate point
>> coincide with either start or end. See also (but for cubic beziers)
>> the description at wikipedia:
>>
>>   http://en.wikipedia.org/wiki/Bezier_curve
>>
>> On a related note, be advised that non-rational bezier curves cannot
>> truthfully approximate circles and other conic sections. To
>> approximate ellipses see Bezier2Segment class>>makeEllipseSegments: in
>> the 3.9 graphics package. The points you see in Ned's spec are the
>> control points of such segments (this may be helpful with exploring
>> the exact shape you are trying to construct).
>>
>> Hope this helps,
>>   - Andreas
>>
>
> ------------------------------------------------------------------
> Dr. Noury Bouraqadi - Enseignant/Chercheur
> ARMINES - Ecole des Mines de Douai - Dept. I.A.
> http://csl.ensm-douai.fr/noury
>
> European Smalltalk Users Group Board
> http://www.esug.org
>
> Squeak: a Free Smalltalk
> http://www.squeak.org
> ------------------------------------------------------------------
>
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New arrows for ConnectorMorph

Noury Bouraqadi
It looks like Connectors does not map curves directly to balloon  
since the two arrays that you provided does not build the same shape.  
The first one draws a square, while the second one draws a kind of  
triangle (see below).

Noury

Le 8 sept. 06 à 01:22, Andreas Raab a écrit :

> I have no idea how connectors handle this. If it's mapped straight  
> into Balloon then it should be the case that you can make up  
> arbitrary segments but that they should form closed shapes for  
> rendering. E.g., instead of a "regular" set of curves like here:
>   {
>     0@0. 0@0. 1@0. "right"
>     1@0. 1@0. 1@1. "down"
>     1@1. 1@1. 0@1. "left"
>     0@1. 0@1. 0@0. "up"
>   }

> the following would work just as well in Balloon:
>
>   {
>     0@0. 0@0. 1@0. "right"
>     1@1. 1@1. 0@1. "left"
>     0@1. 0@1. 0@0. "up"
>     1@0. 1@0. 1@1. "down"
>   }
>


> Since the segments form a closed outline and that is really all  
> that is required to draw them.
>
> Cheers,
>   - Andreas
>
> Noury Bouraqadi wrote:
>> Thanks Andreas for your help.
>> Do you know if there any constraints/dependencies on/between  
>> points belonging to two different segments defined for the same  
>> arrow ? Though we know about bezier curves, still we don't fully  
>> understand the implementation. We'd like to draw an open symbol,  
>> something like a "lower than" (<) symbol.
>> Noury
>> Le 7 sept. 06 à 08:30, Andreas Raab a écrit :
>>> Noury Bouraqadi wrote:
>>>> I'd like to have connectors with new arrow shapes (circles,  
>>>> arcs, rhombus...)
>>>> How can do that? Together with Serge, we had a look on class  
>>>> methods such as NCAAConnectorMorph class>>#basicArrow (see code  
>>>> below).
>>>> But, we could not figure-out how to easily and cleanly change  
>>>> the points to have the expected shape.
>>>
>>> This is a quadratic bezier curve. Each segment is made up by  
>>> three consecutive points where the first and the third point are  
>>> start and end and the intermediate is a control point that  
>>> describes how the curve is shaped. To draw straight lines, have  
>>> the intermediate point coincide with either start or end. See  
>>> also (but for cubic beziers) the description at wikipedia:
>>>
>>>   http://en.wikipedia.org/wiki/Bezier_curve
>>>
>>> On a related note, be advised that non-rational bezier curves  
>>> cannot truthfully approximate circles and other conic sections.  
>>> To approximate ellipses see Bezier2Segment  
>>> class>>makeEllipseSegments: in the 3.9 graphics package. The  
>>> points you see in Ned's spec are the control points of such  
>>> segments (this may be helpful with exploring the exact shape you  
>>> are trying to construct).
>>>
>>> Hope this helps,
>>>   - Andreas
>>>
>> ------------------------------------------------------------------
>> Dr. Noury Bouraqadi - Enseignant/Chercheur
>> ARMINES - Ecole des Mines de Douai - Dept. I.A.
>> http://csl.ensm-douai.fr/noury
>> European Smalltalk Users Group Board
>> http://www.esug.org
>> Squeak: a Free Smalltalk
>> http://www.squeak.org
>> ------------------------------------------------------------------
>
>
------------------------------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
ARMINES - Ecole des Mines de Douai - Dept. I.A.
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group Board
http://www.esug.org

Squeak: a Free Smalltalk
http://www.squeak.org
------------------------------------------------------------------





Image 1.png (4K) Download Attachment
Image 2.png (4K) Download Attachment