drawYIntervalSegmentation static method
void
drawYIntervalSegmentation()
Implementation
static void drawYIntervalSegmentation(
Canvas canvas,
List<SectionBeanY> ySectionBeans,
double startX,
double endX,
double startY,
double endY) {
var _fixedHeight = startY - endY;
for (var item in ySectionBeans) {
var tempStartY = endY + (_fixedHeight - _fixedHeight * item.startRatio);
var tempHeight = _fixedHeight * item.widthRatio;
var tempPath = Path()
..moveTo(startX, tempStartY)
..lineTo(endX, tempStartY)
..lineTo(endX, tempStartY - tempHeight)
..lineTo(startX, tempStartY - tempHeight)
..lineTo(startX, tempStartY)
..close();
var tempPaint = Paint()
..isAntiAlias = true
..strokeWidth = 0
..color = item.fillColor!
..style = PaintingStyle.fill;
canvas.drawPath(tempPath, tempPaint);
//边缘线
var borderLinePaint = Paint()
..isAntiAlias = true
..strokeWidth = item.borderWidth ?? 1
..color = item.borderColor ?? Colors.transparent
..style = PaintingStyle.stroke;
var borderLinePath1 = Path()
..moveTo(startX, tempStartY)
..lineTo(endX, tempStartY);
var borderLinePath2 = Path()
..moveTo(startX, tempStartY - tempHeight)
..lineTo(endX, tempStartY - tempHeight);
if (item.isBorderSolid) {
canvas.drawPath(borderLinePath1, borderLinePaint);
canvas.drawPath(borderLinePath2, borderLinePaint);
} else {
canvas.drawPath(
dashPath(
borderLinePath1,
dashArray: CircularIntervalList<double>(<double>[5.0, 4.0]),
),
borderLinePaint,
);
canvas.drawPath(
dashPath(
borderLinePath2,
dashArray: CircularIntervalList<double>(<double>[5.0, 4.0]),
),
borderLinePaint,
);
}
}
}