-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
515 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 11 additions & 31 deletions
42
.codesandbox/templates/vanilla/src/testcases/simpleTextbox.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,20 @@ | ||
import * as fabric from 'fabric'; | ||
|
||
export function testCase(canvas: fabric.Canvas) { | ||
const textValue = 'fabric.js sandbox'; | ||
const text = new fabric.Textbox(textValue, { | ||
originX: 'center', | ||
splitByGrapheme: true, | ||
const textValue = 'LOL'; | ||
const path = new fabric.Path( | ||
'M0 200 v-200 h200 a100,100 90 0,1 0,200 a100,100 90 0,1 -200,0 z', | ||
{ | ||
fill: '', | ||
stroke: 'red', | ||
}, | ||
); | ||
const text = new fabric.IText(textValue, { | ||
width: 200, | ||
top: 20, | ||
styles: fabric.util.stylesFromArray( | ||
[ | ||
{ | ||
style: { | ||
fontWeight: 'bold', | ||
fontSize: 64, | ||
}, | ||
start: 0, | ||
end: 9, | ||
}, | ||
], | ||
textValue, | ||
), | ||
path, | ||
objectCaching: false, | ||
}); | ||
canvas.add(text); | ||
canvas.centerObjectH(text); | ||
function animate(toState) { | ||
text.animate( | ||
{ scaleX: Math.max(toState, 0.1) * 2 }, | ||
{ | ||
onChange: () => canvas.renderAll(), | ||
onComplete: () => animate(!toState), | ||
duration: 1000, | ||
easing: toState | ||
? fabric.util.ease.easeInOutQuad | ||
: fabric.util.ease.easeInOutSine, | ||
}, | ||
); | ||
} | ||
// animate(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.