#include "SkCanvas.h" #include "SkPath.h" int main() { // Create a rectangle path SkPath rectPath; rectPath.addRect(0, 0, 100, 50); // Offset the path by 10 units in both x and y directions SkPath offsetPath; rectPath.offset(10, 10, &offsetPath); // Draw the offset path on a canvas SkCanvas canvas; canvas.drawPath(offsetPath, SkPaint()); }
#include "SkCanvas.h" #include "SkPath.h" int main() { // Create a circle path SkPath circlePath; circlePath.addCircle(50, 50, 25); // Offset the path by -20 units in x direction SkPath offsetPath; circlePath.offset(-20, 0, &offsetPath); // Draw the offset path on a canvas SkCanvas canvas; canvas.drawPath(offsetPath, SkPaint()); }Both examples use the Skia Graphics Library and demonstrate the use of the SkPath offset method to create new paths by offsetting existing paths.