Author Topic: Capital Letter "D" in shapescript with arcto()  (Read 12011 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Capital Letter "D" in shapescript with arcto()
« on: January 28, 2016, 12:01:54 pm »
Hi,
The following shapescript creates a circle with a line down the middle:
Code: [Select]
ellipse(20,-5,10,5);
moveto(15,5);
lineto(15,-5);
}
- like two back-to-back capital letter "D"s.
All I want to do is to create a forward facing letter "D" (one half only).  So I need to use an acrto() function.
Arcto is problematic at the best of times.  It often takes a long tome to get a shape right with arcto().
However, this one seems to be beyond me... (Or maybe one of q's YAEAAB)

Can some kind soul please help me to draw the letter "D"?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #1 on: January 28, 2016, 12:04:26 pm »
I don't get arcto :-)  I even downloaded printable graph paper and drew out what I wanted, and then overlaid two axes to get what i though should be the right set of coordinates.  But nup!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #2 on: January 28, 2016, 01:47:03 pm »
ArcTo or BezierTo will be the only way to achieve what you're after.

Code: [Select]
shape main
{
    // Just for a comparison between ArcTo and BezierTo
    SetPen(0,0,255,3);
    // Create path so we can fill it
    StartPath();
    // Set initial point.
    moveto(0,0);
    // Move to the start of where the arc will be drawn
    // (This can be omitted because arcto will draw it)
    lineto(0,100);
    // ArcTo will always draw counterclockwise
    arcto(
        // Define a rect such that the center of the
        // circle is the left edge of the element
        -100,0,100,100,
        // Starting point is join of the ellipse and
        // the center (0,50) and this point
        0,100,
        // End point is join of the ellipse and
        // the center (0,50) and this point
        0,0
    );
    endpath();
    FillAndStrokePath();


    // The equivalent arc using bezier approximation
    // with the ratio rounded to 0.28
    SetPen(255,0,0,1);
    moveto(0,100);
    BezierTo(56,100,100,78,100,50);
    BezierTo(100,22,56,0,0,0);
}

Edited to include instructional comments in the script and comparison between two methods.
« Last Edit: January 28, 2016, 02:19:01 pm by Simon M »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #3 on: January 28, 2016, 05:36:33 pm »
Thanks Simon,

I've taken your code and used it in a target shape:
Code: [Select]
shape target
{
    // Just for a comparison between ArcTo and BezierTo
    SetPen(0,0,255,1);
    // Create path so we can fill it
    StartPath();
    // Set initial point.
    moveto(0,0);
    // Move to the start of where the arc will be drawn
    // ArcTo will always draw counterclockwise
    arcto(
        // Define a rect such that the center of the
        // circle is the left edge of the element
        -10,-5,10,5,
        // Starting point is join of the ellipse and
        // the center (0,50) and this point
        0,5,
        // End point is join of the ellipse and
        // the center (0,50) and this point
        0,-5
    );
    endpath();
    FillAndStrokePath();
}
As you can see, I've reduced the sizing appropriately, and moved the "D" so that it straddles the line (that is, centred on y=0)
Now, the "D" extends into the target shape that the connector references.
OK, so, let me move it back 10 points on the x axis:
Code: [Select]
shape target
{
    // Just for a comparison between ArcTo and BezierTo
    SetPen(0,0,255,1);
    // Create path so we can fill it
    StartPath();
    // Set initial point.
    moveto(-10,0);
    // Move to the start of where the arc will be drawn
      // ArcTo will always draw counterclockwise
    arcto(
        // Define a rect such that the center of the
        // circle is the left edge of the element
        -20,-5,0,5,
        // Starting point is join of the ellipse and
        // the center (0,50) and this point
        -10,5,
        // End point is join of the ellipse and
        // the center (0,50) and this point
        -10,-5
    );
    endpath();
    FillAndStrokePath();
}
Now, "All hell breaks loose!"

Have I misunderstood something or is this a bug?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #4 on: January 29, 2016, 09:06:56 am »
A bit of both I think.

You've defined an inverse rect for the arc. I'm not sure but that could make it draw clockwise unless it's normalized.

Also, the shapes should be in the positive x-axis. (I recommend drawing the ellipse explicitly so you can see where the arc should go)

Where things start going weird is that the arcto command isn't being rotated with the connector.

If that was fixed, I think the following would work:
Code: [Select]
shape target
{
    StartPath();
    moveto(10,-5);
    lineto(10,5);
    arcto(0,-5,20,5,10,5,10,-5);
    endpath();
    FillAndStrokePath();
}

Here's roughly the equivalent with beziers so the rotation works. Just tweak the numbers to get the curve you want.

Code: [Select]
shape target
{
    StartPath();
    moveto(10,-5);
    lineto(10,5);
    //arcto(0,-5,20,5,10,5,10,-5);
    bezierto(7,5,0,2,0,0);
    bezierto(0,-2,7,-5,10,-5);
    endpath();
    FillAndStrokePath();
}

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #5 on: January 29, 2016, 10:50:18 am »
Thanks  for investigating it Simon,
A bit of both I think.

You've defined an inverse rect for the arc. I'm not sure but that could make it draw clockwise unless it's normalized.
Ah... I thought I was just shifting it "left" by 10 - but I see that it was indeed a reversal of the "direction" - by flipping about the axis.
Quote
Also, the shapes should be in the positive x-axis. (I recommend drawing the ellipse explicitly so you can see where the arc should go)
Is that a requirement of the current design a "first principles" issue - seems the former to me.
Quote
Where things start going weird is that the arcto command isn't being rotated with the connector.

If that was fixed, I think the following would work:
[SNIP]
So should I report a bug for the absent rotation?  I'll try the Bezier option but I might just use a set of lines to simulate.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #6 on: January 29, 2016, 01:04:00 pm »
Just quickly: x-axis direction, think of targeting the left edge as the native (unrotated side)

Yes, I would report a bug.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #7 on: February 01, 2016, 11:23:49 am »
I figured out how to achieve x-axis translation with arcto(), and I've reported the rotation bug.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #8 on: February 08, 2016, 07:07:37 pm »
Simon M has indicated, elsewhere, that there has been a regression bug introduced after v10.

While we're on this, I think this may also be one:

I've created shapescripts for various letters on connectors - T, U, E, etc.  I thought I'd simulate the letter "D" with:
Code: [Select]
shape target
{
        StartPath();
moveto(15,-5);
lineto(15,5);
lineto(13,5);
lineto(11,3);
lineto(10,2);
lineto(10,-2);
lineto(11,-3);
lineto(13,-5);
lineto(15,-5);
endpath();
Strokepath();
}
For some orientations, it makes a passable letter "D", but as you swing the line around 360 degrees, some of the renderings are really wierd.

I don'r recall any of my other letters (v9 and before) behaving in this odd way.

Can any one confirm this behaviour?

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #9 on: February 08, 2016, 09:36:38 pm »
What are "some orientations"? Testing this gives a mirrored D. Maybe you should look at the OCR font. This is more easily to plot.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #10 on: February 09, 2016, 08:59:18 am »
I'd say it's just rounding that you're seeing. Because you're dealing with very small shapes rounding can sometimes have a very large impact.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #11 on: February 09, 2016, 04:40:05 pm »
What are "some orientations"? Testing this gives a mirrored D. Maybe you should look at the OCR font. This is more easily to plot.

q.

q,

the way I show this is to take the target shape and move it "around" the source shape through the whole 360 degrees so I can see how the decoration will look at all the different orientations.

Try it, you'll see what I mean.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8605
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #12 on: February 09, 2016, 04:45:13 pm »
I'd say it's just rounding that you're seeing. Because you're dealing with very small shapes rounding can sometimes have a very large impact.
I was afraid of that...

Yes it might have an impact, but it's pretty high...

For testing purposes, I have the zoom set up high - which only accentuates the effect!  :(

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #13 on: February 09, 2016, 07:32:25 pm »
q,

the way I show this is to take the target shape and move it "around" the source shape through the whole 360 degrees so I can see how the decoration will look at all the different orientations.

Try it, you'll see what I mean.

Paolo
Still having problems. What means "move it around"? How do you accomplish that? I guess not by using it as decoration since that produces just a tiny dash.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8078
  • Karma: +118/-20
    • View Profile
Re: Capital Letter "D" in shapescript with arcto()
« Reply #14 on: February 10, 2016, 08:43:06 am »
For a little more clarity on testing different angles of connector end shape scripts:

  • Assign the stereotype to a connector
  • Set the line style to custom (if not already set)
  • Add a bend point to the connector
  • Click and drag the bend point to move it
  • Drag the bend around the target element to get a live drawing at every angle