Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
var res = {
boxes: detectedBoxes,
names: detectedNames,
inferenceTime: endTime - startTime
};
console.log(res);
// create canvas and context
const width=1024
const height=768
const canvas = createCanvas(width, height);
const context = canvas.getContext('2d');
// create image from buffer
const img = new Image()
img.onload = () => {
// draw image in context
context.drawImage(img, 0, 0, width, height);
// draw boxes from model's detection boxes
for (let i = 0; i < res.boxes.length; i++) {
const box = res.boxes[i];
context.fillStyle = 'rgba(255,255,255,0.2';
context.strokeStyle = 'white';
context.fillRect(box[1] * width, box[0] * height, width * (box[3] - box[1]),
height * (box[2] - box[0]));
context.font = '15px Arial';
context.fillStyle = 'white';
context.fillText(res.names[i], box[1] * width, box[0] * height, box[0] * height);
context.lineWidth = 2;
context.strokeRect(box[1] * width, box[0] * height, width * (box[3] - box[1]),
height * (box[2] - box[0]));
const fontScale = 1.2,
canvas = createCanvas(width, height),
ctx = canvas.getContext('2d');
// TODO: 渐变背景
// const grd=cxt.createLinearGradient(0, 0, width, height);
// grd.addColorStop(0, "#FF0000");
if (bgColor) {
ctx.fillStyle = bgColor;
ctx.fillRect(0, 0, width, height);
}
if (bgImage) {
let image = new Image();
if (bgImage.startsWith('http')) {
image = await loadImage(bgImage);
} else if (bgImage.startsWith('data:image/')) image.src = bgImage;
else image.src = await readFile(bgImage);
ctx.drawImage(image, 0, 0, width, height);
}
let fontSize = Number(fontStyle.split(' ')[0].replace('px', ''));
ctx.font = fontStyle;
ctx.fillStyle = fontColor;
if ((fontSize * bookName.length) / height > 0.6) {
ctx.font = fontStyle.replace(`${fontSize}px`, `${fontSize / fontScale}px`);
fontSize /= fontScale;
}
const fontHeight = fontSize + fontSize / 4;
const canvas = createCanvas(imageD, imageD);
const ctx = canvas.getContext('2d');
ctx.quality = 'fast';
ctx.patternQuality = 'fast';
// resize their image so we don't have to do it each time.
const ctxResize = canvas.getContext('2d');
ctxResize.drawImage(theirImage, 0, 0, imageD, imageD);
const buffer = canvas.toBuffer('image/jpeg', undefined);
theirImage.src = Buffer.from(buffer);
// loop over all images.
const length = (images.length > 65) ? 65 : images.length;
for (let i = 0; i < length - 1; i += 1) {
ctx.globalAlpha = 1;
const background = new Image();
background.src = Buffer.from(images[i]);
ctx.drawImage(background, 0, 0, imageD, imageD);
// get buffer and resize our image to our length
ctx.globalAlpha = 0.5;
ctx.drawImage(theirImage, 0, 0, imageD, imageD);
encoder.addFrame(ctx);
}
encoder.finish();
return await myAccumulator.getBuffer();
} catch (error) {
console.error(error);
}
return undefined;
},
var tc = require('../');
var Canvas = require('canvas');
// create terminal <canvas>
var canvas = tc();
var ctx = canvas.getContext('2d');
var screenWidth = canvas.width;
var maxWidth = parseInt(process.argv[3], 10) || screenWidth;
var imageFile = process.argv[2];
var image = require('fs').readFileSync(imageFile);
var img = new Canvas.Image();
img.src = image;
var width = maxWidth;
var scaleW = img.width > width ? width / img.width : 1;
var w = Math.floor(img.width * scaleW);
var h = Math.floor(img.height * scaleW);
ctx.drawImage(img, 0, 0, w, h);
canvas.render();
</canvas>
let COLOR_WALLS = "#2b2e30";
let COLOR_PATH = "white";
const robot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAE7AAABOwBim79cgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAfrSURBVFiFpVdraFTbFf7WmSRmYjTRThInEY3WJEZjMErFBFHESKEWWxQ0BhSVC3rl/ihWLFQjRrFKKxIkPkBaKgoiKGh8gBgU0yAWMZTaWAxJMNHM40xmMo/M65yz1+6P2eMdc6OmuGEzZ87Ze69vrW899iJMfZD6dQBYDmARgEL1PgzgHYB/A3iv1sn/4+yvCv4ZgN8B+CcAEwCrKdTM/P8fAMcBzM0A/cXDvzTyABwCcBDATCICALO0tHS8qqpKFBUVMTNzJBLJ7uvr04aGhuzMbJdSSgAGgCsAWgGMArApgFPWug7Afw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FLTOSMqTsx9e3iyKfynb1SK+RqtEq70RzZPwEGKwv7G0OK1QA42Y+HIgct9P3WWG9ItI/mQTgvoeuWAMdlTRclO/+Km2jwlhDvinGNbyJH6EWV84AJ1wl8JowejqTqTmv+0GqDmVLlg/wLX5Mp2rO3WRs2Zs5fznAVd1EzRh10OONr7hhhM4ctevhiVVxHdYsbq+JzHzaIfdjs5CZ9tGInSfoWEXuL7//fwtn9+Jp7wSryDjBFqnOGeuUxAAAAAElFTkSuQmCC";
const charger = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAdVBMVEUAAAA44Yo44Yo44Yo44Yo44Yo44Yo44Yo44Yp26q844Yr///9767Kv89DG9t2g8Md26q5C44/5/vvz/fjY+ei19NNV5ZtJ45T2/fmY78KP7r1v6atq6Kjs/PPi+u7e+uvM9+Gb8MSS7r+H7bhm6KVh56JZ5p3ZkKITAAAACnRSTlMABTr188xpJ4aepd0A4wAAANZJREFUKM9VklmCgzAMQwkQYCSmLKWl2+zL/Y9YcIUL7wvkJHIUJyKkVcyy+JIGCZILGF//QLEqlTmMdsBEXi56igfH/QVGqvXSu49+1KftCbn+dtxB5LOPfNGQNRaKaQNkTJ46OMGczZg8wJB/9TB+J3nFkyqJMp44vBrnWYhJJmOn/5uVzAotV/zACnbUtTbOpHcQzVx8kxw6mavdpYP90dsNcE5k6xd8RoIb2Xgk6xAbfm5C9NiHtxGiXD/U2P96UJunrS/LOeV2GG4wfBi241P5+NwBnAEUFx9FUdUAAAAASUVORK5CYII=";
const tank = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAzCAYAAAD2OArBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAC9AAAAvQBgK2sVQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAApASURBVFiFpZhLbJzVFcd/3zfffPO0PeNx/Irj2AHyoiHEJUEQEqJCIa1aaLtBgkZtxaKVWHRH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VB8rYDGePPckLakToFMR4vfl66pgw5T+MVxxmz549WwYAlpaWthzwPK+jf/7qm+hTZQbiMBRrPUhs6k8uwPpFzipAJL6Hn7oWL9htoXdd8EJABVQ3gG14BOIBapkagUAAAMMwCIfDmKaJ53kEAgFqNek3nRpaUHilm34BPIuztSI//y936+fVngzyYwAAAABJRU5ErkJggg=="
const spaceship = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAFMklEQVRYR+2YfUxVZRjAf+cAfiAOHZaIFxXD0g2V3LVipZFuOrRcm6KBHw0b/GHERpFGfoQokcV0M6x5mbiKyFK31NRls666RmUrP0gtUVQU8IP8AEGBe297zznXe+71fsBB+4v3D8Z97/M85/c+X+9zj8SDW7eBUJ25XsDdrpqXumpAp29jSoZMTDxsXCS2+wJNXbX/YAFTVsqMeg5WTO4GNBIZG90eNOI3l063B434zwK8oCnGkrISXRWfARzAT0CGEeNCp6ttppHIYWFExYIkQc4mCOsHeclw6wY01MC/taIXip5oaHUdMPmtMBa85/7w+jq4egX2bQRrWTegv9A00u1BQ6l7T6nbgx2tYiGXCsia7yqAKqAzHowFEjR9O1Cu9Um/Mewo4ETgQJAsYXc4cDi4CER3ErBGkjDJkoTNLvo3zwMHA2VYRwGFMaujLonk9D/Z9l29IcBZL0aatpY8iTRor+BKFId+oIDj48Opqm7m+s02Q4D9w0NMsTGhHD5y8+EAYhoJDZegpdEQIL37mogYDBdPPSTA9w9B+XKotBoDjEs0kboK3p3QacBSYIEuHyZ5JLCSg/gDnPkotLeqJuRgyN/veRfX4B9QFOKPOobPgYXOIjk8tFc/85LoZ8ms2iMqdSGwWSfsH3D+CpgRzkcrRioqb+efgoKD8INFPywEAkyTJam0OHYaa2p+5vydG78D4+8BxodFmnePnsuQX9Zhc9gDAV4CHgOuKXexBlhVIc4BsQkHPAEHAGeISxzsJ8RpQZJceuGZbKYf/5IjTfXugIBZ5zHvgJZTsHkJVOxwic5dCnMWKx50A7SchN2fwo71Ltn4qTB7ma8cTANEqjmXB2DUE2bS18OqaWC3eQfcdUtVbm50mQnti+jc9wHuvKkOsXrZM2dVPe9FkoYcVMryPVCSBbV/ewCaRppZVALLEvWAInHF64zRwIc4AZ14l8/DpdMqYN5MNq0TYvBa9nHI264CDh4BA4eqGseP6gEXix1xXK0gVcDVVvgkXbSigIBlQKvyELFCesL2K7oIALOjoKVJERGM92QdDtde7zD4plbVa9Ve1aREu/5XfrbQA5hnDHBLDfQJdwdzfkoeRG56JAW5jyNH7QWL5qGMsdhrk1ha+A+FJfWwtc5d32aDE5VwpwnykwwBVgLi2FMIADh8oIMRMaF8b73mBjg1cQCnq5s5e1nqCOA+IAo5KM53iEeMM7PWCgWpcP6EeuLgECj+FWTnlOXhyOIsOKYNJELmYzGFAW8kgF1MVMCYiZCpq2S9CSGT+TS0t6m7EdGQutpHDjoBvQfz/9mtOg0tzT4AJcmseEy/JBm+vgjBIoe9rJxJcPaY9oUEX4gZFpgvZlMl+WH4GCjS32CauMhD4bnUIeDQvK1UGtDeLvTdqljcCi97IAQBawLl4ISeA5jcP4a8c1a3HMwblsj+69UcunutIzm4BLB5PP9bcfv4G1iFO1spP+e7iueYyIqII3fIBAZVFLkB1iXkUHjhEOsbKtUo6JdSxX+pVbx6uvhGhEhLRI8g+kmuYF9KPnWKtILJEf29U0s4Q8T1vhVo5I8QLdpDyxLZI+yl/WNf5ak/LNy2tYkS/UBpSzlbVNGiV8TfKOCdPkEhWb+Ny2Dy0c+ob23a5eVFkvBcg6/jBAL0prf1kZA+s8pHzWRG5Ve02NsKgaWAnXkFqnyZ+Kj8AizoLYfk7oxLIfXkdq623d4GJHfGt0YA1wLZuodkAhsUQNfbMlGOAvB1oFgnuw54szOA/wGAoJRHR2vq3wAAAABJRU5ErkJggg==";
var canvasimg = new Canvas();
//var ctximg = canvasimg.getContext('2d');
var img = new Image(); // Create a new Image
img.src = robot1;
const img_charger = new Image();
img_charger.src = charger;
const MapCreator = function () {};
MapCreator.CanvasMap = function (Mapdata, options) {
let that = this;
if(options){
COLOR_FLOOR = options.FLOORCOLOR;
COLOR_WALLS = options.WALLCOLOR;
COLOR_PATH = options.PATHCOLOR;
if(options.ROBOT=== 'robot'){
img.src = robot
}
drawProfileImage() {
const text20 = '20';
const text18 = '18';
const startAngle = 0;
const endAngle = Math.PI * 2;
const circleRadius = this.relativeCircleSize(0.17);
const imageSize = circleRadius * 2;
const halfImageSize = imageSize / 2;
const x = this.relativeX(0.50, this.widthLeftPane);
const y = this.relativeY(0.28);
const textY = this.relativeY(0.295);
const ctx = this.ctx;
// Draw avatar inside circle
const img = new Image();
img.src = this.avatarData;
ctx.save();
ctx.beginPath();
ctx.arc(
x,
y,
circleRadius,
startAngle,
endAngle,
true
);
ctx.clip();
ctx.drawImage(
img,
x - halfImageSize,
parseImage(data, cb) {
let Canvas = require('canvas');
let img = new Canvas.Image();
img.src = data;
let buf = img.rawData;
cb(null, {source: buf, w: img.width, h: img.height, premultiplyAlpha: false, flipBlueRed: true});
}
drawRightPane() {
const ctx = this.ctx;
const rightGradient = ctx.createLinearGradient(this.widthLeftPane, 0, this.widthLeftPane, this.height);
rightGradient.addColorStop(0, 'rgba(23, 218, 214, 0.75)');
rightGradient.addColorStop(0.5, 'rgba(33, 136, 179, 0.75)');
rightGradient.addColorStop(1, 'rgba(43, 56, 144, 0.75)');
const picture = new Image(this.width, this.height);
picture.src = this.avatarData;
const imageCanvas = createCanvas(this.width, this.height);
const ictx = imageCanvas.getContext('2d');
ictx.drawImage(picture, this.width * 0.3, 0, this.width, this.height);
StackBlur.canvasRGB(imageCanvas, 0, 0, this.width, this.height, 20);
ctx.drawImage(imageCanvas, 0, 0, this.width, this.height);
ctx.fillStyle = rightGradient;
ctx.fillRect(this.widthLeftPane, 0, this.widthRightPane, this.canvas.height);
}
rectangles.forEach(function(rect){
var image = new (Canvas.Image)();
image.src = rect.name;
ctx.drawImage(image, rect.x, rect.y);
});
function loadImage(imageFilename) {
let img = new Canvas.Image();
img.src = imageFilename;
const canvas = new Canvas();
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, img.width, img.height);
return ctx;
}