This commit is contained in:
Sam 2023-12-30 12:25:15 +13:00
commit 87d5dc634d
4 changed files with 46 additions and 7 deletions

View File

@ -47,7 +47,7 @@
</div> </div>
</body> </body>
<script src="./js/helper.js" type="text/javascript"></script> <script src="./js/helper.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<script src="./js/math.js" type="text/javascript"></script> <script src="./js/math.js" type="text/javascript"></script>
<script src="./js/objects.js" type="text/javascript"></script> <script src="./js/objects.js" type="text/javascript"></script>
<script src="./js/index.js"></script> <script src="./js/index.js"></script>

View File

@ -27,11 +27,12 @@ async function fetchConfig(className) {
{ type: "range", min: 240, max: 240, defaultValue: 240, property: "width" }, { type: "range", min: 240, max: 240, defaultValue: 240, property: "width" },
{ type: "color", defaultValue: "#4287f5", property: "colour1" }, { type: "color", defaultValue: "#4287f5", property: "colour1" },
], ],
FloralPhyllo_Accident: [ NewWave: [
{ type: "range", min: 1, max: 50, defaultValue: 20, property: "sides" }, { type: "range", min: 300, max: 600, defaultValue: 342, property: "width" },
{ type: "range", min: 240, max: 240, defaultValue: 240, property: "width" }, { type: "range", min: 2, max: 40, defaultValue: 4, property: "sides" },
{ type: "color", defaultValue: "#2D81FC", property: "colour1" }, { type: "range", min: 1, max: 100, defaultValue: 1, property: "step" },
{ type: "color", defaultValue: "#FC0362", property: "colour2" }, { type: "range", min: 3, max: 5, defaultValue: 4, property: "lineWidth" },
{ type: "range", min: 100, max: 1000, defaultValue: 100, property: "limiter" },
], ],
Nodal_expanding: [ Nodal_expanding: [
{ type: "range", min: 10, max: 10, defaultValue: 10, property: "expand" }, { type: "range", min: 10, max: 10, defaultValue: 10, property: "expand" },

View File

@ -1,5 +1,5 @@
//jshint esversion:8 //jshint esversion:8
var seed = cyrb128("813311281"); var seed = cyrb128("813311293");
var rand = sfc32(seed[0], seed[1], seed[2], seed[3]); var rand = sfc32(seed[0], seed[1], seed[2], seed[3]);
// var gateway = `ws://192.168.1.184/ws`; // var gateway = `ws://192.168.1.184/ws`;
@ -68,6 +68,7 @@ const classMap = {
EyePrototype: EyePrototype, EyePrototype: EyePrototype,
CircleExpand: CircleExpand, CircleExpand: CircleExpand,
MaryFace: MaryFace, MaryFace: MaryFace,
NewWave:NewWave,
// Add more class constructors here as needed // Add more class constructors here as needed
}; };
function createInstance(className, args) { function createInstance(className, args) {

View File

@ -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();
}
}
}
}