MCPcopy Create free account
hub / github.com/HumbleUI/Skija / drawFillPaths

Method drawFillPaths

examples/scenes/src/PathsScene.java:439–493  ·  view source on GitHub ↗
(Canvas canvas)

Source from the content-addressed store, hash-verified

437 }
438
439 private void drawFillPaths(Canvas canvas) {
440 canvas.save();
441
442 try (Path path = new PathBuilder().moveTo(20, 5).lineTo(35, 35).lineTo(5, 35).closePath().build();
443 Paint stroke1 = new Paint().setColor(0xFF247ba0).setMode(PaintMode.STROKE).setStrokeWidth(1))
444 {
445 Paint[] paints = new Paint[] {
446 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10),
447 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10).setStrokeMiter(2),
448 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10).setStrokeJoin(PaintStrokeJoin.ROUND),
449 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10).setStrokeJoin(PaintStrokeJoin.BEVEL)
450 };
451
452 for (Paint stroke5: paints) {
453 canvas.drawPath(path, stroke5);
454 canvas.drawPath(path, stroke1);
455 canvas.translate(50, 0);
456
457 try (Path fillPath = stroke5.getFillPath(path)) {
458 canvas.drawPath(fillPath, stroke1);
459 canvas.translate(50, 0);
460 }
461
462 try (Path fillPath = stroke5.getFillPath(path, Rect.makeLTRB(15, 15, 25, 25), 0.1f)) {
463 canvas.drawPath(fillPath, stroke1);
464 canvas.translate(50, 0);
465 }
466
467 stroke5.close();
468 }
469 }
470
471 try (Path path = new PathBuilder().moveTo(5, 35).lineTo(15, 10).lineTo(25, 30).lineTo(35, 5).build();
472 Paint stroke1 = new Paint().setColor(0xFF247ba0).setMode(PaintMode.STROKE).setStrokeWidth(1))
473 {
474 Paint[] paints = new Paint[] {
475 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10),
476 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10).setStrokeCap(PaintStrokeCap.ROUND),
477 new Paint().setColor(0xFFffe066).setMode(PaintMode.STROKE).setStrokeWidth(10).setStrokeCap(PaintStrokeCap.SQUARE)
478 };
479 for (Paint stroke5: paints) {
480 canvas.drawPath(path, stroke5);
481 canvas.drawPath(path, stroke1);
482 canvas.translate(50, 0);
483 try (Path fillPath = stroke5.getFillPath(path)) {
484 canvas.drawPath(fillPath, stroke1);
485 }
486 canvas.translate(50, 0);
487 stroke5.close();
488 }
489 }
490
491 canvas.restore();
492 canvas.translate(0, 50);
493 }
494
495 private void drawPathsOp(Canvas canvas) {
496 canvas.save();

Callers 1

drawMethod · 0.95

Calls 15

saveMethod · 0.80
closePathMethod · 0.80
lineToMethod · 0.80
moveToMethod · 0.80
setStrokeWidthMethod · 0.80
setModeMethod · 0.80
setStrokeMiterMethod · 0.80
setStrokeJoinMethod · 0.80
getFillPathMethod · 0.80
setStrokeCapMethod · 0.80
restoreMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected