evanyou-canvas
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,2 +0,2 @@ | ||
module.exports=function(e,t){void 0===t&&(t=!0);var n=function(e){var t=document.createElement("canvas");return t.setAttribute("style","position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;pointer-events:none"),e.prepend(t),t}(e),i=function(e){var t,n=e.getContext("2d"),i=window.devicePixelRatio||1,o=window.innerWidth,r=window.innerHeight,l=90,a=Math,c=0,d=2*a.PI,u=a.cos,h=a.random;function s(){for(n.clearRect(0,0,o,r),t=[{x:0,y:.7*r+l},{x:0,y:.7*r-l}];t[1].x<o+l;)v(t[0],t[1])}function v(e,i){n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x,i.y);var o=i.x+(2*h()-.25)*l,a=function e(t){var n=t+(2*h()-1.1)*l;return n>r||n<0?e(t):n}(i.y);n.lineTo(o,a),n.closePath(),n.fillStyle="#"+(127*u(c-=d/-50)+128<<16|127*u(c+d/3)+128<<8|127*u(c+d/3*2)+128).toString(16),n.fill(),t[0]=t[1],t[1]={x:o,y:a}}return e.width=o*i,e.height=r*i,n.scale(i,i),n.globalAlpha=.6,s(),s}(n);return t&&document.addEventListener("click",i),{element:n,update:i}}; | ||
module.exports=function(e,t){void 0===t&&(t=!0),"string"==typeof e&&(e=document.querySelector(e));var n=function(e){var t=document.createElement("canvas");return t.setAttribute("style","position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;pointer-events:none"),e.prepend(t),t}(e),i=function(e){var t,n=e.getContext("2d"),i=window.devicePixelRatio||1,o=window.innerWidth,r=window.innerHeight,l=90,a=Math,c=0,d=2*a.PI,u=a.cos,h=a.random;function s(){for(n.clearRect(0,0,o,r),t=[{x:0,y:.7*r+l},{x:0,y:.7*r-l}];t[1].x<o+l;)f(t[0],t[1])}function f(e,i){n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(i.x,i.y);var o=i.x+(2*h()-.25)*l,a=function e(t){var n=t+(2*h()-1.1)*l;return n>r||n<0?e(t):n}(i.y);n.lineTo(o,a),n.closePath(),n.fillStyle="#"+(127*u(c-=d/-50)+128<<16|127*u(c+d/3)+128<<8|127*u(c+d/3*2)+128).toString(16),n.fill(),t[0]=t[1],t[1]={x:o,y:a}}return e.width=o*i,e.height=r*i,n.scale(i,i),n.globalAlpha=.6,s(),s}(n);return t&&document.addEventListener("click",i),{element:n,update:i}}; | ||
//# sourceMappingURL=evanyou-canvas.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.evanyouCanvas=n()}(this,function(){return function(e,n){void 0===n&&(n=!0);var t=function(e){var n=document.createElement("canvas");return n.setAttribute("style","position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;pointer-events:none"),e.prepend(n),n}(e),i=function(e){var n,t=e.getContext("2d"),i=window.devicePixelRatio||1,o=window.innerWidth,r=window.innerHeight,d=90,a=Math,u=0,c=2*a.PI,l=a.cos,f=a.random;function s(){for(t.clearRect(0,0,o,r),n=[{x:0,y:.7*r+d},{x:0,y:.7*r-d}];n[1].x<o+d;)h(n[0],n[1])}function h(e,i){t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(i.x,i.y);var o=i.x+(2*f()-.25)*d,a=function e(n){var t=n+(2*f()-1.1)*d;return t>r||t<0?e(n):t}(i.y);t.lineTo(o,a),t.closePath(),t.fillStyle="#"+(127*l(u-=c/-50)+128<<16|127*l(u+c/3)+128<<8|127*l(u+c/3*2)+128).toString(16),t.fill(),n[0]=n[1],n[1]={x:o,y:a}}return e.width=o*i,e.height=r*i,t.scale(i,i),t.globalAlpha=.6,s(),s}(t);return n&&document.addEventListener("click",i),{element:t,update:i}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.evanyouCanvas=t()}(this,function(){return function(e,t){void 0===t&&(t=!0),"string"==typeof e&&(e=document.querySelector(e));var n=function(e){var t=document.createElement("canvas");return t.setAttribute("style","position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;pointer-events:none"),e.prepend(t),t}(e),o=function(e){var t,n=e.getContext("2d"),o=window.devicePixelRatio||1,i=window.innerWidth,r=window.innerHeight,d=90,u=Math,a=0,c=2*u.PI,l=u.cos,f=u.random;function s(){for(n.clearRect(0,0,i,r),t=[{x:0,y:.7*r+d},{x:0,y:.7*r-d}];t[1].x<i+d;)y(t[0],t[1])}function y(e,o){n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(o.x,o.y);var i=o.x+(2*f()-.25)*d,u=function e(t){var n=t+(2*f()-1.1)*d;return n>r||n<0?e(t):n}(o.y);n.lineTo(i,u),n.closePath(),n.fillStyle="#"+(127*l(a-=c/-50)+128<<16|127*l(a+c/3)+128<<8|127*l(a+c/3*2)+128).toString(16),n.fill(),t[0]=t[1],t[1]={x:i,y:u}}return e.width=i*o,e.height=r*o,n.scale(o,o),n.globalAlpha=.6,s(),s}(n);return t&&document.addEventListener("click",o),{element:n,update:o}}}); | ||
//# sourceMappingURL=evanyou-canvas.umd.js.map |
{ | ||
"name": "evanyou-canvas", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"main": "dist/evanyou-canvas.umd.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/evanyou-canvas.mjs", |
@@ -8,6 +8,5 @@ # evanyou-canvas | ||
```js | ||
const evanyouCanvas = require("evanyou-canvas"); | ||
const ec = require("evanyou-canvas"); | ||
const parentElement = document.querySelector("#parent"); | ||
const { element, update } = evanyouCanvas(parentElement); | ||
const { element, update } = ec("#parent"); // selector or element | ||
@@ -14,0 +13,0 @@ // element: canvas element |
export default function evanyouCanvas(parentElement, documentClick = true) { | ||
if (typeof parentElement === "string") { | ||
parentElement = document.querySelector(parentElement); | ||
} | ||
const element = create(parentElement); | ||
@@ -3,0 +6,0 @@ const update = drawCanvas(element); |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16875
90
15