Skip to content

Commit

Permalink
feat: image blurry with clipPath (sleepy-zone#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-zone committed Apr 2, 2024
1 parent d363dc5 commit d42271e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const HOVER_OBJECT_CONTROL = true;
// Image ClipPath bug?
// https://github.com/fabricjs/fabric.js/issues/5639
// but will cause low performance
export const IMAGE_CLIPPATH_QUALITY = false;
export const IMAGE_CLIPPATH_QUALITY = true;

export const MAX_HISTORY_LENGTH = 100;

Expand Down
3 changes: 2 additions & 1 deletion src/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export default class Editor {
width: workspaceEl.offsetWidth,
height: workspaceEl.offsetHeight,
backgroundColor: '#ddd',
preserveObjectStacking: true
preserveObjectStacking: true,
imageSmoothingEnabled: false
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/editor/objects/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { IMAGE_CLIPPATH_QUALITY } from '@/config';

export const initObjectPrototype = () => {
if (IMAGE_CLIPPATH_QUALITY) {
fabric.Object.prototype.needsItsOwnCache = () => false
fabric.Object.prototype.needsItsOwnCache = () => false;
// @ts-ignore
fabric.perfLimitSizeTotal = 16777216; // allows for up to 4096x4096 cache
}

// Text global config
Expand Down

0 comments on commit d42271e

Please sign in to comment.