Commit f58cb30f authored by Luc Didry's avatar Luc Didry
Browse files

Handle 'text' argument (for mattermost)

parent 52180304
Pipeline #23886 passed with stage
in 16 seconds
sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential
......@@ -20,6 +20,10 @@ const requestHandler = (request, response) => {
var py = (queryData.py !== undefined) ? queryData.py : '350';
var ps = (queryData.ps !== undefined) ? queryData.ps : '220';
if (queryData.text !== undefined) {
p = queryData.text;
}
ctx.fillStyle = 'rgba(252, 210, 5, 1)';
roundRect(ctx, 0, 0, 800, 400, 20, true, false);
......@@ -34,11 +38,9 @@ const requestHandler = (request, response) => {
ctx.fillStyle = 'rgba(0, 0, 0, 1)';
var i = 0;
console.log('w: '+ctx.measureText(w).width);
while (ctx.measureText(w).width > 725) {
ctx.font = 'bold '+(parseInt(ws) - i++)+'px sans-serif';
}
console.log('w: '+ctx.measureText(w).width);
ctx.fillText(w, parseInt(wx), parseInt(wy));
// Write new value
......@@ -46,11 +48,9 @@ const requestHandler = (request, response) => {
ctx.fillStyle = 'rgba(0, 0, 0, 1)';
i = 0;
console.log('p: '+ctx.measureText(p).width);
while (ctx.measureText(p).width > 725) {
ctx.font = 'bold '+(parseInt(ps) - i++)+'px sans-serif';
}
console.log('p: '+ctx.measureText(p).width);
ctx.fillText(p, parseInt(px), parseInt(py));
var data = canvas.toDataURL().replace('data:image/png;base64,','');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment