Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphics-wrapper

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

graphics-wrapper - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

test/test.js

32

index.js

@@ -273,19 +273,23 @@ const Canvas = require("canvas");

* @param {Number} h
* @param {Number} dx
* @param {Number} dy
* @param {Number} x1
* @param {Number} y1
* @param {Number} x2
* @param {Number} y2
*/
module.exports.drawNineSlice = function(image, x, y, w, h, dx, dy) {
module.exports.drawNineSlice = function(image, x, y, w, h, x1, y1, x2, y2) {
const iw = image.width;
const ih = image.height;
if (!dx) dx = Math.floor(iw / 3);
if (!dy) dy = Math.floor(ih / 3);
ctx.drawImage(image, 0, 0, dx, dy, x, y, dx, dy);
ctx.drawImage(image, dx, 0, iw-dx*2, dy, x+dx, y, w-dx*2, dy);
ctx.drawImage(image, iw-dx, 0, dx, dy, x+w-dx, y, dx, dy);
ctx.drawImage(image, 0, dy, dx, ih-dy*2, x, y+dy, dx, h-dy*2);
ctx.drawImage(image, dx, dy, iw-dx*2, ih-dy*2, x+dx, y+dy, w-dx*2, h-dy*2);
ctx.drawImage(image, iw-dx, dy, dx, ih-dy*2, x+w-dx, y+dy, dx, h-dy*2);
ctx.drawImage(image, 0, ih-dy, dx, dy, x, y+h-dx, dx, dy);
ctx.drawImage(image, dx, ih-dy, iw-dx*2, dy, x+dx, y+h-dx, w-dx*2, dy);
ctx.drawImage(image, iw-dx, ih-dy, dx, dy, x+w-dx, y+h-dx, dx, dy);
if (!x1) x1 = Math.floor(iw / 3);
if (!y1) y1 = Math.floor(x1 / iw * ih);
if (!x2) x2 = x1;
if (!y2) y2 = y1;
ctx.drawImage(image, 0, 0, x1, y1, x, y, x1, y1);
ctx.drawImage(image, x1, 0, iw-x1-x2, y1, x+x1, y, w-x1-x2, y1);
ctx.drawImage(image, iw-x2, 0, x2, y1, x+w-x2, y, x2, y1);
ctx.drawImage(image, 0, y1, x1, ih-y1-y2, x, y+y1, x1, h-y1-y2);
ctx.drawImage(image, x1, y1, iw-x1-x2, ih-y1-y2, x+x1, y+y1, w-x1-x2, h-y1-y2);
ctx.drawImage(image, iw-x2, y1, x2, ih-y1-y2, x+w-x2, y+y1, x2, h-y1-y2);
ctx.drawImage(image, 0, ih-y2, x1, y2, x, y+h-y2, x1, y2);
ctx.drawImage(image, x1, ih-y2, iw-x1-x2, y2, x+x1, y+h-y2, w-x1-x2, y2);
ctx.drawImage(image, iw-x2, ih-y2, x2, y2, x+w-x2, y+h-y2, x2, y2);
};
{
"name": "graphics-wrapper",
"version": "1.1.0",
"version": "1.1.1",
"description": "A wrapper for node-canvas",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "node test/test.js",
"testNineSlice": "node test/testNineSlice.js"
},

@@ -9,0 +10,0 @@ "author": "Vlams",

@@ -10,3 +10,3 @@

const Canvas = require('canvas');
const Draw = require('./');
const Draw = require('graphics-wrapper');

@@ -13,0 +13,0 @@ const canvas = Canvas.createCanvas(500, 500);

Sorry, the diff of this file is not supported yet

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