-
-
Save vegeta897/717d589041ac4179fe6e4c74d3660ff9 to your computer and use it in GitHub Desktop.
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
blot: function(options) { | |
var x = options.x || 0, y = options.y || 0; | |
var metrics = options.metrics || this.calculateMetrics(options); | |
var lineStart = options.lineStart ? options.lineStart : 0; | |
var lineCount = options.lineCount ? Math.min(metrics.lines.length, options.lineCount) | |
: metrics.lines.length; | |
var canvas = options.canvas || new BetterCanvas( | |
padding.x * 2 + x + metrics.w - 1, | |
padding.y * 2 + y + lineCount * 10 | |
); | |
if(options.bg) canvas.fill(options.bg); | |
var charCount = 0; | |
for(var l = lineStart; l < Math.min(metrics.lines.length, lineStart + lineCount); l++) { | |
var maxChars = metrics.lines[l].chars.length; | |
if(options.maxChars) maxChars = Math.min(maxChars,options.maxChars - charCount); | |
for(var c = 0; c < maxChars; c++) { | |
var char = metrics.lines[l].chars[c]; | |
if(char.char.text == ' ') continue; | |
canvas.drawImage(image, char.char.x, char.char.y, char.w, char.char.h, | |
padding.x + x + char.x, padding.y + y + (l - lineStart) * 10 + (char.oy || 0) + vertOffset, | |
char.w, char.char.h); | |
} | |
charCount += metrics.lines[l].chars.length; | |
} | |
return canvas.canvas; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment