You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2024/01/19 02:43:27 UTC
(echarts) 01/01: refactor(util): import `liftColor` function from zrender (ecomfe/zrender#999)
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch import-liftColor-from-zrender
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit a2efa574487a744e546b82fbee9229fc80776043
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Fri Jan 19 10:38:57 2024 +0800
refactor(util): import `liftColor` function from zrender (ecomfe/zrender#999)
---
src/util/states.ts | 32 ++------------------------------
1 file changed, 2 insertions(+), 30 deletions(-)
diff --git a/src/util/states.ts b/src/util/states.ts
index 3a8ad4502..3c8675dd4 100644
--- a/src/util/states.ts
+++ b/src/util/states.ts
@@ -19,7 +19,6 @@
*/
import { Dictionary } from 'zrender/src/core/types';
-import LRU from 'zrender/src/core/LRU';
import Displayable, { DisplayableState } from 'zrender/src/graphic/Displayable';
import { PatternObject } from 'zrender/src/graphic/Pattern';
import { GradientObject } from 'zrender/src/graphic/Gradient';
@@ -45,13 +44,10 @@ import {
isObject,
keys,
isArray,
- each,
- isString,
- isGradientObject,
- map
+ each
} from 'zrender/src/core/util';
import { getECData } from './innerStore';
-import * as colorTool from 'zrender/src/tool/color';
+import { liftColor } from 'zrender/src/tool/color';
import SeriesData from '../data/SeriesData';
import SeriesModel from '../model/Series';
import { CoordinateSystemMaster, CoordinateSystem } from '../coord/CoordinateSystem';
@@ -109,30 +105,6 @@ type ExtendedDisplayable = Displayable & ExtendedProps;
function hasFillOrStroke(fillOrStroke: string | PatternObject | GradientObject) {
return fillOrStroke != null && fillOrStroke !== 'none';
}
-// Most lifted color are duplicated.
-const liftedColorCache = new LRU<string>(100);
-function liftColor(color: GradientObject): GradientObject;
-function liftColor(color: string): string;
-function liftColor(color: string | GradientObject): string | GradientObject {
- if (isString(color)) {
- let liftedColor = liftedColorCache.get(color);
- if (!liftedColor) {
- liftedColor = colorTool.lift(color, -0.1);
- liftedColorCache.put(color, liftedColor);
- }
- return liftedColor;
- }
- else if (isGradientObject(color)) {
- const ret = extend({}, color) as GradientObject;
- ret.colorStops = map(color.colorStops, stop => ({
- offset: stop.offset,
- color: colorTool.lift(stop.color, -0.1)
- }));
- return ret;
- }
- // Change nothing.
- return color;
-}
function doChangeHoverState(el: ECElement, stateName: DisplayState, hoverStateEnum: 0 | 1 | 2) {
if (el.onHoverStateChange && (el.hoverState || 0) !== hoverStateEnum) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org