🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more →
Sign In

cherry-box

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cherry-box - npm Package Compare versions

Comparing version
1.2.1
to
1.2.3
+72
.github/workflows/codeql-analysis.yml
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '36 5 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# â„šī¸ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
import { textBox, wrapText } from "cherry-box";
import Canvas from "canvas";
const canvas = new Canvas.createCanvas(800, 600);
const ctx = canvas.getContext("2d");
let upperText = [
{
text: "POV: Linux user",
color: "white",
modifier: "bold",
font: "ubuntu",
shadow: {
color: "red",
offset: [0, 0],
blur: 10
}
}
];
textBox(ctx, 0, 0, canvas.width, canvas.height-20, upperText, 80, ["bottom", "center"]);
let wrapTextBox = [
{
text: "I'd like to interject for a moment, what you reffered to as Linux was in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called \"Linux\", and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. The Free Software Foundation obviously intends Linux to be free software like any other free program, and whoever works for the Free Software Foundation will do whatever it takes to ensure that the GNU system remains free. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called \"Linux\" distributions are really distributions of GNU/Linux.",
color: "yellow",
font: 'Arial',
modifier: "bold",
shadow: {
color: "red",
offset: [10, 10],
blur: 10
}
}
]
wrapText(ctx, 25, 25, canvas.width-50, wrapTextBox, 20, 'justify');
import { textBox } from "cherry-box";
import Canvas from "canvas";
const canvas = new Canvas.createCanvas(800, 600);
const ctx = canvas.getContext("2d");
let meme = [
'upper text',
'lower text'
]
let upperText = [
{
text: meme[0],
color: "white",
font: "Impact",
shadow: {
color: "black",
offset: [0, 0],
blur: 10
}
}
];
let lowerText = [
{
text: meme[1],
color: "white",
font: "Impact",
shadow: {
color: "black",
offset: [0, 0],
blur: 10
}
}
];
//Draw text
textBox(ctx, 0, 0, canvas.width, 80, upperText, 80, ["middle", "center"]);
textBox(ctx, 0, canvas.height-80, canvas.width, 80, lowerText, 80, ["middle", "center"]);
function paintText(t,e,o,l,i,n=0){t.save(),e.forEach(({text:e,color:r,shadow:a,font:f,modifier:h})=>{t.fillStyle=r,null==h&&(h=""),t.font=`${h} ${i}px ${f}`,a?(t.shadowColor=a.color,t.shadowOffsetX=a.offset[0]*i/100,t.shadowOffsetY=a.offset[1]*i/100,t.shadowBlur=a.blur):t.shadowColor="transparent",t.fillText(e,o,l),o+=t.measureText(e).width+n}),t.restore()}function getTotalWidth(t,e,o,l=0){let i=0;return e.forEach(({text:e,font:n,modifier:r})=>{null==r&&(r=""),t.font=`${r} ${o}px ${n}`,i+=t.measureText(e).width+l}),i-l}function getTotalHeight(t,e,o){let l="";e.forEach(({text:e,font:i})=>{t.font=o+"px "+i,l+=e});const i=t.measureText(l);return i.actualBoundingBoxAscent+i.actualBoundingBoxDescent}function textBox(t,e,o,l,i,n,r,a=["middle","center"]){t.save();let f=getTotalWidth(t,n,r);f>l&&(r*=l/f);let h=getTotalHeight(t,n,r);f=getTotalWidth(t,n,r),"top"===a[0]&&(o+=h),"bottom"===a[0]&&(o+=i),"middle"===a[0]&&(o+=(h+i)/2),"center"===a[1]&&(e+=l/2-f/2),"right"===a[1]&&(e+=l-f),"left"===a[1]&&(e+=0),paintText(t,n,e,o,r),t.restore()}function wrapText(t,e,o,l,i,n,r="left"){t.save();let a=[],f=[],h=10;for(let e in i){let o=i[e].text.split(" "),r=0;for(r in o){let s={color:i[e].color,text:o[r],font:i[e].font,modifier:i[e].modifier,shadow:i[e].shadow},d=getTotalWidth(t,f,n,h),x=getTotalWidth(t,[s],n,h);d+x+10>l&&(a.push(f),f=[]),f.push(s)}}a.push(f);for(let i in a){let f=getTotalWidth(t,a[i],n,h),s=e;if("center"===r&&(s+=l/2-f/2),"right"===r&&(s+=l-f),"left"===r&&(s+=0),"justify"===r){let e=getTotalWidth(t,a[i],n);h=(l-e)/(a[i].length-1),h<4&&(h=4),h>50&&(h=10)}paintText(t,a[i],s,o+n*i+n,n,h)}t.restore()}export{textBox,getTotalWidth,getTotalHeight,wrapText,paintText};
+2
-0

@@ -17,2 +17,4 @@ /**

ctx.fillStyle = color;
if (modifier == undefined) modifier = '';
ctx.font = `${modifier} ${fontSize}px ${font}`;

@@ -19,0 +21,0 @@

+2
-1

@@ -16,3 +16,4 @@ import paintText from './paintText.js';

text.forEach(({ text, font, modifier }) => {
ctx.font = modifier + " " + fontSize + "px " + font;
if (modifier == undefined) modifier = '';
ctx.font = `${modifier} ${fontSize}px ${font}`;
width += ctx.measureText(text).width + spaceWidth;

@@ -19,0 +20,0 @@ });

{
"name": "cherry-box",
"version": "1.2.1",
"version": "1.2.3",
"description": "A node-canvas package filled with utilities, manage text boxes easily and more",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -25,4 +25,3 @@ # About

]
let text = textBox(800, 600, textSchema, 200, ['middle', 'center']);
ctx.drawImage(text, 0, 0)
textBox(800, 600, textSchema, 200, ['middle', 'center']);
```

@@ -29,0 +28,0 @@

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

import { textBox, wrapText } from "./lib/textBox.js";
//import { textBox, wrapText } from "./lib/textBox.js";
import { textBox, wrapText } from "./index.min.js";
import Canvas from "canvas";

@@ -31,3 +32,3 @@ import fs from "fs";

color: "red",
offset: [0, 0],
offset: [10, 10],
blur: 10

@@ -37,3 +38,3 @@ }

]
wrapText(ctx, 0, 0, canvas.width, wrapTextBox, 20, 'justify');
wrapText(ctx, 25, 25, canvas.width-50, wrapTextBox, 20, 'justify');

@@ -40,0 +41,0 @@ // Save canvas to file