Skip to main content
Public

Share visualization

Loading preview…

Sol Lewitt in Vanilla JS

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Sol Lewitt in Vanilla JS

0
JJaga-droid
Last edited Feb 5, 2023
Created on Feb 4, 2023
Forked from SVG Fundamentals

This piece reproduces a Sol Lewitt art concept using a generative, animated SVG composition. It displays a rotating triangular mask that reveals or conceals a grid of horizontal and vertical lines, creating a dynamic interplay of shapes. Rendered entirely in vanilla JavaScript, the code dynamically creates SVG elements via `createElementNS`, building a responsive full-window graphic. The animation is driven by CSS keyframes, while two distinct SVG masks, one inverting the other, control the visibility of the line grid, producing a clean, geometric visual effect.

AI-generated description

A reproduction of a Sol Lewitt art piece, in this case, a triangle(animated)

Notes:

  1. No CreateElement with SVG :

    • SVG is an XML(Xtensible Markup Language)-based language.
    • When parsing HTML you can create SVG elements as long as you use <svg> and </svg> correctly
    • SVG elements cannot be dynamically created using CreateElement in the same way as HTML elements.
    • use createElementNS where NS-> NameSpace.
    • i.e. document.createElementNS('http://www.w3.org/2000/svg', 'svg')
  2. Innerheight and Innerwidth :

    • Adjusts height and width based on browser window size.
    • window in window.innerHeight is an alias for the global object so even just using 'innerHeight' is fine unless you use a build tool which will then throw an error saying that innerHeight is not defined.
  3. const and let :

    • Both are block-scoped and not closure-scoped(which is like var, i.e. global scope). -block-scope: scope of variable restricted to the scope in which it was defined(local)
  4. SVG Mask :

    • The SVG masking feature makes it possible to apply a mask to an SVG shape. The mask determines what parts of the SVG shape that is visible, and with what transparency. You can think of an SVG mask as a more advanced version of a clip path.
    • For this example, we will have a black background and a white circle and a white background and black circle to invert the mask

Comments

Sign in to join the discussion.

MIT Licensed