Files
game-cards-poker-design/frontend/node_modules/fabric/dist-extensions/data_updaters/gradient/index.mjs
Poker Design Developer 5dbcebf7a2 Fix frontend blank page issues
- Fix router import path in main.js
- Handle Django REST Framework pagination format in API calls
- Add getTemplates function to project API
- Restart frontend development server
2026-05-31 18:40:56 +08:00

32 lines
1.0 KiB
JavaScript

import { Color, Gradient } from "fabric";
//#region extensions/data_updaters/gradient/index.ts
const gradientUpdaterWrapper = (originalFn) => async function(serializedGradient) {
const { colorStops } = serializedGradient;
const newColorStops = colorStops === null || colorStops === void 0 ? void 0 : colorStops.map(({ color, opacity, offset }) => {
if (opacity === void 0 || opacity === 1) return {
color,
offset
};
return {
color: new Color(color).setAlpha(opacity).toRgba(),
offset
};
});
return await originalFn.call(this, {
...serializedGradient,
colorStops: newColorStops
});
};
/**
* Wraps and override the current fabricJS fromObject static functions
* Used to upgrade from fabric 7 to fabric 8
* If you used to export with includeDefaultValues = false, you have to specify
* which were yours default origins values
*/
const installGradientUpdater = () => {
Gradient.fromObject = gradientUpdaterWrapper(Gradient.fromObject);
};
//#endregion
export { gradientUpdaterWrapper, installGradientUpdater };
//# sourceMappingURL=index.mjs.map