blog/maps/candy.min.js.map

1 line
11 KiB
Plaintext

{"version":3,"sources":["candy.js"],"names":["ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","configurable","writable","_classCallCheck","instance","Constructor","TypeError","_defineProperties","props","descriptor","_createClass","protoProps","staticProps","prototype","Circle","_ref","origin","speed","color","angle","context","this","position","renderCount","fillStyle","beginPath","arc","x","y","Math","PI","fill","sin","cos","Boom","_ref2","_ref2$circleCount","circleCount","area","stop","circles","range","floor","random","randomArray","start","end","circle","randomColor","randomRange","_this","index","width","height","splice","move","draw","CursorSpecialEffects","computerCanvas","document","createElement","renderCanvas","computerContext","getContext","renderContext","globalWidth","window","innerWidth","globalHeight","innerHeight","booms","running","e","boom","clientX","clientY","init","run","style","top","left","zIndex","pointerEvents","body","append","addEventListener","handleMouseDown","bind","handlePageHide","_this2","requestAnimationFrame","clearRect","drawImage","cursorSpecialEffects"],"mappings":"AAAA,aAEA,SAASA,QAAQC,EAAQC,GAAkB,IAAIC,EAAOC,OAAOD,KAAKF,GAAS,GAAIG,OAAOC,sBAAuB,CAAE,IAAIC,EAAUF,OAAOC,sBAAsBJ,GAASC,IAAmBI,EAAUA,EAAQC,QAAO,SAAUC,GAAO,OAAOJ,OAAOK,yBAAyBR,EAAQO,GAAKE,eAAiBP,EAAKQ,KAAKC,MAAMT,EAAMG,GAAY,OAAOH,EAE9U,SAASU,cAAcC,GAAU,IAAK,IAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAAK,CAAE,IAAIG,EAAS,MAAQF,UAAUD,GAAKC,UAAUD,GAAK,GAAIA,EAAI,EAAIf,QAAQI,OAAOc,IAAS,GAAIC,SAAQ,SAAUC,GAAOC,gBAAgBP,EAAQM,EAAKF,EAAOE,OAAYhB,OAAOkB,0BAA4BlB,OAAOmB,iBA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M7E,SAAQ,SAACgF,EAAMtB,GACxB,GAAIsB,EAAKlC,KACP,OAAOkD,EAAKnB,MAAMhB,OAAOH,EAAO,GAElCsB,EAAKlB,OACLkB,EAAKjB,UAEPnC,KAAK2C,cAAc4B,UAAUvE,KAAKqC,eAAgB,EAAG,EAAGrC,KAAK4C,YAAa5C,KAAK+C,kBA6D5EX,EA9E+B,GAqBhCoC,qBAAuB,IAAIpC,qBACjCoC,qBAAqBjB","file":"../js/candy.min.js","sourcesContent":["// Copied from [DIYgod's Hexo Theme Sagiri](https://github.com/DIYgod/diygod.me/blob/master/themes/sagiri/)\n\nclass Circle {\n constructor({ origin, speed, color, angle, context }) {\n this.origin = origin\n this.position = { ...this.origin }\n this.color = color\n this.speed = speed\n this.angle = angle\n this.context = context\n this.renderCount = 0\n }\n \n draw() {\n this.context.fillStyle = this.color\n this.context.beginPath()\n this.context.arc(this.position.x, this.position.y, 2, 0, Math.PI * 2)\n this.context.fill()\n }\n \n move() {\n this.position.x = (Math.sin(this.angle) * this.speed) + this.position.x\n this.position.y = (Math.cos(this.angle) * this.speed) + this.position.y + (this.renderCount * 0.3)\n this.renderCount++\n }\n }\n \n class Boom {\n constructor ({ origin, context, circleCount = 10, area }) {\n this.origin = origin\n this.context = context\n this.circleCount = circleCount\n this.area = area\n this.stop = false\n this.circles = []\n }\n \n randomArray(range) {\n const length = range.length\n const randomIndex = Math.floor(length * Math.random())\n return range[randomIndex]\n }\n \n randomColor() {\n const range = ['8', '9', 'A', 'B', 'C', 'D', 'E', 'F']\n return '#' + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range)\n }\n \n randomRange(start, end) {\n return (end - start) * Math.random() + start\n }\n \n init() {\n for(let i = 0; i < this.circleCount; i++) {\n const circle = new Circle({\n context: this.context,\n origin: this.origin,\n color: this.randomColor(),\n angle: this.randomRange(Math.PI - 1, Math.PI + 1),\n speed: this.randomRange(1, 6)\n })\n this.circles.push(circle)\n }\n }\n \n move() {\n this.circles.forEach((circle, index) => {\n if (circle.position.x > this.area.width || circle.position.y > this.area.height) {\n return this.circles.splice(index, 1)\n }\n circle.move()\n })\n if (this.circles.length == 0) {\n this.stop = true\n }\n }\n \n draw() {\n this.circles.forEach(circle => circle.draw())\n }\n }\n \n class CursorSpecialEffects {\n constructor() {\n this.computerCanvas = document.createElement('canvas')\n this.renderCanvas = document.createElement('canvas')\n \n this.computerContext = this.computerCanvas.getContext('2d')\n this.renderContext = this.renderCanvas.getContext('2d')\n \n this.globalWidth = window.innerWidth\n this.globalHeight = window.innerHeight\n \n this.booms = []\n this.running = false\n }\n \n handleMouseDown(e) {\n const boom = new Boom({\n origin: { x: e.clientX, y: e.clientY },\n context: this.computerContext,\n area: {\n width: this.globalWidth,\n height: this.globalHeight\n }\n })\n boom.init()\n this.booms.push(boom)\n this.running || this.run()\n }\n \n handlePageHide() {\n this.booms = []\n this.running = false\n }\n \n init() {\n const style = this.renderCanvas.style\n style.position = 'fixed'\n style.top = style.left = 0\n style.zIndex = '999999999999999999999999999999999999999999'\n style.pointerEvents = 'none'\n \n style.width = this.renderCanvas.width = this.computerCanvas.width = this.globalWidth\n style.height = this.renderCanvas.height = this.computerCanvas.height = this.globalHeight\n \n document.body.append(this.renderCanvas)\n \n window.addEventListener('mousedown', this.handleMouseDown.bind(this))\n window.addEventListener('pagehide', this.handlePageHide.bind(this))\n }\n \n run() {\n this.running = true\n if (this.booms.length == 0) {\n return this.running = false\n }\n \n requestAnimationFrame(this.run.bind(this))\n \n this.computerContext.clearRect(0, 0, this.globalWidth, this.globalHeight)\n this.renderContext.clearRect(0, 0, this.globalWidth, this.globalHeight)\n \n this.booms.forEach((boom, index) => {\n if (boom.stop) {\n return this.booms.splice(index, 1)\n }\n boom.move()\n boom.draw()\n })\n this.renderContext.drawImage(this.computerCanvas, 0, 0, this.globalWidth, this.globalHeight)\n }\n }\n \n const cursorSpecialEffects = new CursorSpecialEffects()\n cursorSpecialEffects.init()"]}