NativeScript / canvas

Apache License 2.0
88 stars 18 forks source link

Path2D.roundedRect crash on iOS 15.4 #86

Closed darkyelox closed 1 year ago

darkyelox commented 2 years ago

Tested on simulator with: @nativescript/core: 8.3.2 @nativescript/ios: 8.3.2

There is a weird behavior with the roundedRect on iOS:

const checkboxPath = new Path2D()

checkboxPath.roundedRect(0,0, 50, 50, 1) // this draw a weird shape if I draw something else over it

// checkboxPath.roundedRect(0,0, 50, 50, 10) <--- this crash the app

canvasContext.fill(checkboxPath)

I tried to create my own roundedRect function with the next code but it also crashes the app:

  if (width < 2 * radius) radius = width / 2;
  if (height < 2 * radius) radius = height / 2;
  context.beginPath();
  context.moveTo(x+radius, y);
  context.arc(x+width, y,   x + width, y + height, radius);
  context.arcTo(x+width, y+height, x,   y+height, radius);
  context.arcTo(x,   y+height, x,   y,   radius);
  context.arcTo(x,   y,   x+width, y,   radius);
  context.closePath();

I was trying to animate a rounded rect increasing on a custom checkbox for a checked state and drawing the check mark over it also animated.

triniwiz commented 2 years ago

I added the roundRect method it will be available in the next release

triniwiz commented 2 years ago

You can try it on the latest alpha