JSFiddle - React, Tailwind, and code Playground

by linzoey

HTML

<a>click here to download this svg!</a>

CSS

body{
background-color:white;
}

JavaScript

var draw = SVG().addTo('body').size(1920, 1080)


function buildArray(n, fillFunction) {
  let outputArray = [];
  for (let i = 0; i < n; i++) {
    outputArray.push(fillFunction(i))
  }
  return outputArray
}

class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }
  move(xDistance, yDistance) {
    return new Point(this.x + xDistance, this.y + yDistance)
  }
}

function randomInteger(min, max) {
  return Math.floor(min + ((max - min) * Math.random()))
}

function pick(inputArray) {
  return inputArray[randomInteger(0, inputArray.length)]
}

class Butterfly {
  constructor(size, point) {
    this.butterflySize = size;
    this.xPosition = point.x ;
    this.yPosition = point.y ;
    this.scaleAmount = undefined;
  }
  draw() {

    this.scaleAmount = 1.2;// + Math.random();

let rect = draw.circle(17).fill('gray').move(this.xPosition+201.5, this.yPosition+102)

let line = draw.line(10, 30, 10, 0).move(this.xPosition+210, this.yPosition+120)
line.stroke({ color: 'gray', width: 10, linecap: 'round' })

let line1 = draw.line(10, 30, 10, 0).move(this.xPosition+210, this.yPosition+155)
line1.stroke({ color: 'gray', width: 6, linecap: 'round' })

//let circle = draw.circle(70).fill('green').move(245,144)

let path = draw.path('M351,107 C435,5 480,10 460,60 C435,110 465,105 442,127 S350,105 351,107')
path.fill('white').move(this.xPosition+210, this.yPosition+50)
path.stroke({ color: 'gray', width: 3, linecap: 'round', linejoin: 'round' })

let path1 = draw.path('M329,107 C245,5 200,10 220,60 C245,110 215,105 238,127 S330,105 329,107')
path1.fill('white').move(this.xPosition+96, this.yPosition+50)
path1.stroke({ color: 'gray', width: 3, linecap: 'round', linejoin: 'round' })

let path2 = draw.path('M800,163 C830,175 825,235 785,235 S725,180 730,145')
path2.fill('none').move(this.xPosition+213, this.yPosition+137)//.rotate(10)
path2.stroke({ color: 'gray', width: 3, linecap: 'round', linejoin: 'round' })

let path3 = draw.path('M650,165.3 C620,175 625,235...