Flutter 颤振自定义绘制交叉,带有路径,但带有渐变和圆角
我刚开始接触定制画师,我已经创建了一个基本的十字,但不知道如何使角变圆,使颜色渐变 渐变似乎需要Flutter 颤振自定义绘制交叉,带有路径,但带有渐变和圆角,flutter,dart,custom-painting,Flutter,Dart,Custom Painting,我刚开始接触定制画师,我已经创建了一个基本的十字,但不知道如何使角变圆,使颜色渐变 渐变似乎需要createShader,它需要rect,但我没有,因为我使用了路径 另外,我想绕一下十字架的拐角,但不知道怎么做。我曾想过创建矩形,但似乎也不可能创建倾斜的矩形 class CrossPainter extends CustomPainter { CrossPainter({this.bodyColour, this.strokeColour, this.stroke}); final Co
createShader
,它需要rect
,但我没有,因为我使用了路径
另外,我想绕一下十字架的拐角,但不知道怎么做。我曾想过创建矩形,但似乎也不可能创建倾斜的矩形
class CrossPainter extends CustomPainter {
CrossPainter({this.bodyColour, this.strokeColour, this.stroke});
final Color bodyColour;
final Color strokeColour;
final double stroke;
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint();
paint
..color = strokeColour
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeWidth = stroke;
Paint paint1 = Paint();
paint1
..color = bodyColour
..style = PaintingStyle.fill
..strokeWidth = 0;
double width = size.width;
double height = size.height;
Path path = Path();
path.addPolygon([Offset.zero, Offset(width / 4, 0), Offset(width, height), Offset(width - (width / 4), height)], true);
Path path2 = Path();
path2.addPolygon(
[Offset(width, 0), Offset(width - (width / 4), 0), Offset(0, height), Offset(0 + (width / 4), height)], true);
canvas.drawPath(path, paint1);
canvas.drawPath(path2, paint1);
// canvas.drawPath(path, paint); //border
// canvas.drawPath(path2, paint); //border
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
我还有
paint1
,它添加了一个边框,但看起来不太好,因为每个多边形都是一个单独的对象;这个对话已经结束了。@pskink看看这个,我看起来不能让一个多边形有圆角,看起来在颤振中没有任何东西。我必须手动点到点画一个多边形,并围绕每个角。@Bhargav-Rao♦ 我认为没有人会收到任何关于聊天的通知。一旦开始聊天,对方就会消失。