Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]feat: remove the logic of calculating fill color based on stroke colo… #875

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions packages/vrender-components/src/label/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,27 +922,29 @@ export class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
continue;
}

/** 当label设置stroke时,保留stroke设置的颜色,根据stroke对fill做反色 */
if (label.attribute.stroke) {
label.setAttributes({
fill: labelSmartInvert(
label.attribute.fill as IColor,
label.attribute.stroke as IColor,
textType,
contrastRatiosThreshold,
alternativeColors,
mode
)
});
const hasIntersect = label.AABBBounds.intersects(baseMark.AABBBounds);

if (!hasIntersect) {
/** 当 label 与图元完全没有交集的时候,不进行任何反色计算 */
continue;
}

/** 当label未设置stroke,且可设置stroke时,正常计算 */
const fill = smartInvertStrategy(fillStrategy, baseColor, invertColor, similarColor);
fill && label.setAttributes({ fill });

const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
stroke && label.setAttributes({ stroke });
const hasStrokeConfig = isString(label.attribute.stroke);

if (hasStrokeConfig) {
const accessible = contrastAccessibilityChecker(label.attribute.stroke as IColor, fill);
if (!accessible) {
const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
stroke && label.setAttributes({ stroke });
}
} else {
const stroke = smartInvertStrategy(strokeStrategy, baseColor, invertColor, similarColor);
stroke && label.setAttributes({ stroke });
}
}
}
}
Expand Down
Loading