3

random duotone - all SVG + JS

 2 years ago
source link: https://codepen.io/andyfitz/pen/KKvXJpo
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
0 unsaved changes
xxxxxxxxxx

CSS (SCSS)

CSS (SCSS)

xxxxxxxxxx
body{background-color:#2f3135; display:grid; margin:0; place-items:center; height:100vh; cursor:pointer;}
svg{width: 100vw; height:100vh}
xxxxxxxxxx
var lightColors = ["#6aadff", "#0fda90", "#ff6157", "#f8df4d", "#d37e35"];
var darkColors = ["#22272f", "#1c2f29", "#1c4134", "#2f1c1c"];
var stage = document.querySelector('body');
function drawImages() {
  var searchTerm = "ocean";
  function hexToRgb(hex) {
    // Expand shorthand form (e.g. "FA7") to full form (e.g. "FFAA77")
    var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
    hex = hex.replace(shorthandRegex, function (m, r, g, b) {
      return r + r + g + g + b + b;
    });
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
          r: parseInt(result[1], 16),

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK