Socket
Socket
Sign inDemoInstall

canvas-elements

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.5 to 0.0.6

2

build/cdn/canvas-elements.min.js

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

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self)["canvas-elements"]={})}(this,function(t){"use strict";var s=function(t,i){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])})(t,i)};function i(t,i){function r(){this.constructor=t}s(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){function t(t,i,r,s,e,o,h,n){if(void 0===r&&(r=0),void 0===s&&(s="#000"),void 0===e&&(e=0),void 0===o&&(o="#000"),void 0===h&&(h="solid"),!t)throw new Error("X coordinate is not defined");if(!i)throw new Error("Y coordinate is not defined");if(!n)throw new Error("Canvas rendering context is not defined");this.x=t,this.y=i,this.rotation=r,this.background=s,this.borderWidth=e,this.borderColor=o,this.borderStyle=h,this.ctx=n}return t.prototype.rotate=function(t,i,r){void 0===r&&(r=!0),this.ctx.translate(t,i),this.ctx.rotate((r?1:-1)*this.rotation),this.ctx.translate(-t,-i)},t.prototype.draw=function(){if("string"==typeof this.borderStyle)switch(this.borderStyle){case"dotted":this.ctx.setLineDash([1,2*this.borderWidth]);break;case"dashed":this.ctx.setLineDash([8,10]);break;default:this.ctx.setLineDash([])}else Array.isArray(this.borderStyle)&&this.ctx.setLineDash(this.borderStyle)},t}(),e=function(y){function t(t){var i=this,r=t.x,s=t.y,e=t.radiusX,o=t.radiusY,h=t.rotation,n=void 0===h?0:h,d=t.background,a=t.borderColor,c=t.borderWidth,l=t.borderStyle,x=t.ctx;return(i=y.call(this,r,s,n,d,c,a,l,x)||this).radiusX=e,i.radiusY=o,i.draw(),i}return i(t,y),t.prototype.draw=function(){y.prototype.draw.call(this),this.ctx.beginPath(),this.ctx.ellipse(this.x,this.y,this.radiusX,this.radiusY,this.rotation,0,2*Math.PI,!1),this.ctx.fillStyle=this.background,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.stroke()),this.ctx.fill(),this.ctx.closePath()},t}(r),o=function(a){function t(t){var i=t.x,r=t.y,s=t.r,e=t.background,o=t.borderColor,h=t.borderWidth,n=t.borderStyle,d=t.ctx;return a.call(this,{x:i,y:r,radiusX:s,radiusY:s,rotation:0,background:e,borderColor:o,borderWidth:h,borderStyle:n,ctx:d})||this}return i(t,a),t}(e),h=function(f){function t(t){var i=t.x,r=t.y,s=t.w,e=t.h,o=t.r,h=void 0===o?0:o,n=t.rotation,d=void 0===n?0:n,a=t.borderColor,c=t.background,l=t.borderWidth,x=t.borderStyle,y=t.ctx,u=f.call(this,i,r,d,c,l,a,x,y)||this;return u.r=h,u.w=s,u.h=e,u.draw(),u}return i(t,f),t.prototype.draw=function(){f.prototype.draw.call(this),this.rotate(this.w/2+this.x,this.h/2+this.y),this.w<2*this.r&&(this.r=this.w/2),this.h<2*this.r&&(this.r=this.h/2),this.ctx.beginPath(),this.ctx.moveTo(this.x+this.r,this.y),this.ctx.arcTo(this.x+this.w,this.y,this.x+this.w,this.y+this.h,this.r),this.ctx.arcTo(this.x+this.w,this.y+this.h,this.x,this.y+this.h,this.r),this.ctx.arcTo(this.x,this.y+this.h,this.x,this.y,this.r),this.ctx.arcTo(this.x,this.y,this.x+this.w,this.y,this.r),this.ctx.closePath(),this.ctx.fillStyle=this.background,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.stroke()),this.ctx.fill(),this.rotate(this.w/2+this.x,this.h/2+this.y,!1)},t}(r),n=function(W){function t(t){var i=this,r=t.x,s=t.y,e=t.size,o=void 0===e?18:e,h=t.rotation,n=void 0===h?0:h,d=t.font,a=void 0===d?"Arial":d,c=t.background,l=t.align,x=void 0===l?"left":l,y=t.baseline,u=void 0===y?"middle":y,f=t.text,b=t.ctx,p=t.borderColor,w=t.borderWidth,v=t.borderStyle,g=t.weight,k=void 0===g?"400":g;return(i=W.call(this,r,s,n,c,w,p,v,b)||this).size=o,i.font=a,i.background=c,i.align=x,i.baseline=u,i.weight=k,i.text=f,i.draw(),i}return i(t,W),t.prototype.draw=function(){W.prototype.draw.call(this),this.rotate(this.x,this.y),this.ctx.font=this.weight+" "+this.size+"px "+this.font,this.ctx.fillStyle=this.background,this.ctx.textAlign=this.align,this.ctx.textBaseline=this.baseline,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.strokeText(this.text,this.x,this.y)),this.ctx.fillText(this.text,this.x,this.y),this.rotate(this.x,this.y,!1)},t}(r),d=function(p){function t(t){var i=this,r=t.x,s=t.y,e=t.x2,o=t.y2,h=t.r,n=t.angle,d=t.rotation,a=void 0===d?0:d,c=t.background,l=t.borderColor,x=t.borderWidth,y=t.borderStyle,u=t.lineCap,f=void 0===u?"square":u,b=t.ctx;if(i=p.call(this,r,s,a,c||l,x,l,y,b)||this,"number"==typeof e&&"number"==typeof o)i.x2=e,i.y2=o;else{if("number"!=typeof h||"number"!=typeof n)throw new Error("Insufficient values to draw a line");i.x2=i.x+h*Math.cos(n),i.y2=i.y+h*Math.sin(n)}return i.lineCap=f,i.draw(),i}return i(t,p),t.prototype.draw=function(){p.prototype.draw.call(this);var t=(this.x+this.x2)/2,i=(this.y+this.y2)/2;this.rotate(t,i),this.ctx.beginPath(),this.ctx.moveTo(this.x,this.y),this.ctx.lineTo(this.x2,this.y2),this.borderWidth&&(this.ctx.lineCap=this.lineCap,this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.background),this.ctx.stroke(),this.rotate(t,i,!1)},t}(r);window.CanvasElements={Circle:o,Rect:h,Text:n,Ellipse:e,Line:d},t.Circle=o,t.Rect=h,t.Text=n,t.Ellipse=e,t.Line=d,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self)["canvas-elements"]={})}(this,function(t){"use strict";var s=function(t,i){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])})(t,i)};function i(t,i){function r(){this.constructor=t}s(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){function t(t,i,r,s,e,o,h,n){if(void 0===r&&(r=0),void 0===s&&(s="#000"),void 0===e&&(e=0),void 0===o&&(o="#000"),void 0===h&&(h="solid"),"number"!=typeof t)throw new Error("X coordinate is not defined");if("number"!=typeof i)throw new Error("Y coordinate is not defined");if(!n)throw new Error("Canvas rendering context is not defined");this.x=t,this.y=i,this.rotation=r,this.background=s,this.borderWidth=e,this.borderColor=o,this.borderStyle=h,this.ctx=n}return t.prototype.rotate=function(t,i,r){void 0===r&&(r=!0),this.ctx.translate(t,i),this.ctx.rotate((r?1:-1)*this.rotation),this.ctx.translate(-t,-i)},t.prototype.draw=function(){if("string"==typeof this.borderStyle)switch(this.borderStyle){case"dotted":this.ctx.setLineDash([1,2*this.borderWidth]);break;case"dashed":this.ctx.setLineDash([8,10]);break;default:this.ctx.setLineDash([])}else Array.isArray(this.borderStyle)&&this.ctx.setLineDash(this.borderStyle)},t}(),e=function(y){function t(t){var i=this,r=t.x,s=t.y,e=t.radiusX,o=t.radiusY,h=t.rotation,n=void 0===h?0:h,d=t.background,a=t.borderColor,c=t.borderWidth,l=t.borderStyle,x=t.ctx;return(i=y.call(this,r,s,n,d,c,a,l,x)||this).radiusX=e,i.radiusY=o,i.draw(),i}return i(t,y),t.prototype.draw=function(){y.prototype.draw.call(this),this.ctx.beginPath(),this.ctx.ellipse(this.x,this.y,this.radiusX,this.radiusY,this.rotation,0,2*Math.PI,!1),this.ctx.fillStyle=this.background,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.stroke()),this.ctx.fill(),this.ctx.closePath()},t}(r),o=function(a){function t(t){var i=t.x,r=t.y,s=t.r,e=t.background,o=t.borderColor,h=t.borderWidth,n=t.borderStyle,d=t.ctx;return a.call(this,{x:i,y:r,radiusX:s,radiusY:s,rotation:0,background:e,borderColor:o,borderWidth:h,borderStyle:n,ctx:d})||this}return i(t,a),t}(e),h=function(f){function t(t){var i=t.x,r=t.y,s=t.w,e=t.h,o=t.r,h=void 0===o?0:o,n=t.rotation,d=void 0===n?0:n,a=t.borderColor,c=t.background,l=t.borderWidth,x=t.borderStyle,y=t.ctx,u=f.call(this,i,r,d,c,l,a,x,y)||this;return u.r=h,u.w=s,u.h=e,u.draw(),u}return i(t,f),t.prototype.draw=function(){f.prototype.draw.call(this),this.rotate(this.w/2+this.x,this.h/2+this.y),this.w<2*this.r&&(this.r=this.w/2),this.h<2*this.r&&(this.r=this.h/2),this.ctx.beginPath(),this.ctx.moveTo(this.x+this.r,this.y),this.ctx.arcTo(this.x+this.w,this.y,this.x+this.w,this.y+this.h,this.r),this.ctx.arcTo(this.x+this.w,this.y+this.h,this.x,this.y+this.h,this.r),this.ctx.arcTo(this.x,this.y+this.h,this.x,this.y,this.r),this.ctx.arcTo(this.x,this.y,this.x+this.w,this.y,this.r),this.ctx.closePath(),this.ctx.fillStyle=this.background,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.stroke()),this.ctx.fill(),this.rotate(this.w/2+this.x,this.h/2+this.y,!1)},t}(r),n=function(W){function t(t){var i=this,r=t.x,s=t.y,e=t.size,o=void 0===e?18:e,h=t.rotation,n=void 0===h?0:h,d=t.font,a=void 0===d?"Arial":d,c=t.background,l=t.align,x=void 0===l?"left":l,y=t.baseline,u=void 0===y?"middle":y,f=t.text,b=t.ctx,p=t.borderColor,w=t.borderWidth,v=t.borderStyle,g=t.weight,k=void 0===g?"400":g;return(i=W.call(this,r,s,n,c,w,p,v,b)||this).size=o,i.font=a,i.background=c,i.align=x,i.baseline=u,i.weight=k,i.text=f,i.draw(),i}return i(t,W),t.prototype.draw=function(){W.prototype.draw.call(this),this.rotate(this.x,this.y),this.ctx.font=this.weight+" "+this.size+"px "+this.font,this.ctx.fillStyle=this.background,this.ctx.textAlign=this.align,this.ctx.textBaseline=this.baseline,this.borderWidth&&(this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.borderColor,this.ctx.strokeText(this.text,this.x,this.y)),this.ctx.fillText(this.text,this.x,this.y),this.rotate(this.x,this.y,!1)},t}(r),d=function(p){function t(t){var i=this,r=t.x,s=t.y,e=t.x2,o=t.y2,h=t.r,n=t.angle,d=t.rotation,a=void 0===d?0:d,c=t.background,l=t.borderColor,x=t.borderWidth,y=t.borderStyle,u=t.lineCap,f=void 0===u?"square":u,b=t.ctx;if(i=p.call(this,r,s,a,c||l,x,l,y,b)||this,"number"==typeof e&&"number"==typeof o)i.x2=e,i.y2=o;else{if("number"!=typeof h||"number"!=typeof n)throw new Error("Insufficient values to draw a line");i.x2=i.x+h*Math.cos(n),i.y2=i.y+h*Math.sin(n)}return i.lineCap=f,i.draw(),i}return i(t,p),t.prototype.draw=function(){p.prototype.draw.call(this);var t=(this.x+this.x2)/2,i=(this.y+this.y2)/2;this.rotate(t,i),this.ctx.beginPath(),this.ctx.moveTo(this.x,this.y),this.ctx.lineTo(this.x2,this.y2),this.borderWidth&&(this.ctx.lineCap=this.lineCap,this.ctx.lineWidth=this.borderWidth,this.ctx.strokeStyle=this.background),this.ctx.stroke(),this.rotate(t,i,!1)},t}(r);window.CanvasElements={Circle:o,Rect:h,Text:n,Ellipse:e,Line:d},t.Circle=o,t.Rect=h,t.Text=n,t.Ellipse=e,t.Line=d,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=canvas-elements.min.js.map

@@ -10,5 +10,5 @@ "use strict";

if (borderStyle === void 0) { borderStyle = 'solid'; }
if (!x)
if (typeof x !== 'number')
throw new Error('X coordinate is not defined');
if (!y)
if (typeof y !== 'number')
throw new Error('Y coordinate is not defined');

@@ -15,0 +15,0 @@ if (!ctx)

{
"name": "canvas-elements",
"version": "0.0.5",
"version": "0.0.6",
"description": "Collection of easy to use elements with HTML5 Canvas",

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc