尽管此代码是javascript,但此link
中给出了答案 0 :(得分:2)
我使用了ImageShader并使用了Paint Function的shader属性 设备变换用于获取设备像素,以便可以渲染效果 这是我的绘画方法,看起来像...
final double devicePixelRatio = ui.window.devicePixelRatio;
@override
void paint(Canvas canvas, Size size) {
final Float64List deviceTransform = new Float64List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio
..[10] = 1.0
..[15] = 2.0;
Float64List matrix = new Float64List(16);
print('matrix is $matrix');
print('image is coming in paint $image');
Paint paint = new Paint()
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..shader = ImageShader(
image, TileMode.repeated, TileMode.repeated, deviceTransform)
..strokeWidth = 40.2;
paths.forEach((path) {
canvas.drawPath(path, paint);
});
repaint = false;
}