Export Image

Enter, Update, Exit

xinyuwangxyw

0 views in last 90 days
Last edited Mar 19, 2023
Created on Mar 19, 2023
Forked from Sol LeWitt with D3

A reproduction of a Sol LeWitt art piece.

  // creating a mask
  const mask_front = document.createElementNS(
    'http://www.w3.org/2000/svg',
    'mask'
  );
  mask_front.setAttribute('id', 'mask_front');
  svg.appendChild(mask_front);

  // creating a circle in this mask
  const circle = document.createElementNS(
    'http://www.w3.org/2000/svg',
    'circle'
  );
  circle.setAttribute('cx', width / 2);
  circle.setAttribute('cy', height / 2);
  circle.setAttribute('r', 250);
  circle.setAttribute('fill', "white");
  mask_front.appendChild(circle);
  
  // creating horizontal bars
  const m = 100;
  for (let i = 0; i < m; i++) {
    const rect = document.createElementNS(
      'http://www.w3.org/2000/svg',
      'rect'
    );
    rect.setAttribute('y', 20 * i);
    rect.setAttribute('width', 1000);
    rect.setAttribute('height', 10);
    rect.setAttribute("mask", "url(#mask_front)");
    svg.appendChild(rect);
  }
MIT Licensed