module.exports = vectorizeText
module.exports.processPixels = processPixels
var surfaceNets = require('surface-nets')
var ndarray = require('ndarray')
var simplify = require('simplify-planar-graph')
var cleanPSLG = require('clean-pslg')
var cdt2d = require('cdt2d')
var toPolygonCrappy = require('planar-graph-to-polyline')
var TAG_bold = "b"
var CHR_bold = 'b|'
var TAG_italic = "i"
var CHR_italic = 'i|'
var TAG_super = "sup"
var CHR_super0 = '+'
var CHR_super = '+1'
var TAG_sub = "sub"
var CHR_sub0 = '-'
var CHR_sub = '-1'
function parseTag(tag, TAG_CHR, str, map) {
var opnTag = "<" + tag + ">"
var clsTag = "</" + tag + ">"
var nOPN = opnTag.length
var nCLS = clsTag.length
var isRecursive = (TAG_CHR[0] === CHR_super0) ||
(TAG_CHR[0] === CHR_sub0);
var a = 0
var b = -nCLS
while (a > -1) {
a = str.indexOf(opnTag, a)
if(a === -1) break
b = str.indexOf(clsTag, a + nOPN)
if(b === -1) break
if(b <= a) break
for(var i = a; i < b + nCLS; ++i){
if((i < a + nOPN) || (i >= b)) {
map[i] = null
str = str.substr(0, i) + " " + str.substr(i + 1)
} else {
if(map[i] !== null) {
var pos = map[i].indexOf(TAG_CHR[0])
if(pos === -1) {
map[i] += TAG_CHR
} else { // i.e. to handle multiple sub/super-scripts
if(isRecursive) {
// i.e to increase the sub/sup number
map[i] = map[i].substr(0, pos + 1) + (1 + parseInt(map[i][pos + 1])) + map[i].substr(pos + 2)
}
}
}
}
}
var start = a + nOPN
var remainingStr = str.substr(start, b - start)
var c = remainingStr.indexOf(opnTag)
if(c !== -1) a = c
else a = b + nCLS
}
return map
}
function transformPositions(positions, options, size) {
var align = options.textAlign || "start"
var baseline = options.textBaseline || "alphabetic"
var lo = [1<<30, 1<<30]
var hi = [0,0]
var n =...
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.