Socket
Socket
Sign inDemoInstall

@canvacord/beta

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@canvacord/beta - npm Package Compare versions

Comparing version 6.0.0-dev-2 to 6.0.0-dev-3

lib/builder/ImageBuilder.d.ts

4

lib/Canvas/module.d.ts

@@ -1,2 +0,2 @@

export * from "@napi-rs/canvas";
export { loadImage } from "../Utils/loadImage";
export * from '@napi-rs/canvas';
export { loadImage } from '../Utils/loadImage';
/// <reference types="node" />
import { ImageSource } from "../types/globalTypes";
import { SKRSContext2D, Canvas as SkCanvas } from "@napi-rs/canvas";
import { ImageSource, SketchConstructorOptions } from '../types/globalTypes';
import { SKRSContext2D, Canvas as SkCanvas } from '@napi-rs/canvas';
/**

@@ -23,2 +23,3 @@ * Basic photo editing

static colour(colour: string, width: number, height: number): Promise<Buffer>;
static sketch(image: ImageSource, options?: SketchConstructorOptions): Promise<Buffer>;
}

@@ -15,2 +15,4 @@ "use strict";

const Util_1 = require("../Utils/Util");
const Sketch_1 = require("../include/Sketch");
const loadImage_1 = require("../Utils/loadImage");
/**

@@ -21,3 +23,3 @@ * Basic photo editing

constructor() {
throw new Error("Cannot instantiate static class");
throw new Error('Cannot instantiate static class');
}

@@ -27,6 +29,6 @@ static blur(image, pixels) {

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
// experiment

@@ -45,3 +47,3 @@ // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter

const canvas = canvas_1.createCanvas(image.width, image.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);

@@ -67,3 +69,3 @@ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const canvas = canvas_1.createCanvas(image.width, image.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);

@@ -90,3 +92,3 @@ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const canvas = canvas_1.createCanvas(image.width, image.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);

@@ -108,3 +110,3 @@ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const canvas = canvas_1.createCanvas(image.width, image.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);

@@ -125,3 +127,3 @@ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const canvas = canvas_1.createCanvas(image.width, image.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(image, 0, 0);

@@ -143,8 +145,8 @@ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
ctx.globalCompositeOperation = "destination-in";
ctx.globalCompositeOperation = 'destination-in';
ctx.beginPath();

@@ -206,9 +208,9 @@ ctx.arc(canvas.width / 2, canvas.height / 2, canvas.height / 2, 0, Math.PI * 2);

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
if (color) {
ctx.globalCompositeOperation = "color";
ctx.globalCompositeOperation = 'color';
ctx.fillStyle = color;

@@ -228,5 +230,5 @@ ctx.fillRect(0, 0, canvas.width, canvas.height);

const canvas = canvas_1.createCanvas(width !== null && width !== void 0 ? width : 1024, height !== null && height !== void 0 ? height : 1024);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.fillStyle = color !== null && color !== void 0 ? color : "#FFFFFF";
ctx.fillStyle = color !== null && color !== void 0 ? color : '#FFFFFF';
ctx.fillRect(0, 0, canvas.width, canvas.height);

@@ -241,3 +243,36 @@ return yield canvas.png();

}
static sketch(image, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
if (!image)
return reject(new Error("Source image was not provided"));
const img = yield loadImage_1.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
Object.assign({}, {
levelSteps: 6,
lineAlpha: 0.1,
lineThickness: 2,
lineDensity: 0.5,
lightness: 4,
edgeBlurAmount: 2,
edgeAmount: 0.5
}, options);
const greyscale = Boolean(options.greyscale);
delete options['greyscale'];
Object.keys(options).filter((x) => x !== 'greyscale').forEach((fn) => {
if (!Util_1.Util.is(options[fn], 'number') || options[fn] === Infinity)
return reject(new TypeError(`options.${fn} must be a finite number, received ${fn}!`));
});
const sketcher = new Sketch_1.Sketcher(canvas.width, canvas.height);
for (const prop of Object.keys(options)) {
sketcher[prop] = options[prop];
}
sketcher.transformCanvas(canvas, greyscale)
.whenReady(() => __awaiter(this, void 0, void 0, function* () { return resolve(yield canvas.png()); }));
}));
});
}
}
exports.Photoshop = Photoshop;
/// <reference types="node" />
import { ImageSource } from "../types/globalTypes";
import { ImageSource } from '../types/globalTypes';
/**

@@ -4,0 +4,0 @@ * Housing for memes

@@ -25,7 +25,7 @@ "use strict";

constructor() {
throw new Error("Cannot instantiate static class");
throw new Error('Cannot instantiate static class');
}
static trigger(img) {
return __awaiter(this, void 0, void 0, function* () {
const base = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("TRIGGERED"));
const base = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('TRIGGERED'));
const image = yield Util_1.Util.loadImage(img);

@@ -37,3 +37,3 @@ const GIF = new gifencoder_1.default(256, 310);

const canvas = canvas_1.createCanvas(256, 310);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
const BR = 30;

@@ -46,3 +46,3 @@ const LR = 20;

ctx.save();
ctx.fillStyle = "#FF000033";
ctx.fillStyle = '#FF000033';
ctx.fillRect(0, 0, 256, 310);

@@ -67,8 +67,8 @@ ctx.restore();

if (!image1)
throw new Error("First image was not provided!");
throw new Error('First image was not provided!');
if (!image2)
throw new Error("Second image was not provided!");
throw new Error('Second image was not provided!');
const canvas = canvas_1.createCanvas(768, 574);
const ctx = canvas.getContext("2d");
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("KISS"));
const ctx = canvas.getContext('2d');
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('KISS'));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

@@ -85,8 +85,8 @@ const avatar = yield Util_1.Util.loadImage(image1);

if (!image1)
throw new Error("First image was not provided!");
throw new Error('First image was not provided!');
if (!image2)
throw new Error("Second image was not provided!");
throw new Error('Second image was not provided!');
const canvas = canvas_1.createCanvas(500, 500);
const ctx = canvas.getContext("2d");
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("SPANK"));
const ctx = canvas.getContext('2d');
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('SPANK'));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

@@ -103,8 +103,8 @@ const avatar = yield Util_1.Util.loadImage(image1);

if (!image1)
throw new Error("First image was not provided!");
throw new Error('First image was not provided!');
if (!image2)
throw new Error("Second image was not provided!");
throw new Error('Second image was not provided!');
const canvas = canvas_1.createCanvas(1000, 500);
const ctx = canvas.getContext("2d");
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("BATSLAP"));
const ctx = canvas.getContext('2d');
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('BATSLAP'));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

@@ -121,7 +121,7 @@ const avatar = yield Util_1.Util.loadImage(image1);

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const base = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("BEAUTIFUL"));
const base = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('BEAUTIFUL'));
const canvas = canvas_1.createCanvas(376, 400);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0, canvas.width, canvas.height);

@@ -136,7 +136,7 @@ ctx.drawImage(img, 258, 28, 84, 95);

if (!image)
throw new Error("image was not provided!");
let layer = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("FACEPALM"));
throw new Error('image was not provided!');
let layer = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('FACEPALM'));
let canvas = canvas_1.createCanvas(632, 357);
let ctx = canvas.getContext("2d");
ctx.fillStyle = "black";
let ctx = canvas.getContext('2d');
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, 632, 357);

@@ -152,7 +152,7 @@ let avatar = yield Util_1.Util.loadImage(image);

if (!image)
throw new Error("image was not provided!");
let bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("GAY"));
throw new Error('image was not provided!');
let bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('GAY'));
let img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

@@ -166,7 +166,7 @@ ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("RIP"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('RIP'));
const canvas = canvas_1.createCanvas(244, 253);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

@@ -180,8 +180,8 @@ ctx.drawImage(img, 63, 110, 90, 90);

if (!image)
throw new Error("Image was not provided!");
throw new Error('Image was not provided!');
const blur = yield Photoshop_1.Photoshop.blur(image, 3);
const img = yield Util_1.Util.loadImage(blur);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("TRASH"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('TRASH'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0);

@@ -195,7 +195,7 @@ ctx.drawImage(img, 309, 0, 309, 309);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("HITLER"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('HITLER'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0);

@@ -209,8 +209,8 @@ ctx.drawImage(img, 46, 43, 140, 140);

if (!image)
throw new Error("Image wasn ot provided!");
const layer = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("JOKEOVERHEAD"));
throw new Error('Image wasn ot provided!');
const layer = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('JOKEOVERHEAD'));
const img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(425, 404);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "black";
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, 425, 404);

@@ -225,6 +225,6 @@ ctx.drawImage(img, 125, 130, 140, 135);

if (!image1)
throw new Error("First image was not provided!");
throw new Error('First image was not provided!');
if (!image2)
throw new Error("Second image was not provided!");
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("DISTRACTED"));
throw new Error('Second image was not provided!');
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('DISTRACTED'));
const avatar1 = yield Util_1.Util.loadImage(yield Photoshop_1.Photoshop.circle(image1));

@@ -234,3 +234,3 @@ const avatar2 = yield Util_1.Util.loadImage(yield Photoshop_1.Photoshop.circle(image2));

const canvas = canvas_1.createCanvas(background.width, background.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

@@ -247,7 +247,7 @@ ctx.drawImage(avatar1, 180, 90, 150, 150);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("AFFECT"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('AFFECT'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0);

@@ -261,7 +261,7 @@ ctx.drawImage(img, 180, 383, 200, 157);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(greyscale ? yield Photoshop_1.Photoshop.greyscale(image) : image);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("JAIL"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('JAIL'));
const canvas = canvas_1.createCanvas(350, 350);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

@@ -275,10 +275,10 @@ ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

if (!image1)
throw new Error("First image was not provided!");
throw new Error('First image was not provided!');
if (!image2)
throw new Error("Second image was not provided!");
throw new Error('Second image was not provided!');
const avatar = yield Util_1.Util.loadImage(image1);
const avatar1 = yield Util_1.Util.loadImage(image2);
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("BED"));
const background = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('BED'));
const canvas = canvas_1.createCanvas(background.width, background.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

@@ -295,7 +295,7 @@ ctx.drawImage(avatar, 25, 100, 100, 100);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const bg = yield Util_1.Util.loadImage(dark ? yield Photoshop_1.Photoshop.invert(yield Util_1.Util.assets.image("DELETE")) : yield Util_1.Util.assets.image("DELETE"));
const bg = yield Util_1.Util.loadImage(dark ? yield Photoshop_1.Photoshop.invert(yield Util_1.Util.assets.image('DELETE')) : yield Util_1.Util.assets.image('DELETE'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

@@ -309,7 +309,7 @@ ctx.drawImage(img, 120, 135, 195, 195);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(image);
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("WANTED"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('WANTED'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

@@ -323,7 +323,7 @@ ctx.drawImage(img, 145, 282, 447, 447);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(yield Photoshop_1.Photoshop.greyscale(image));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("WASTED"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('WASTED'));
const canvas = canvas_1.createCanvas(512, 512);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

@@ -337,7 +337,7 @@ ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

if (!image)
throw new Error("image was not provided!");
throw new Error('image was not provided!');
const img = yield Util_1.Util.loadImage(yield Photoshop_1.Photoshop.circle(image));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image("SHIT"));
const bg = yield Util_1.Util.loadImage(yield Util_1.Util.assets.image('SHIT'));
const canvas = canvas_1.createCanvas(bg.width, bg.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height);

@@ -351,8 +351,8 @@ ctx.drawImage(img, 210, 700, 170, 170);

if (!image)
throw new Error("image was not provided!");
if (typeof times !== "number" || times <= 0 || times >= Infinity)
throw new Error('image was not provided!');
if (typeof times !== 'number' || times <= 0 || times >= Infinity)
times = 1;
const img = yield Util_1.Util.loadImage(image);
const canvas = canvas_1.createCanvas(img.width, img.height);
const ctx = canvas.getContext("2d");
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

@@ -359,0 +359,0 @@ for (let i = 0; i < times; i++) {

@@ -1,8 +0,6 @@

export * as Canvas from "./Canvas/module";
export { CanvacordImgen as ImageMaker } from "./imgen/Imgen";
export { Matrices as ConvolutionMatrix } from "./editor/Matrix";
export { Photoshop } from "./editor/Photoshop";
export { RankCardBuilder as RankCard } from "./builders/RankCard";
export { SpotifyCardBuilder as SpotifyCard } from "./builders/SpotifyCard";
export { Util } from "./Utils/Util";
export * from "./types/globalTypes";
export * as Canvas from './Canvas/module';
export { CanvacordImgen as ImageMaker } from './imgen/Imgen';
export { Matrices as ConvolutionMatrix } from './editor/Matrix';
export { Photoshop } from './editor/Photoshop';
export { Util } from './Utils/Util';
export * from './types/globalTypes';

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Util = exports.SpotifyCard = exports.RankCard = exports.Photoshop = exports.ConvolutionMatrix = exports.ImageMaker = exports.Canvas = void 0;
exports.Util = exports.Photoshop = exports.ConvolutionMatrix = exports.ImageMaker = exports.Canvas = void 0;
exports.Canvas = __importStar(require("./Canvas/module"));

@@ -34,8 +34,4 @@ var Imgen_1 = require("./imgen/Imgen");

Object.defineProperty(exports, "Photoshop", { enumerable: true, get: function () { return Photoshop_1.Photoshop; } });
var RankCard_1 = require("./builders/RankCard");
Object.defineProperty(exports, "RankCard", { enumerable: true, get: function () { return RankCard_1.RankCardBuilder; } });
var SpotifyCard_1 = require("./builders/SpotifyCard");
Object.defineProperty(exports, "SpotifyCard", { enumerable: true, get: function () { return SpotifyCard_1.SpotifyCardBuilder; } });
var Util_1 = require("./Utils/Util");
Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
__exportStar(require("./types/globalTypes"), exports);
/// <reference types="node" />
export declare type ImageSource = string | Buffer;
export interface SketchConstructorOptions {
levelSteps?: number;
lineAlpha?: number;
lineThickness?: number;
lineDensity?: number;
lightness?: number;
edgeBlurAmount?: number;
edgeAmount?: number;
greyscale?: boolean;
}
/// <reference types="node" />
import { Image as SkImage } from "@napi-rs/canvas";
import { Image as SkImage } from '@napi-rs/canvas';
/**

@@ -4,0 +4,0 @@ * Utility function to load images

@@ -25,7 +25,7 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
if (typeof source === "string" && fs_1.existsSync(source)) {
if (typeof source === 'string' && fs_1.existsSync(source)) {
const data = yield fs_1.promises.readFile(source);
return createImage(data);
}
else if (typeof source === "string") {
else if (typeof source === 'string') {
const res = yield node_fetch_1.default(source);

@@ -32,0 +32,0 @@ if (res.status !== 200)

@@ -1,10 +0,10 @@

import { loadImage, createImage } from "./loadImage";
import { SKRSContext2D as CanvasRenderingContext2D } from "@napi-rs/canvas";
import { weirdToNormalChars } from "weird-to-normal-chars";
/// <reference types="node" />
import { SKRSContext2D as CanvasRenderingContext2D } from '@napi-rs/canvas';
/**
* Canvacord Utils
*/
export declare const Util: {
loadImage: typeof loadImage;
createImage: typeof createImage;
export declare class Util {
constructor();
static loadImage(source: string | Buffer): Promise<import("@napi-rs/canvas").Image>;
static createImage(src: Buffer): void;
/**

@@ -17,3 +17,3 @@ * Renders emoji in canvas

*/
renderEmoji(ctx: CanvasRenderingContext2D, message: string, x: number, y: number): Promise<void>;
static renderEmoji(ctx: CanvasRenderingContext2D, message: string, x: number, y: number): Promise<void>;
/**

@@ -23,8 +23,9 @@ * Abbreviate the given number

*/
toAbbrev(num: number): string;
assets: {
static toAbbrev(num: number): string;
static get assets(): {
font(name: string): Promise<string>;
image(name: string): Promise<string>;
};
cleanText: typeof weirdToNormalChars;
};
static cleanText(text: string): string;
static is(prop: any, propType: string): boolean;
}

@@ -23,5 +23,12 @@ "use strict";

*/
exports.Util = {
loadImage: loadImage_1.loadImage,
createImage: loadImage_1.createImage,
class Util {
constructor() {
throw new Error('Cannot instantiate util');
}
static loadImage(source) {
return loadImage_1.loadImage(source);
}
static createImage(src) {
loadImage_1.createImage(src);
}
/**

@@ -34,7 +41,7 @@ * Renders emoji in canvas

*/
renderEmoji(ctx, message, x, y) {
static renderEmoji(ctx, message, x, y) {
// @todo: fix this
// @ts-ignore
return emoji_parser_1.fillTextWithTwemoji(ctx, message, x, y);
},
}
/**

@@ -44,10 +51,10 @@ * Abbreviate the given number

*/
toAbbrev(num) {
static toAbbrev(num) {
if (!num || isNaN(num))
return "0";
if (typeof num === "string")
return '0';
if (typeof num === 'string')
num = parseInt(num);
const decPlaces = Math.pow(10, 1);
const abbrev = ["K", "M", "B", "T"];
let dat = "";
const abbrev = ['K', 'M', 'B', 'T'];
let dat = '';
for (let i = abbrev.length - 1; i >= 0; i--) {

@@ -66,20 +73,30 @@ const size = Math.pow(10, (i + 1) * 3);

return dat;
},
assets: {
font(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!assets_1.default.font.loaded)
yield assets_1.default.font.load();
return assets_1.default.font.get(name);
});
},
image(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!assets_1.default.image.loaded)
yield assets_1.default.image.load();
return assets_1.default.image.get(name);
});
}
},
cleanText: weird_to_normal_chars_1.weirdToNormalChars
};
}
static get assets() {
return {
font(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!assets_1.default.font.loaded)
yield assets_1.default.font.load();
return assets_1.default.font.get(name);
});
},
image(name) {
return __awaiter(this, void 0, void 0, function* () {
if (!assets_1.default.image.loaded)
yield assets_1.default.image.load();
return assets_1.default.image.get(name);
});
}
};
}
static cleanText(text) {
return weird_to_normal_chars_1.weirdToNormalChars(text);
}
static is(prop, propType) {
if (propType === 'array')
return Array.isArray(prop);
return typeof prop === propType;
}
}
exports.Util = Util;
{
"name": "@canvacord/beta",
"version": "6.0.0-dev-2",
"version": "6.0.0-dev-3",
"description": "Simple & easy to use image manipulation module for beginners.",

@@ -11,6 +11,7 @@ "main": "lib/index.js",

"scripts": {
"build": "tsc",
"build": "rimraf lib && tsc",
"docs": "docgen --source src/*.ts src/**/*.ts --custom docs/index.yml --output docs/docs.json",
"docs:test": "docgen --source src/*.ts src/**/*.ts --custom docs/index.yml",
"test": "tsc && cd test && node index.js",
"test": "jest",
"dev": "cd test && node index.js",
"format": "prettier --write **/*.{ts,js,json,yaml,yml}"

@@ -50,4 +51,3 @@ },

"@canvacord/emoji-parser": "^1.0.1",
"@napi-rs/canvas": "^0.0.4",
"@types/node-fetch": "^2.5.10",
"@napi-rs/canvas": "^0.0.6",
"gifencoder": "^2.0.1",

@@ -58,6 +58,14 @@ "node-fetch": "^2.6.1",

"devDependencies": {
"@babel/preset-env": "^7.14.2",
"@babel/preset-typescript": "^7.13.0",
"@types/gifencoder": "^2.0.1",
"@types/jest": "^26.0.23",
"@types/node": "^14.14.41",
"@types/node-fetch": "^2.5.10",
"discord.js-docgen": "github:discordjs/docgen#ts-patch",
"file-type": "^16.4.0",
"jest": "^27.0.0",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-node": "^10.0.0",
"typescript": "^4.2.4"

@@ -67,6 +75,3 @@ },

"url": "https://github.com/DevSnowflake/Canvacord/issues"
},
"directories": {
"doc": "docs"
}
}
# Canvacord
Simple & easy to use image manipulation module for beginners.
Simple & easy to use image manipulation module.

@@ -4,0 +4,0 @@ # v6 WIP

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc