const parameters = {
width: 800,
height: 200
}
let reference = document.getElementById('canvas')
let canvas = new fabric.Canvas(reference, {
selection: false,
preserveObjectStacking: true
})
canvas.setWidth(parameters.width)
canvas.setHeight(parameters.height)
let pathForText = new fabric.Path(`M 0 0 Q 390 200 780 0`, {
left: 10,
top: 50,
fill: '',
stroke: 'red',
strokeWidth: 1
})
canvas.add(pathForText)
let text = new fabric.Text('Here is some text on a path, and I hope you find it useful!', {
fill: 'red',
fontFamily: 'Verdana',
fontSize: 26,
left: pathForText.left,
path: pathForText,
textAlign: 'center', // While this doesn't work with text on a path, `text-anchor="middle" startOffset="50%"` would accomplish the same in SVG.
top: pathForText.top,
width: parameters.width
})
canvas.add(text)
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.