SkPaint::getFillPath seems to distort geometry of small ellipses

180 views
Skip to first unread message

Igor Shturma

unread,
Dec 5, 2015, 7:52:32 PM12/5/15
to skia-discuss
Hi, 

When I apply SkPaint::getFillPath() to ellipses that are small (e.g. 1.0x1.0 circle with 0.05 stroke width), the geometry is getting distorted.
So the result of drawing an ellipse with kStroke_Style-paint and the result of getting fill path and drawing with kFill_Style-paint are different.

Here is an example:
void draw(SkCanvas* canvas) {
    canvas
->drawColor(SK_ColorWHITE);


   
SkPaint paint;
    paint
.setStyle(SkPaint::kStroke_Style);
    paint
.setStrokeWidth(.05);
    paint
.setColor(0xff1f78b4);
    paint
.setAntiAlias(true);
    paint
.setStrokeCap(SkPaint::kRound_Cap);


   
SkPaint paint2(paint);
    paint2
.setStyle(SkPaint::kFill_Style);
    paint2
.setColor(0xfff10600);    
   
   
SkRect rect;
    rect
.setXYWH(.05, .05, 1., 1.);
   
SkPath path;
    path
.addOval(rect, SkPath::kCW_Direction);
   
   
SkPath path2;
    paint
.getFillPath(path, &path2);    
   
    canvas
->scale(200., 200.);


    canvas
->drawPath(path, paint);
    canvas
->drawPath(path2, paint2);
}



Is this a known issue?

Thanks,
Igor

Cary Clark

unread,
Dec 7, 2015, 8:42:09 AM12/7/15
to skia-d...@googlegroups.com
Igor, thanks for the bug report. It appears that getFillPath is returning the wrong weight for the conics. I'll investigate.

--
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 http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Cary Clark

unread,
Dec 7, 2015, 9:02:46 AM12/7/15
to skia-d...@googlegroups.com
Igor

The behavior is as expected. You are calling getFillPath without specifying the device resolution, so the stroker assumes that the path covers a single pixel.

Here's a modified fiddle that passes in the resolution: https://fiddle.skia.org/c/4493cfea9b1fab4b8e70edc6e298ce2f

Cary

Igor Shturma

unread,
Dec 14, 2015, 1:28:43 AM12/14/15
to skia-discuss
Cary, 

Thank you for clarification.

Igor
Reply all
Reply to author
Forward
0 new messages