in src/util/states.ts [223:277]
function createEmphasisDefaultState(
el: Displayable,
stateName: 'emphasis',
targetStates: string[],
state: Displayable['states'][number]
): DisplayableState {
const hasSelect = targetStates && indexOf(targetStates, 'select') >= 0;
let cloned = false;
if (el instanceof Path) {
const store = getSavedStates(el);
const fromFill = hasSelect ? (store.selectFill || store.normalFill) : store.normalFill;
const fromStroke = hasSelect ? (store.selectStroke || store.normalStroke) : store.normalStroke;
if (hasFillOrStroke(fromFill) || hasFillOrStroke(fromStroke)) {
state = state || {};
let emphasisStyle = state.style || {};
// inherit case
if (emphasisStyle.fill === 'inherit') {
cloned = true;
state = extend({}, state);
emphasisStyle = extend({}, emphasisStyle);
emphasisStyle.fill = fromFill;
}
// Apply default color lift
else if (!hasFillOrStroke(emphasisStyle.fill) && hasFillOrStroke(fromFill)) {
cloned = true;
// Not modify the original value.
state = extend({}, state);
emphasisStyle = extend({}, emphasisStyle);
// Already being applied 'emphasis'. DON'T lift color multiple times.
emphasisStyle.fill = liftColor(fromFill as ColorString);
}
// Not highlight stroke if fill has been highlighted.
else if (!hasFillOrStroke(emphasisStyle.stroke) && hasFillOrStroke(fromStroke)) {
if (!cloned) {
state = extend({}, state);
emphasisStyle = extend({}, emphasisStyle);
}
emphasisStyle.stroke = liftColor(fromStroke as ColorString);
}
state.style = emphasisStyle;
}
}
if (state) {
// TODO Share with textContent?
if (state.z2 == null) {
if (!cloned) {
state = extend({}, state);
}
const z2EmphasisLift = (el as ECElement).z2EmphasisLift;
state.z2 = el.z2 + (z2EmphasisLift != null ? z2EmphasisLift : Z2_EMPHASIS_LIFT);
}
}
return state;
}