12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- export const updatePen = (pen: any, prop: string, render = true) => {
- const v: any = { id: pen.id };
- v[prop] = pen[prop];
- if (prop === 'width' && pen.ratio) {
- const rect = meta2d.findOne(pen.id);
- v.height = (pen.width / rect.width) * rect.height;
- pen.height = v.height;
- } else if (prop === 'height' && pen.ratio) {
- const rect = meta2d.findOne(pen.id);
- v.width = (pen.height / rect.height) * rect.width;
- pen.width = v.width;
- } else if (prop === 'shadow') {
- if (v[prop]) {
- !v.shadowOffsetX && (v.shadowOffsetX = 0);
- !v.shadowOffsetY && (v.shadowOffsetY = 0);
- !v.shadowBlur && (v.shadowBlur = 0);
- } else {
- v.shadowColor = '';
- }
- } else if (prop === 'lineGradientColors') {
- //@ts-ignore
- if (meta2d.store.active[0].name === 'line') {
- //@ts-ignore
- meta2d.store.active[0].calculative.gradientColorStop = null;
- } else {
- //@ts-ignore
- meta2d.store.active[0].calculative.lineGradient = null;
- }
- //不同模式切换不同的系统配色
- } else if (prop === 'titleFnJs') {
- v.titleFn = null;
- } else if (prop === 'dash') {
- v.lineDash = lineDashObj[v[prop]];
- } else if (prop === 'whiteSpace') {
- if(!pen.whiteSpace || pen.whiteSpace !== 'break-all') {
- pen.whiteSpace = 'break-all';
- v.whiteSpace = 'break-all';
- } else {
- v.whiteSpace = 'nowrap';
- pen.whiteSpace = 'nowrap';
- }
- }
- meta2d.setValue(v, { render });
- };
- export const lineDashObj = [
- undefined,
- [5, 5],
- [10, 10],
- [10, 10, 2, 10],
- [1, 16],
- ];
|