createStaticDivides static method
创建定宽等分线(start end可以颠倒) 注意只从start开始定宽 Size大小会改变数量,无法使用 PercentGetter 创建,需要在外部根据Size变化每次重新 createStaticDivides
Implementation
static List<NamedLine> createStaticDivides(double staticPercent, {double count = double.infinity,
NamedLine? fromStartLine,
NamedLine? toEndLine,
bool includeStartEnd = false}){
NamedLine fromStart = fromStartLine ?? NamedLine.percent(0.0, name: NAME_START);
NamedLine toEnd = toEndLine ?? NamedLine.percent(1.0, name: NAME_END);
assert(staticPercent >0 && staticPercent <1);
if(fromStart.percent < toEnd.percent){
List<NamedLine> excludeStartEnd;
if(staticPercent + fromStart.percent > toEnd.percent) {
excludeStartEnd = [];
}else{
excludeStartEnd = List.generate(min<double>(((toEnd.percent - fromStart.percent) / staticPercent), count).floor(), (index){
var plusPercent = fromStart.percent + (index + 1) * staticPercent;
return NamedLine.percent(
plusPercent,
name: '$STATIC_DIVIDES-${index+1}:+$staticPercent:$plusPercent',
);
});
}
return includeStartEnd ? [
NamedLine.rename(rename: '$STATIC_DIVIDES-$NAME_START', copy: fromStart),
...excludeStartEnd,
NamedLine.rename(rename: '$STATIC_DIVIDES-$NAME_END', copy: toEnd),
]: excludeStartEnd;
}else{
return createReverseStaticDivides(staticPercent,
count: count, fromEndLine: toEndLine, toStartLine: fromStartLine, includeStartEnd: includeStartEnd);
}
}