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

pure-canvas

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-canvas - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

16

lib/Image.js

@@ -11,4 +11,6 @@ "use strict";

function Image(_a) {
var width = _a.width, height = _a.height, image = _a.image;
_super.call(this, { minX: 0, minY: 0, maxX: width, maxY: height });
var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, width = _a.width, height = _a.height, image = _a.image;
_super.call(this, { minX: x, minY: y, maxX: x + width, maxY: y + height });
this.x = x;
this.y = y;
this.width = width;

@@ -19,5 +21,5 @@ this.height = height;

Image.prototype.draw = function (context) {
var _a = this, width = _a.width, height = _a.height, image = _a.image;
var _a = this, x = _a.x, y = _a.y, width = _a.width, height = _a.height, image = _a.image;
try {
context.drawImage(image, 0, 0, width, height);
context.drawImage(image, x, y, width, height);
}

@@ -29,5 +31,5 @@ catch (invalidStateError) {

var x = _a.x, y = _a.y;
var _b = this, width = _b.width, height = _b.height, image = _b.image;
var rx = Math.round(x);
var ry = Math.round(y);
var _b = this, ox = _b.x, oy = _b.y, width = _b.width, height = _b.height, image = _b.image;
var rx = Math.round(x - ox);
var ry = Math.round(y - oy);
if (0 <= rx && rx <= width && 0 <= ry && ry <= height) {

@@ -34,0 +36,0 @@ if (!this.pixelArray) {

{
"name": "pure-canvas",
"version": "0.4.1",
"version": "0.4.2",
"description": "TODO",

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

@@ -5,2 +5,4 @@ import Node, {Point} from './Node';

export interface ImageParameters {
x?: number;
y?: number;
width: number;

@@ -12,2 +14,4 @@ height: number;

class Image extends NodeFixedBounds {
private x: number;
private y: number;
private width: number;

@@ -18,4 +22,6 @@ private height: number;

constructor({width, height, image}: ImageParameters) {
super({minX: 0, minY: 0, maxX: width, maxY: height});
constructor({x = 0, y = 0, width, height, image}: ImageParameters) {
super({minX: x, minY: y, maxX: x + width, maxY: y + height});
this.x = x;
this.y = y;
this.width = width;

@@ -27,5 +33,5 @@ this.height = height;

draw(context: CanvasRenderingContext2D): void {
const {width, height, image} = this;
const {x, y, width, height, image} = this;
try {
context.drawImage(image, 0, 0, width, height);
context.drawImage(image, x, y, width, height);
} catch (invalidStateError) {

@@ -37,5 +43,5 @@ // Silently ignore

intersection({x, y}: Point): Node {
const {width, height, image} = this;
const rx = Math.round(x);
const ry = Math.round(y);
const {x: ox, y: oy, width, height, image} = this;
const rx = Math.round(x - ox);
const ry = Math.round(y - oy);

@@ -42,0 +48,0 @@ if (0 <= rx && rx <= width && 0 <= ry && ry <= height) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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