createCustomDivides static method
创建自定义线(占首尾线区间比值 < 1)
Implementation
static List<NamedLine> createCustomDivides(List<double> customs, {
NamedLine? fromStartLine,
NamedLine? toEndLine,
END_POINT endPoint = END_POINT.exclude_start_end}){
NamedLine fromStart = fromStartLine ?? NamedLine.percent(0.0, name: NAME_START);
NamedLine toEnd = toEndLine ?? NamedLine.percent(1.0, name: NAME_END);
assert(customs.isNotEmpty && customs.every((custom)=>custom <= 1));
final rangeFromStartToEnd = toEnd - fromStart;
var excludeStartEnd = customs.mapIndexed<NamedLine>((int index, double custom){
final expr = rangeFromStartToEnd * custom;
return NamedLine.expression(expr, name: '$index/$NAME_CUSTOM:$expr');
}).toList();
return [
if(endPoint == END_POINT.include_start_only || endPoint == END_POINT.include_start_end)
NamedLine.rename(rename: '$NAME_CUSTOM-$NAME_START', copy: fromStart),
... excludeStartEnd,
if(endPoint == END_POINT.include_end_only || endPoint == END_POINT.include_start_end)
NamedLine.rename(rename: '$NAME_CUSTOM-$NAME_END', copy: toEnd),
];
}