CORDEA blog

Android applications engineer

Flutter で 2 つの Path を組み合わせる Path#combine

Android における Path#op あるいは Canvas#clipPath のようなことをする Path#combine


api.flutter.dev


以下のような形で Path を組み合わせる

final path = Path.combine(
  _pathOperation,
  Path()
    ..addOval(Rect.fromCircle(
      center: Offset(centerX - 50, centerY),
      radius: 100,
    ))
    ..close(),
  Path()
    ..addOval(Rect.fromCircle(
      center: Offset(centerX + 50, centerY),
      radius: 100,
    ))
    ..close(),
);

canvas.drawPath(path, _paint);

PathOperation

Android と一緒です

api.flutter.dev

difference


f:id:CORDEA:20210821153045p:plain

intersect

f:id:CORDEA:20210821153118p:plain

union

f:id:CORDEA:20210821153140p:plain

xor

f:id:CORDEA:20210821153154p:plain

reverseDifference


f:id:CORDEA:20210821153128p:plain



github.com