createExpressionStaticDivides static method
List<NamedLine>
createExpressionStaticDivides(
- Expression staticExpr,
- double count, {
- (DIRECTION_ENUM, Size)? infinitySample,
- NamedLine? fromStartLine,
- NamedLine? toEndLine,
- END_POINT endPoint = END_POINT.exclude_start_end,
Implementation
static List<NamedLine> createExpressionStaticDivides(Expression staticExpr, double count, {(DIRECTION_ENUM, Size)? infinitySample,
NamedLine? fromStartLine,
NamedLine? toEndLine,
END_POINT endPoint = END_POINT.exclude_start_end}){
assert(count != double.infinity || infinitySample != null);
NamedLine fromStart = fromStartLine ?? NamedLine.percent(0.0, name: NAME_START);
NamedLine toEnd = toEndLine ?? NamedLine.percent(1.0, name: NAME_END);
if(count == double.infinity){
switch(infinitySample!.$1){
case DIRECTION_ENUM.vertical:
count = ((toEnd - fromStart) as Expression).verticalWidthMergeLiteral(PxUnit.wpc)(infinitySample.$2).$1 / staticExpr.verticalWidthMergeLiteral(PxUnit.wpc)(infinitySample.$2).$1;
break;
case DIRECTION_ENUM.horizontal:
count = ((toEnd - fromStart) as Expression).horizontalHeightMergeLiteral(PxUnit.hpc)(infinitySample.$2).$1 / staticExpr.horizontalHeightMergeLiteral(PxUnit.hpc)(infinitySample.$2).$1;
}
}
List<NamedLine> excludeStartEnd = List.generate(count.floor(), (index){
var plusExpr = fromStart + staticExpr * (index + 1);
return NamedLine.expression(plusExpr, name: '$STATIC_DIVIDES-${index+1}');
});
return [
if(endPoint == END_POINT.include_start_only || endPoint == END_POINT.include_start_end)
NamedLine.rename(rename: '$STATIC_DIVIDES-$NAME_START', copy: fromStart),
...excludeStartEnd,
if(endPoint == END_POINT.include_end_only || endPoint == END_POINT.include_start_end)
NamedLine.rename(rename: '$STATIC_DIVIDES-$NAME_END', copy: toEnd),
];
}