//Because it's just fine to spend 12K worth of data tin include a sexy vector font that I designed in abouyt an hour and a half NPos2d.Geom.font = { "!":{"points":[[1,0],[1,2],[1,3],[1,4]],"lines":[[0,1],[2,3]]}, "\"":{"points":[[1,1],[1,0],[0,0],[0,1]],"lines":[[0,1],[2,3]]}, "#":{"points":[[2,4],[1,4],[0,3],[0,1],[1,0],[2,0],[2,1],[2,3]],"lines":[[0,5],[1,4],[2,7],[3,6]]}, "$":{"points":[[1,0],[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,1],[0,3],[0,4],[1,2],[1,5],[3,5]]}, "%":{"points":[[0,4],[2,0],[1,4],[2,3],[1,3],[0,1],[1,0],[1,1]],"lines":[[0,1],[2,3],[2,4],[3,4],[5,7],[5,6],[6,7]]}, "&":{"points":[[2,4],[2,1],[0,1],[1,0],[1,2],[2,3],[0,3],[1,4]],"lines":[[0,2],[1,3],[2,3],[4,6],[5,7],[6,7]]}, "'":{"points":[[1,1],[1,0]],"lines":[[0,1]]}, "(":{"points":[[2,0],[2,4],[1,3],[1,1]],"lines":[[0,3],[1,2],[2,3]]}, ")":{"points":[[1,1],[1,3],[0,4],[0,0]],"lines":[[0,1],[0,3],[1,2]]}, "*":{"points":[[1,3],[1,1],[0,2],[2,2],[0,3],[2,3],[0,1],[2,1]],"lines":[[0,1],[2,3],[4,7],[5,6]]}, "+":{"points":[[2,2],[0,2],[1,1],[1,3]],"lines":[[0,1],[2,3]]}, ",":{"points":[[0,4],[1,3]],"lines":[[0,1]]}, "-":{"points":[[2,2],[0,2]],"lines":[[0,1]]}, ".":{"points":[[1,4],[1,3],[0,4]],"lines":[[0,2],[0,1],[1,2]]}, "/":{"points":[[2,1],[0,3]],"lines":[[0,1]]}, "0":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,4],[0,1],[1,3],[1,5],[2,3],[2,5],[3,4]]}, "1":{"points":[[0,1],[0,4],[2,4],[1,0],[1,4]],"lines":[[0,3],[1,2],[3,4]]}, "2":{"points":[[0,4],[2,1],[1,0],[2,4],[0,1]],"lines":[[0,3],[0,1],[1,2],[2,4]]}, "3":{"points":[[1,4],[1,0],[0,1],[0,3],[1,2],[2,1],[2,3]],"lines":[[0,3],[0,6],[1,2],[1,5],[4,5],[4,6]]}, "4":{"points":[[0,0],[2,0],[2,4],[0,2],[2,2]],"lines":[[0,3],[1,2],[3,4]]}, "5":{"points":[[2,3],[1,2],[0,2],[0,4],[2,0],[1,4],[0,0]],"lines":[[0,5],[0,1],[1,2],[2,6],[3,5],[4,6]]}, "6":{"points":[[1,0],[0,1],[2,3],[1,4],[0,3],[1,2]],"lines":[[0,1],[1,4],[2,5],[2,3],[3,4],[4,5]]}, "7":{"points":[[1,4],[2,0],[0,0]],"lines":[[0,1],[1,2]]}, "8":{"points":[[1,2],[1,4],[1,0],[0,1],[0,3],[2,1],[2,3]],"lines":[[0,6],[0,5],[0,3],[0,4],[1,4],[1,6],[2,3],[2,5]]}, "9":{"points":[[1,2],[2,1],[1,0],[0,1],[2,3],[1,4]],"lines":[[0,1],[0,3],[1,2],[1,4],[2,3],[4,5]]}, ":":{"points":[[1,0],[1,1],[1,4],[1,3]],"lines":[[0,1],[2,3]]}, ";":{"points":[[1,3],[0,4],[1,1],[1,0]],"lines":[[0,1],[2,3]]}, "<":{"points":[[2,0],[2,4],[0,2]],"lines":[[0,2],[1,2]]}, "=":{"points":[[2,1],[0,1],[2,3],[0,3]],"lines":[[0,1],[2,3]]}, ">":{"points":[[2,2],[0,0],[0,4]],"lines":[[0,1],[0,2]]}, "?":{"points":[[1,2],[2,1],[0,1],[1,0],[1,4],[1,3]],"lines":[[0,1],[1,3],[2,3],[4,5]]}, "@":{"points":[[2,1],[0,1],[1,0],[0,3],[1,4],[1,2],[1,3],[2,2],[2,3]],"lines":[[0,2],[1,2],[1,3],[3,4],[4,8],[5,7],[5,6],[6,7],[7,8]]}, "A":{"points":[[2,4],[1,0],[0,2],[0,4],[2,2]],"lines":[[0,4],[1,2],[1,4],[2,4],[2,3]]}, "B":{"points":[[2,3],[2,1],[1,2],[0,4],[0,0],[1,0],[1,4]],"lines":[[0,2],[0,6],[1,2],[1,5],[3,4],[3,6],[4,5]]}, "C":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,4],[1,5],[2,3],[2,5],[3,4]]}, "D":{"points":[[1,4],[1,0],[0,4],[0,0],[2,1],[2,3]],"lines":[[0,2],[0,5],[1,3],[1,4],[2,3],[4,5]]}, "E":{"points":[[2,4],[2,0],[2,2],[0,4],[0,0],[0,2]],"lines":[[0,3],[1,4],[2,5],[3,4]]}, "F":{"points":[[0,0],[0,4],[2,2],[2,0],[0,2]],"lines":[[0,3],[0,1],[2,4]]}, "G":{"points":[[1,2],[2,2],[2,1],[2,3],[1,0],[1,4],[0,3],[0,1]],"lines":[[0,1],[1,3],[2,4],[3,5],[4,7],[5,6],[6,7]]}, "H":{"points":[[2,4],[2,0],[0,4],[0,0],[0,2],[2,2]],"lines":[[0,1],[2,3],[4,5]]}, "I":{"points":[[0,4],[2,4],[0,0],[2,0],[1,0],[1,4]],"lines":[[0,1],[2,3],[4,5]]}, "J":{"points":[[2,0],[2,3],[1,4],[0,3]],"lines":[[0,1],[1,2],[2,3]]}, "K":{"points":[[0,0],[0,4],[2,0],[2,4],[0,2]],"lines":[[0,1],[2,4],[3,4]]}, "L":{"points":[[0,0],[2,4],[0,4]],"lines":[[0,2],[1,2]]}, "M":{"points":[[2,4],[0,4],[1,2],[0,0],[2,0]],"lines":[[0,4],[1,3],[2,3],[2,4]]}, "N":{"points":[[2,0],[2,4],[0,0],[0,4]],"lines":[[0,1],[1,2],[2,3]]}, "O":{"points":[[1,0],[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[2,3],[4,5]]}, "P":{"points":[[1,0],[0,0],[0,4],[1,2],[2,1],[0,2]],"lines":[[0,1],[0,4],[1,2],[3,4],[3,5]]}, "Q":{"points":[[2,4],[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,5],[1,5],[1,2],[2,6],[3,4],[3,6],[4,5]]}, "R":{"points":[[2,4],[2,1],[1,2],[0,4],[0,0],[1,0],[0,2]],"lines":[[0,2],[1,2],[1,5],[2,6],[3,4],[4,5]]}, "S":{"points":[[2,3],[2,1],[0,1],[0,3],[1,4],[1,0]],"lines":[[0,2],[0,4],[1,5],[2,5],[3,4]]}, "T":{"points":[[1,4],[2,0],[0,0],[1,0]],"lines":[[0,3],[1,2]]}, "U":{"points":[[2,3],[2,0],[0,0],[0,3],[1,4]],"lines":[[0,4],[0,1],[2,3],[3,4]]}, "V":{"points":[[1,4],[0,1],[0,0],[2,0],[2,1]],"lines":[[0,1],[0,4],[1,2],[3,4]]}, "W":{"points":[[0,4],[2,4],[1,2],[2,0],[0,0]],"lines":[[0,2],[0,4],[1,2],[1,3]]}, "X":{"points":[[2,0],[0,0],[2,4],[0,4]],"lines":[[0,3],[1,2]]}, "Y":{"points":[[1,4],[1,2],[0,0],[2,0]],"lines":[[0,1],[1,2],[1,3]]}, "Z":{"points":[[0,0],[2,4],[2,0],[0,4]],"lines":[[0,2],[1,3],[2,3]]}, "[":{"points":[[1,0],[1,4],[2,4],[2,0]],"lines":[[0,1],[0,3],[1,2]]}, "\\":{"points":[[2,3],[0,1]],"lines":[[0,1]]}, "]":{"points":[[0,0],[0,4],[1,4],[1,0]],"lines":[[0,3],[1,2],[2,3]]}, "^":{"points":[[0,1],[2,1],[1,0]],"lines":[[0,2],[1,2]]}, "_":{"points":[[0,4],[2,4]],"lines":[[0,1]]}, "`":{"points":[[0,0],[1,1]],"lines":[[0,1]]}, "a":{"points":[[2,4],[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,1],[1,2],[1,5],[2,6],[3,4],[3,6],[4,5]]}, "b":{"points":[[1,4],[0,0],[0,4],[1,2],[2,3],[0,2]],"lines":[[0,2],[0,4],[1,2],[3,4],[3,5]]}, "c":{"points":[[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[2,3]]}, "d":{"points":[[0,3],[1,2],[2,4],[2,0],[1,4],[2,2]],"lines":[[0,1],[0,4],[1,5],[2,4],[2,3]]}, "e":{"points":[[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,4],[1,2],[1,5],[2,3],[2,5],[3,4]]}, "f":{"points":[[2,2],[1,1],[1,3],[0,4],[0,2],[0,3]],"lines":[[0,1],[1,4],[2,5],[3,4]]}, "g":{"points":[[0,5],[1,6],[2,5],[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,1],[1,2],[2,7],[3,6],[3,7],[4,5],[4,8],[5,6]]}, "h":{"points":[[2,4],[0,0],[0,4],[1,2],[2,3],[0,2]],"lines":[[0,4],[1,2],[3,4],[3,5]]}, "i":{"points":[[1,1],[1,0],[1,2],[2,4],[0,4],[1,4]],"lines":[[0,1],[2,5],[3,4]]}, "j":{"points":[[1,2],[1,6],[0,5],[2,5],[2,2]],"lines":[[0,4],[1,3],[1,2],[3,4]]}, "k":{"points":[[2,4],[0,4],[0,0],[2,3],[2,1],[1,2],[0,2]],"lines":[[0,3],[1,2],[3,5],[4,5],[5,6]]}, "l":{"points":[[0,2],[2,4],[0,0]],"lines":[[0,1],[0,2]]}, "m":{"points":[[0,4],[2,1],[1,1],[1,2],[2,4],[0,1],[0,2]],"lines":[[0,5],[1,3],[1,4],[2,3],[2,6]]}, "n":{"points":[[2,4],[0,4],[1,1],[2,2],[0,2],[0,1]],"lines":[[0,3],[1,4],[2,3],[2,4],[4,5]]}, "o":{"points":[[2,3],[2,2],[0,2],[0,3],[1,4],[1,1]],"lines":[[0,4],[0,1],[1,5],[2,3],[2,5],[3,4]]}, "p":{"points":[[2,3],[1,4],[0,6],[0,2],[1,2],[0,4]],"lines":[[0,1],[0,4],[1,5],[2,3],[3,4]]}, "q":{"points":[[1,2],[2,2],[2,6],[1,4],[0,3],[2,4]],"lines":[[0,1],[0,4],[1,2],[3,4],[3,5]]}, "r":{"points":[[0,4],[0,1],[1,1],[2,2],[0,2]],"lines":[[0,1],[2,3],[2,4]]}, "s":{"points":[[1,1],[1,4],[0,3],[0,2],[2,2],[2,3]],"lines":[[0,3],[0,4],[1,2],[1,5],[3,5]]}, "t":{"points":[[1,1],[0,2],[2,2],[1,4]],"lines":[[0,3],[1,2]]}, "u":{"points":[[1,4],[0,3],[0,1],[2,1],[2,3]],"lines":[[0,1],[0,4],[1,2],[3,4]]}, "v":{"points":[[2,1],[0,1],[1,4]],"lines":[[0,2],[1,2]]}, "w":{"points":[[2,1],[2,3],[0,1],[1,3],[0,4],[1,4]],"lines":[[0,1],[1,5],[2,4],[3,4],[3,5]]}, "x":{"points":[[2,1],[0,1],[1,2],[0,4],[2,4],[1,3]],"lines":[[0,2],[1,2],[2,5],[3,5],[4,5]]}, "y":{"points":[[2,1],[0,1],[1,2],[1,4]],"lines":[[0,2],[1,2],[2,3]]}, "z":{"points":[[0,4],[2,1],[2,4],[0,1]],"lines":[[0,1],[0,2],[1,3]]}, "{":{"points":[[1,1],[1,3],[0,2],[2,0],[2,4],[1,4],[1,0]],"lines":[[0,2],[0,6],[1,2],[1,5],[3,6],[4,5]]}, "|":{"points":[[1,0],[1,4]],"lines":[[0,1]]}, "}":{"points":[[1,1],[1,3],[2,2],[1,0],[1,4],[0,4],[0,0]],"lines":[[0,2],[0,3],[1,2],[1,4],[3,6],[4,5]]}, "~":{"points":[[1,1],[1,3],[2,2],[0,2]],"lines":[[0,1],[0,3],[1,2]]} }; //VectorText generation! Weeeeeeeeeeeee!!! NPos2d.VText = function(args){ var t = this; if(t === window){throw('JIM TYPE ERROR');} var args = args || {}; NPos2d.blessWith2DBase(t,args); t.string = args.string || 'NEED INPUT'; t.textAlign = args.textAlign || 'left'; t.characterWidth = 2; //This is set static because of the design of the font. t.characterHeight = 4; //This is set static because of the design of the font. t.characterHeightOffset = 2; //This is set static because of the design of the font. t.letterSpacing = args.letterSpacing || 1; t.lineHeight = args.lineHeight || 6; t.color = args.color || '#fff'; //Color is allowed in this ob type because text geom is autogen t.stringCached = false; t.font = args.font || NPos2d.Geom.font; t.cacheTextGeom(); } NPos2d.VText.prototype = { getStateString:function(){ var t = this; return (t.string + t.textAlign + t.characterWidth + t.letterSpacing + t.lineHeight).toString(); }, cacheTextGeom:function(){ var t = this; //this line is -important-: if any text property changes, new point caches won't be updated without scaling or rotating the object. t.lastRotString = false; t.shape = { color: t.color, points:[], lines:[] }; var offsetPointCount = 0; var textAlignTypes = { left:{ charOffset:function(){ return 0; }, spacingOffset: 0 }, right:{ charOffset:function(num){ return -num; }, spacingOffset: t.letterSpacing }, center:{ charOffset:function(num){ //Plus 2 because each character is 2 wide. return -(num / 2); }, spacingOffset: t.letterSpacing /2 } }; if(textAlignTypes.hasOwnProperty(t.textAlign)){ var offsetSpacing = textAlignTypes[t.textAlign].spacingOffset; var linesOText = t.string.split("\n"); for(var lineNum = 0; lineNum < linesOText.length; lineNum += 1){ var thisLine = linesOText[lineNum]; var charCount = thisLine.length; var offsetCharCount = textAlignTypes[t.textAlign].charOffset(charCount); for(var charNum = 0; charNum < charCount; charNum += 1){ var thisChar = thisLine[charNum]; //console.log(t.string[i]); if(thisChar === ' '){ //This is a space character. //I need to bump over the text by one char, //but I don't need to add any geom. }else if(thisChar === '\t'){ //This is a tab character. //I need to bump over the text by TWO chars, //but I don't need to add any geom. offsetCharCount += 1; }else if(t.font.hasOwnProperty(thisChar)){ var letter = t.font[thisChar]; for(var p = 0; p < letter.points.length; p += 1){ t.shape.points.push([ letter.points[p][0] + ((t.characterWidth + t.letterSpacing) * offsetCharCount) + offsetSpacing, letter.points[p][1] + (t.lineHeight * lineNum) - t.characterHeightOffset ]); } for(var l = 0; l < letter.lines.length; l += 1){ var line = letter.lines[l]; t.shape.lines.push([line[0] + offsetPointCount, line[1] + offsetPointCount]); } //console.log('#char',thisChar,'#points',t.shape.points,'#lines',t.shape.lines); offsetPointCount = t.shape.points.length; }else{ throw('This font does not contain the character "' + ch + '"'); } offsetCharCount += 1; } offsetCharCount = 0; } }else{ throw('You passed an unsupported textAlign type named "' + t.textAlign + '"'); } t.stringCached = t.getStateString(); }, update:function(s){ var t = this; if(t.getStateString() !== t.stringCached){ t.cacheTextGeom(); } t.shape.color = t.color; t.render(); }, destroy:NPos2d.destroyFunc };