我在http请求中有一个变量值
registerFont('path-to-font-file', {family: 'CustomFont'});
const canvas = createCanvas(600, 600);
const paperCanvas = createCanvas(600, 600);
const ctx = canvas.getContext('2d');
ctx.font = "normal 30px CustomFont";
ctx.fillText("Hello World", 10, 50);
// using paperjs
const paper = require("paper");
const project = new paper.Project(paperCanvas);
var text = new paper.PointText();
text.fillColor = 'white';
text.content = 'HELLO';
text.fontSize = '60';
text.fontFamily = 'CustomFont';
text.strokeWidth = 0;
text.strokeColor = 'blue';
text.position = project.view.center;
text.selected = true;
project.activeLayer.addChild(text);
project.view.draw();
// return canvas.toDataURL(); this canvas renders font correctly.
return project.view.element.toDataURL(); // paper does not use registered font
数字3是可变值。
如何将PaperJS
插入local data = http.request('http://ip:port/json.htm?type=devices&rid=3')
number
答案 0 :(得分:2)
您可以使用concatenation operator '..':
local data = http.request('http://ip:port/json.htm?type=devices&rid=' .. number)
local data = http.request(string.format('http://ip:port/json.htm?type=devices&rid=%d', number))