I'm trying to draw an image on a canvas while making a custom shape of a dvd disk on it.
I'm still new to drawing in general and trying to learn it so I managed to draw the custom shape I wanted by combining quadraticBezierTo, lineTo. I tried searching for a way to apply the image to the custom shape I drew but the result I get is as it follows
my code is as it follows
late ui.Image sBackground;
which will be initialized before calling the paint class
code For the paint class is:
class Painter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..style = PaintingStyle.fill;
canvas.drawImage(sBackground, Offset.zero, paint); // drawing image to canvas in here
Path path = Path()..moveTo(0, 0);
path.quadraticBezierTo(0, 0, size.width * 0.5, 0);
path.quadraticBezierTo(size.width, 0, size.width, size.height * 0.5);
path.lineTo(size.width * 0.55, size.height * 0.5);
path.quadraticBezierTo(size.width * 0.55, size.height * 0.45,
size.width * 0.5, size.height * 0.45);
path.quadraticBezierTo(size.width * 0.45, size.height * 0.45,
size.width * 0.45, size.height * 0.5);
path.quadraticBezierTo(size.width * 0.45, size.height * 0.55,
size.width * 0.5, size.height * 0.55);
path.quadraticBezierTo(size.width * 0.55, size.height * 0.55,
size.width * 0.55, size.height * 0.5);
path.lineTo(size.width, size.height * 0.5);
path.quadraticBezierTo(
size.width, size.height, size.width * 0.5, size.height);
path.quadraticBezierTo(0, size.height, 0, size.height * 0.5);
path.quadraticBezierTo(0, 0, size.width * 0.5, 0);
path.close();
canvas.drawShadow(path, Colors.white30, 2.0, true);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
}
reference: Clip objects drawn outside of canvas which I read and tried but didn't get a result
NOTE: I'm still searching for a way to solve my problem as I post this question in here. any help or docs will really be helpful and thanks in advance