-
-
Save psbolden/b8695677de6337023fa6b839d4bc98de to your computer and use it in GitHub Desktop.
fabric.js set text
This file contains hidden or 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
<canvas id="c" width="400" height="200"></canvas> |
This file contains hidden or 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
var canvas = new fabric.Canvas('c'); | |
var Bar = new fabric.Text('Bar', {selectable: false, top: 50, left: 10}); | |
var rect = new fabric.Rect({width: 100, height: 100, left: 100, top: 100, fill: 'red'}); | |
var group = new fabric.Group([rect, Bar], {selectable: true, top: 50, left: 100}); | |
canvas.add(group); | |
canvas.renderAll(); | |
Bar.setText("my_text"); | |
canvas.renderAll(); | |
or | |
$(document).click(function(e) { | |
Bar.setText('selected'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment