Trying to understand Skia arc\curve

663 views
Skip to first unread message

louels...@gmail.com

unread,
Mar 16, 2017, 11:21:46 AM3/16/17
to skia-discuss
I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

Cary Clark

unread,
Mar 21, 2017, 5:31:27 AM3/21/17
to skia-d...@googlegroups.com
File a bug against SkiaSharp? https://github.com/mono/SkiaSharp/issues

On Thu, Mar 16, 2017 at 4:21 PM, <louels...@gmail.com> wrote:
I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

louels...@gmail.com

unread,
Mar 22, 2017, 10:05:50 AM3/22/17
to skia-discuss
Putting aside trying to convert\translate the survey curves to what the drawpath would need, is there any example (in Skia), of a polygon that is basically straight lines, with an attached curve?

Cary Clark

unread,
Mar 22, 2017, 10:15:55 AM3/22/17
to skia-d...@googlegroups.com
Many functions in SkPath add curves:

quadraticTo, rQuadraticTo
cubicTo, rCubicTo
conicTo, rConicTo
addArc, arcTo

What kind of curve are you trying to add?
Which call are you making that doesn't work as you expect?

You can put an example here that will help clarify your question:

 

--

louels...@gmail.com

unread,
Mar 22, 2017, 10:20:02 AM3/22/17
to 'Cary Clark' via skia-discuss

The original posting contains a link to a posting in the Skiasharp forum (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest), with images.  Do you want me to include them here?

 

Sent from Mail for Windows 10

 

From: 'Cary Clark' via skia-discuss
Sent: Wednesday, March 22, 2017 10:15 AM
To: skia-d...@googlegroups.com
Subject: Re: Trying to understand Skia arc\curve

 

Many functions in SkPath add curves:

 

quadraticTo, rQuadraticTo

cubicTo, rCubicTo

conicTo, rConicTo

addArc, arcTo

 

What kind of curve are you trying to add?

Which call are you making that doesn't work as you expect?

 

You can put an example here that will help clarify your question:

 

 

On Wed, Mar 22, 2017 at 10:05 AM, <louels...@gmail.com> wrote:

Putting aside trying to convert\translate the survey curves to what the drawpath would need, is there any example (in Skia), of a polygon that is basically straight lines, with an attached curve?



On Thursday, March 16, 2017 at 11:21:46 AM UTC-4, louels...@gmail.com wrote:

I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

Cary Clark

unread,
Mar 22, 2017, 10:35:20 AM3/22/17
to skia-d...@googlegroups.com
I won't be much help with Skiasharp. However, if you have questions about using Skia directly, I'll do my best to answer them.

Take a look https://fiddle.skia.org ; the menu at the top left contains "Named Fiddles".
You may find an example there that illustrates the curve that you are trying to add to your polygon.

Or, try entering an example, working or not, in the text box. You can include a link to your attempt
here to better explain your question.


On Wed, Mar 22, 2017 at 10:20 AM, <louels...@gmail.com> wrote:

The original posting contains a link to a posting in the Skiasharp forum (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest), with images.  Do you want me to include them here?

 

Sent from Mail for Windows 10

 

From: 'Cary Clark' via skia-discuss
Sent: Wednesday, March 22, 2017 10:15 AM
To: skia-d...@googlegroups.com
Subject: Re: Trying to understand Skia arc\curve

 

Many functions in SkPath add curves:

 

quadraticTo, rQuadraticTo

cubicTo, rCubicTo

conicTo, rConicTo

addArc, arcTo

 

What kind of curve are you trying to add?

Which call are you making that doesn't work as you expect?

 

You can put an example here that will help clarify your question:

 

 

On Wed, Mar 22, 2017 at 10:05 AM, <louels...@gmail.com> wrote:

Putting aside trying to convert\translate the survey curves to what the drawpath would need, is there any example (in Skia), of a polygon that is basically straight lines, with an attached curve?



On Thursday, March 16, 2017 at 11:21:46 AM UTC-4, louels...@gmail.com wrote:

I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss+unsubscribe@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

louels...@gmail.com

unread,
Mar 22, 2017, 10:57:02 AM3/22/17
to 'Cary Clark' via skia-discuss

Let me explain that I am not really a graphics person, or a GIS type, so I do not understand a lot of this.  When I go that that site, and click on the options, six little images appear showing different drawings.  The left wo drawings show images of drawings that have a mixture of straight lines, and curves.  Basically, that is what I am trying to achieve (take a survey and draw the image, sometimes it is all straight lines, sometimes it has curves.  I have the straight line drawing done, now just trying to add curves to a drawing.  Putting aside the fact that I still need to learn how to convert the curves of the survey to what Skia (or SkiaSharp) is looking for, I would like to see the code that creates those two left images.

 

As per your instructions, when I click on the Menu\Fiddles, I see a long list of fiddles, but do not know which one would be similar to the two drawings that I pointed out above (I do not know what name to look for).  And, not knowing what to input to create what I am looking for, I would not know what to enter in the Options, to draw a combination straight line\curves image.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

louels...@gmail.com

unread,
Mar 22, 2017, 11:54:00 AM3/22/17
to skia-discuss

Ok, I have looked at every one of the listed fiddles.  The two images that I would like to see the code for… are not there.  I see examples using CubicTo, ArcTo, ClipRect, but nothing that I can understand (because of everything else that is taking place in that code).   I need something simple (as I am hoping that the code for those two images would be).  Is that code available somewhere?



On Thursday, March 16, 2017 at 11:21:46 AM UTC-4, louels...@gmail.com wrote:

Cary Clark

unread,
Mar 22, 2017, 12:13:09 PM3/22/17
to skia-d...@googlegroups.com
The closest match in Skia is arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);

You have the circle radius; oval will be a square with a width and height twice the radius.
In your example, the start angle may be the angle of the previous line, but I do not know that that will always be the case in your dataset.
The sweepAngle will be the delta. However, your example shows arcs that are both clockwise and counterclockwise, so the delta is not enough.
The chord bearing plus the computed start angle may help with this.
You'll still need to determine the center of the oval from the radius and the other information in your dataset.

The information provided in your example will require some additional math to turn into something drawable.
A math forum may be a better fit to provide you with the forumula of describing the arc from the data you have.





--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

louels...@gmail.com

unread,
Mar 22, 2017, 12:24:40 PM3/22/17
to 'Cary Clark' via skia-discuss

I will try to find a GIS, Geo, etc., type of forum, to see if there is an existing math formula to convert the survey curve information, to what Skia\SkiaSharp is requiring.  I appreciate the effort that you have put into this.

 

Sent from Mail for Windows 10

 

From: 'Cary Clark' via skia-discuss
Sent: Wednesday, March 22, 2017 12:13 PM
To: skia-d...@googlegroups.com
Subject: Re: Trying to understand Skia arc\curve

 

The closest match in Skia is arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo);

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

Hal Canary

unread,
Mar 22, 2017, 12:30:54 PM3/22/17
to skia-discuss
Sounds like you want a lesson on these graphics primitives used by SkPath.  Take a look at 

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

louels...@gmail.com

unread,
Mar 22, 2017, 12:46:18 PM3/22/17
to 'Hal Canary' via skia-discuss

Hal, I do appreciate your input, but I cannot use that information as of yet.  I need to get a formula (and understand it), to convert the curve information on the survey, to what the srcTo function is expecting. 

 

Sent from Mail for Windows 10

 

From: 'Hal Canary' via skia-discuss
Sent: Wednesday, March 22, 2017 12:30 PM
To: skia-discuss
Subject: Re: Trying to understand Skia arc\curve

 

Sounds like you want a lesson on these graphics primitives used by SkPath.  Take a look at 

On Wed, Mar 22, 2017 at 8:53 AM, <louels...@gmail.com> wrote:

Ok, I have looked at every one of the listed fiddles.  The two images that I would like to see the code for… are not there.  I see examples using CubicTo, ArcTo, ClipRect, but nothing that I can understand (because of everything else that is taking place in that code).   I need something simple (as I am hoping that the code for those two images would be).  Is that code available somewhere?



On Thursday, March 16, 2017 at 11:21:46 AM UTC-4, louels...@gmail.com wrote:

I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

Hal Canary

unread,
Mar 22, 2017, 1:12:17 PM3/22/17
to skia-discuss
So it looks like you have or can calculate:
   
   S = starting point of the arc.
   E = ending point of the arc,
   R = radius of the arc (so it must be a section of circle)
   L = arc length.

Skia needs C, the center of the circle that the arc is part of.  From the definintion of a circle:

    distance(C, S) = R
    distance(C, E) = R

    (Cx-Sx)^2 + (Cy-Sy)^2 = R^2 
    (Cx-Ex)^2 + (Cy-Ey)^2 = R^2 

Solve for C = {Cx,Cy}.  Throw one answer away.

Skia also needs the start angle A and the sweep W.

    A = arctangent((Sy-Cy) / (Sx-Cx)) ;
    W = arctangent((Ey-Cy) / (Ex-Cx)) - A;

The bounding rectangle of the circle is  {Cx-R,Cy-R,Cx+R,Cy+R}

    SkPath path;
    path.arcTo({Cx-R,Cy-R,Cx+R,Cy+R}, radian2degree(A), radian2degree(W), false); 

I've glossed over some issues in this.  You may want to add 2pi to W.  And I don't know which center you want. 


On Thu, Mar 16, 2017 at 8:21 AM, <louels...@gmail.com> wrote:
I am currently using Xamarin Forms, PLC, and am using SkiSharp.  I use Drawpath with no difficulty, but that is just using straight lines.  I need to add curves to the drawing.  I can find no examples of doing this, and, do not understand exactly what the calls are looking for.  I have already posted on the Xamarin forum, (https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest).  I am posing here because SkiaSharp is based on Skia, and am hoping that someone here can help me on my way.  Thanks.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

Hal Canary

unread,
Mar 22, 2017, 1:23:52 PM3/22/17
to skia-discuss
D'oh!

    abs(W) = L / R
    (A + W) modulo 2pi  arctangent((Ey-Cy) / (Ex-Cx));

Use both equations to get the right value for W.

louels...@gmail.com

unread,
Mar 28, 2017, 10:08:25 AM3/28/17
to 'Hal Canary' via skia-discuss

I do appreciate the time that you have spent on this, but I am not a math type.  I do not know how to use the curve information provide on the survey, in the formula that you have provided…and that is why it has taken me so long to reply.

 

Sent from Mail for Windows 10

 

From: 'Hal Canary' via skia-discuss
Sent: Wednesday, March 22, 2017 1:23 PM
To: skia-discuss
Subject: Re: Trying to understand Skia arc\curve

 

D'oh!

--

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

 

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

Hal Canary

unread,
Mar 28, 2017, 11:00:29 AM3/28/17
to skia-discuss
I'm sorry, where did you get lost?

--

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss+unsubscribe@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss+unsubscribe@googlegroups.com.

Hal Canary

unread,
Mar 28, 2017, 11:04:38 AM3/28/17
to skia-discuss
On Wed, Mar 22, 2017 at 1:11 PM, Hal Canary <halc...@google.com> wrote:
[...]  And I don't know which center you want. 

Do you know that the arcs are always specified clockwise or counterclockwise with respect to the chord bearing?  If so, that would pin down the center.

louels...@gmail.com

unread,
Mar 28, 2017, 1:45:14 PM3/28/17
to 'Hal Canary' via skia-discuss

Not sure.  If I were to go by this “In land navigation, a bearing is ordinarily calculated in a clockwise direction starting from a reference direction of 0° and increasing to 359.9 degrees.”, from https://en.wikipedia.org/wiki/Bearing_(navigation)...I would say clockwise.

 

Sent from Mail for Windows 10

 

From: 'Hal Canary' via skia-discuss
Sent: Tuesday, March 28, 2017 11:04 AM
To: skia-discuss
Subject: Re: Trying to understand Skia arc\curve

 

On Wed, Mar 22, 2017 at 1:11 PM, Hal Canary <halc...@google.com> wrote:

[...]  And I don't know which center you want. 

 

Do you know that the arcs are always specified clockwise or counterclockwise with respect to the chord bearing?  If so, that would pin down the center.

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

louels...@gmail.com

unread,
Mar 28, 2017, 1:53:04 PM3/28/17
to 'Hal Canary' via skia-discuss

Where did I get lost?  Lets start with I do not know how to use what is shown in the survey curve information, to fit into your formula.  Starting, ending…are these points from the non curve lines?  From the  curve info on the survey, which info would I used for a,b,c,d, etc.?  This formula stuff (converting what is in the curve information, to what the Skia call is looking for…is all Greek to me.  It is not that I want you to do my work for me, it is just that I do not know how to do this particular stuff.

--

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

 

 

--

You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.


To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/fUSKpIy-wVw/unsubscribe.

To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.

Greg Daniel

unread,
Mar 28, 2017, 2:15:06 PM3/28/17
to skia-discuss
So since we don't know how your data is structured (as in the curves in the survey), it is going to be difficult for us to tell you how to convert from the survey format to our format for arcs, outside of the help Hal has already provided. At this point I would suggest doing the following. I assume you have gotten the survery data from somewhere or some person. I would go to them and figure out who originally generated the data set. They will have a better understanding of what the values in the survey mean. At that point they may be able to tell you directly how to convert the data into Skia's format. Or if not, you can point them to the advice Hal gave above and from there they should be able to help you figure out the mathematical conversions.
Reply all
Reply to author
Forward
0 new messages