diff --git a/rfid/index.html b/rfid/index.html index 44bd87b..a461bd7 100644 --- a/rfid/index.html +++ b/rfid/index.html @@ -47,7 +47,7 @@ - + diff --git a/rfid/js/helper.js b/rfid/js/helper.js index f34034d..4c872dc 100644 --- a/rfid/js/helper.js +++ b/rfid/js/helper.js @@ -27,11 +27,12 @@ async function fetchConfig(className) { { type: "range", min: 240, max: 240, defaultValue: 240, property: "width" }, { type: "color", defaultValue: "#4287f5", property: "colour1" }, ], - FloralPhyllo_Accident: [ - { type: "range", min: 1, max: 50, defaultValue: 20, property: "sides" }, - { type: "range", min: 240, max: 240, defaultValue: 240, property: "width" }, - { type: "color", defaultValue: "#2D81FC", property: "colour1" }, - { type: "color", defaultValue: "#FC0362", property: "colour2" }, + NewWave: [ + { type: "range", min: 300, max: 600, defaultValue: 342, property: "width" }, + { type: "range", min: 2, max: 40, defaultValue: 4, property: "sides" }, + { type: "range", min: 1, max: 100, defaultValue: 1, property: "step" }, + { type: "range", min: 3, max: 5, defaultValue: 4, property: "lineWidth" }, + { type: "range", min: 100, max: 1000, defaultValue: 100, property: "limiter" }, ], Nodal_expanding: [ { type: "range", min: 10, max: 10, defaultValue: 10, property: "expand" }, diff --git a/rfid/js/index.js b/rfid/js/index.js index 712d866..a178896 100644 --- a/rfid/js/index.js +++ b/rfid/js/index.js @@ -1,5 +1,5 @@ //jshint esversion:8 -var seed = cyrb128("813311281"); +var seed = cyrb128("813311293"); var rand = sfc32(seed[0], seed[1], seed[2], seed[3]); // var gateway = `ws://192.168.1.184/ws`; @@ -68,6 +68,7 @@ const classMap = { EyePrototype: EyePrototype, CircleExpand: CircleExpand, MaryFace: MaryFace, + NewWave:NewWave, // Add more class constructors here as needed }; function createInstance(className, args) { diff --git a/rfid/js/objects.js b/rfid/js/objects.js index 0deb2cb..fcfe9cb 100644 --- a/rfid/js/objects.js +++ b/rfid/js/objects.js @@ -678,3 +678,40 @@ class MaryFace extends BaseShape { } } +class NewWave extends BaseShape { + constructor(width,sides,step,lineWidth,limiter) { + super(); + this.width = width + this.sides = sides; + this.step = step; + this.lineWidth = lineWidth; + this.limiter = limiter; + } + + draw(rotation) { + rotation *= this.speedMultiplier/400 + ctx.lineWidth = this.lineWidth + for (let j = 0; j < this.sides; j++) { + const radRotation = rad(360/this.sides*j) + const inverter = 1-(j%2)*2 + let lastX = centerX + let lastY = centerY + for (let i = 0; i < this.width; i += this.step) { + + ctx.beginPath(); + ctx.moveTo(lastX, lastY); + ctx.strokeStyle = colourToText(lerpRGB([255,51,170],[51,170,255],i/this.width)) + const x = i + const y = (Math.sin(-i*inverter / 30 + rotation*inverter) * i/(this.limiter/100)) + + const xRotated = x * Math.cos(radRotation) - y * Math.sin(radRotation) + const yRotated = x * Math.sin(radRotation) + y * Math.cos(radRotation) + lastX= centerX + xRotated; + lastY= centerY + yRotated; + ctx.lineTo(centerX + xRotated, centerY + yRotated); + ctx.stroke(); + } + } + + } +}