- 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
32 lines
1.0 KiB
JavaScript
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
|