SkPaint myPaint; myPaint.setStrokeWidth(5.0f); float strokeWidth = myPaint.getStrokeWidth();
void drawLine(SkCanvas* canvas, SkPaint paint, SkPoint p1, SkPoint p2) { paint.setStyle(SkPaint::kStroke_Style); canvas->drawLine(p1.x(), p1.y(), p2.x(), p2.y(), paint); } SkPaint myPaint; myPaint.setStrokeWidth(2.0f); drawLine(canvas, myPaint, SkPoint::Make(0, 0), SkPoint::Make(10, 10));In this example, we create a SkPaint object with a stroke width of 2.0, and then use it to draw a line on a SkCanvas object using the drawLine() method. The getStrokeWidth() method is not used directly, but the stroke width we set using it is used in the drawing operation. Package/library: Skia Graphics Library.