![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@szydlovski/canvas-utility
Advanced tools
This library contains various utilities designed for working with the HTML5 Canvas. It facilitates operations like creating, copying, cropping, trimming, flipping, merging, resizing and rotating canvases.
npm install @szydlovski/canvas-utility
Example usage using the Canvas
wrapper:
import { Canvas, loadImage } from '@szydlovski/canvas-utility';
(async () => {
const image = await loadImage('https://source.unsplash.com/random');
const canvas = Canvas.create([500, 500])
.draw((ctx) => ctx.drawImage(image, 0, 0, 500, 500))
.flip()
.resize({ width: 800 })
.crop('16:9')
.rotate(90)
.toElement();
document.body.appendChild(canvas);
})();
This will result in a random image drawn at 500 by 500 pixels, flipped horizontally, resized to 800 by 800 pixels, cropped to a 16:9 ratio (800x450) and then rotated by 90 degrees. The resulting canvas will be 450 pixels wide and 800 pixels tall.
All of the operations used in this example are also exported as individual functions, so using the wrapper is completely optional:
import { flipCanvas, cropCanvas, resizeCanvas, loadImage } from '@szydlovski/canvas-utility';
(async () => {
const image = await loadImage('https://source.unsplash.com/random');
document.body.appendChild(
flipCanvas(cropCanvas(resizeCanvas(image, { width: 500 }), '16:9'))
);
})();
This will result in a random image, resized to a width of 500 pixels (height will be calculated from the image's aspect ratio), cropped to 16:9 and flipped horizontally.
The functions can be neatly composed to quickly
import { cropCanvas, resizeCanvas } from '@szydlovski/canvas-utility';
const resizeAndCropPreviewImage = (image) =>
resizeCanvas(cropCanvas(image, '1:1'), { width: 250 });
// or...
import { Canvas } from '@szydlovski/canvas-utility';
const resizeAndCropPreviewImage = (image) =>
Canvas.fromImage(image).crop('1:1').resize({ width: 250 }).toElement();
fillCircle
, strokeCircle
fillPolygon
, strokePolygon
fillImage
, strokeImage
ImageData
- ImageDataHandle
Canvas
adjustCanvas
, a function which allows pixel by pixel color adjustmentflipCanvas
FAQs
simple canvas 2d utility - trimming, rotating, resizing
The npm package @szydlovski/canvas-utility receives a total of 0 weekly downloads. As such, @szydlovski/canvas-utility popularity was classified as not popular.
We found that @szydlovski/canvas-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.