It's a shame! - 02

In this example below you will see how to do a It's a shame! - 02 with some HTML / CSS and Javascript

The original cartoon was a cover of SPIEGEL - see info. Instead of a naive girl, I used EGON as the protagonist.

Thumbnail
This awesome code was written by mikeK, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright mikeK ©
  • HTML
  • CSS
  • JavaScript
    
<canvas id="canvas"  width="500" height="500"></canvas>
<canvas id="myCanvas"  width="500" height="500"></canvas>
<svg xmlns="http://www.w3.org/2000/svg" id="svg3945" width="355" height="497">
   <defs id="defs4">
    <filter id="filter3814" width="2.407" height="1.176" x="-.704" y="-.088">
      <feGaussianBlur id="feGaussianBlur3816" stdDeviation="5.361"/>
    </filter>
  </defs>
  <g id="layer1" transform="translate(-63.068 -442.344)">
    <path id="path4314" fill="#f8c699" stroke="#0e1111" stroke-opacity=".675" stroke-width="2.539" d="M307.439 833.249c-.037 7.573-.8 31.4-4.618 36.705 8.554 6.86 4.645 11.802 2.691 17.045-26.626 3.853-31.62 3.566-54.83 3.81-4.64.695-12.12-1.493-4.143-4.75-1.195-1.238-.421-2.816 2.787-3.433.226.453-2.802-2.58-1.157-4.037-6.58.13-2.44-11.33 5.642-3.878l6.47 1.186c14.975 3.002 16.972-3.252 33.569-3.252l2.375-43.882"/>
    <path id="path4302" fill="#f8c699" stroke="#0e1111" stroke-opacity=".675" stroke-width="2.539" d="M351.266 702.94c19.763 15.637 20.174 75.016 17.494 97.74-8.663 12.867-10.868 32.194-29.156 35.436 1.723 10.018 4.457 26.414 1.345 36.432 13.198 9.187 13.35 21.705-8.945 23.733-18.928-.483-24.938 2.35-43.108-.408-4.838-.545-4.637-.895-8.672-2.243-1.741-1.495-2.525-2.039 1.187-3.534-.897-.48-2.213 3.253-2.533-2.746-1.097-1.325 4.873-2.748 2.343-4.297-1.483-.176-2.968-2.568-3.24-5.571.582-2.476 1.126-4.97 5.831-5.383 3.715.389 3.783 3.505 7.498 3.88 16.47 1.664 22.534 8.473 39.005 1.703l-.132-44.257c-18.416 2.578-49.313-2.675-49.79-20.635-.608-22.813 3.243-77.245 23.931-103.199"/>

    <g id="xxx" transform="matrix(1.05158 -.1548 .1548 1.05158 252.62 206.616)">
      <g id="xx" transform="matrix(-4.88239 0 0 4.88239 1356.99 -2028)">
        <path id="augeLinks" class="augen" fill="#ede2d5" stroke="#0e1111" stroke-opacity=".997" stroke-width=".372" d="M279.793 490.118c0 1.439-.979 2.606-2.187 2.606-1.207 0-2.186-1.167-2.186-2.606 0-1.44.979-2.606 2.186-2.606 1.208 0 2.187 1.166 2.187 2.606z"/>
        <path id="path4233" fill="#f8c699" stroke="#0e1111" stroke-opacity=".675" stroke-width=".412" d="M275.913 514.235c-5.955-.128-6.826-10.424-8.737-18.639l-2.33-12.231 7.863.145c1.722 1.683 3.325 4.2 4.66 8.592 8.66 2.293 6.558 3.51 3.786 4.66 1.406 4.872 4.3 8.576.583 17.473"/>
        <path id="augeRechts" class="augen" fill="#fbefdb" stroke="#0e1111" stroke-opacity=".997" stroke-width=".813" d="M848.837 579.357c0 3.932-3.132 7.12-6.995 7.12s-6.994-3.188-6.994-7.12 3.131-7.12 6.994-7.12 6.995 3.188 6.995 7.12z" transform="matrix(.4153 0 0 .49257 -75.968 205.668)"/>
        <path id="path4257" fill="#0f1313" stroke="#000" stroke-width=".412" d="M267.54 494.14l-1.092 1.893c-4.458-1.993-2.828-5.094-3.422-7.79-.27-.943-1.113-1.217-2.548-.801l-.073-.947 1.165-1.237-.291-3.35c2.4 2.68 3.502.973 4.368-1.529 8.473-4.673 6.375-2.429 4.441-.29l5.752.946.146 1.02h-3.277l2.04 1.455c-3.485-.29-6.83.393-10.121 1.456.722 1.237 2.206.444 1.893 4.442l1.02 4.878"/>
        <path id="path4235" fill="#f8c699" stroke="#000" stroke-width=".412" d="M268.341 495.16c-5.385-1.021-5.237 5.226.874 2.184"/>
        <path id="pupilleRechts" class="pupille" fill="#0f1313" d="M877.718 574.908c0 .488-.633.883-1.413.883s-1.414-.395-1.414-.883.633-.883 1.414-.883c.78 0 1.413.395 1.413.883z" transform="matrix(.37725 0 0 .35861 -56.394 286.332)"/>
        <path id="pupilleLinks" class="pupille" fill="#0f1313" d="M877.718 574.908c0 .488-.633.883-1.413.883s-1.414-.395-1.414-.883.633-.883 1.414-.883c.78 0 1.413.395 1.413.883z" transform="matrix(.37725 0 0 .35861 -52.486 284.985)"/>
      </g>
      <path id="mund" fill="none" stroke="#0e1111" stroke-opacity=".675" stroke-width="2.126" d="M-27.714 446.732c11.544-4.451 9.235-11.12 20.78-1.54"/>
    </g>
    <path id="rect3043" fill="#50dfff" stroke="#fff" stroke-dashoffset="14" stroke-linecap="round" d="M184.211 600.986l16 8 2.286 123.429-14.857 14.857z" filter="url(#filter3814)" transform="matrix(.8913 0 0 .9838 18.595 -3.435)"/>
    <path id="path3818" fill="#454342" d="M186.37 738.476l72.127 3.932-.739 5.571-71.596 3.865z"/>
    <path id="rect3820" fill="#a1a19f" d="M201.914 736.274l5.357.234-.264 3.09-5.357-.234z"/>
    <path id="rect3820-4" fill="#a1a19f" d="M224.585 737.42l5.357.233-.264 3.09-5.357-.234z"/>
    <path id="rect3820-5" fill="#a1a19f" d="M217.095 737.036l5.358.233-.264 3.09-5.358-.234z"/>
    <path id="rect3820-51" fill="#a1a19f" d="M209.605 736.652l5.358.234-.264 3.09-5.358-.234z"/>
    <path id="rect3820-5-7" fill="#a1a19f" d="M231.873 737.81l5.357.233-.264 3.09-5.357-.234z"/>
    <path id="arm" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-opacity=".676" stroke-width="2.795" d="M352.206 725.173l-12.21 48.417-9.006 35.714.69 11.855c-2.386 7.824-7.71 11.807-3.973 1.455-3.559 5.053-7.639 9.84-5.215-2.223-4.28 10.768-5.992 8.258-5.423-.918-3.137 10.32-14.337 17.51-5.375-5.658l4.977-9.576c6.053-9.21 11.958-27.09 15.251-39.75 3.716-14.282 4.548-23.683 6.835-39.751"/>
    <path id="arm02" class="hidden" fill="#f8c699" stroke="#0e1111" stroke-linejoin="round" stroke-opacity=".676" stroke-width="2.795" d="M352.068 724.633l-12.21 48.416-69.39-44.589-.926 2.159c-2.386 7.824-7.71 11.806-3.972 1.454-3.56 5.054-7.64 9.84-5.216-2.223-4.28 10.769-5.992 8.258-5.423-.918-3.137 10.32-14.337 17.51-5.375-5.658l4.977-9.576c6.053-9.209 75.574 45.94 78.868 33.28 3.715-14.282 2.93-6.713 5.218-22.781"/>
  </g>
</svg>

<div id="info">i</div>
<div id="infoContent">
  <img id="cover" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/174563/SPIEGELcover.jpg" />
  
</div>

/*Downloaded from https://www.codeseek.co/mikeK/itandaposs-a-shame-02-aYPGBz */
    body{
  width:100%;
  height:100%;
  background:#3b5998;
  margin:0;
  overflow:hidden;
}
canvas{
  position:absolute;
  left:50px;
}
svg{
  position:absolute;
  left: 55px;
  top: 12px;
  visibility:hidden;
}
.hidden{
  visibility:hidden;
}
#info{
  position: absolute;
  left: auto;
  right: 10px;
  top: 20px;
  width: 25px;
  height: 25px;
  padding: 3px;
  font-size: 20px;
  border: 1px solid black;
  border-radius: 25px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
}
#infoContent{
  position: absolute;
  height:100%;
  width:100%;
  padding: 10px;
  background:grey;
  z-index: 1;
  visibility:hidden;
}
#cover{
  height: 94%;
  max-height: 500px;
}


/*Downloaded from https://www.codeseek.co/mikeK/itandaposs-a-shame-02-aYPGBz */
    //support by  https://codepen.io/osublake/pen/rdoyXL 

var numFrames = 5;
var frameDelay = 0.1;
var frameIndex = 0;
var frames = [];

var rc = rough.canvas(document.getElementById('canvas'));
var generator = rc.generator;

for (var i = 0; i < numFrames; i++) {
  frames.push(createShapes());
}

function theLeech(theLeechAmount) {
  var tl = new TimelineMax();
  for (var i = 0; i < theLeechAmount; i++){
    tl.to({}, frameDelay, {repeat:2, onRepeat: draw});
  }
  return tl;
}


draw();

function draw() {
  
  rc.ctx.clearRect(0, 0, rc.canvas.width, rc.canvas.height);
  
  var shapes = frames[frameIndex++ % numFrames];
  
  for (var i = 0; i < shapes.length; i++) {
    rc.draw(shapes[i]);
  }
}
function createShapes() {
    
  var path1 = generator.path( 'M216.928 85.287c-12.259 39.103-6.371 36.339-24.726.37-6.764 36.38-7.884 30.685-14.787 3.848-5.133 22.265-3.14 38.074-19.086.824 3.894 34.578 1.44 35.25-16.338 6.73 9.112 23.625 5.827 28.456-11.137 8.97 6.767 16.918 18.927 28.006-5.497 16.844 11.872 10.378 12.382 8.697-8.595 7.363C75.214 82.02 224.058 62.542 216.928 85.287z', { roughness: 1, fill: 'white', fillStyle: 'solid' });
  
  var path2 = generator.path( 'M14.15 467.764c6.53 0 284.081 2.177 284.081 2.177l-286.258 3.265 281.905-2.177L0 479.736l290.612-8.707', { roughness: 2.6, fill: 'black', strokeWidth: 2 });
  
  var path3 = generator.path('M223.654 20.018C117.705 8.303 55.071 46.743 59.3 162.603l6.531 162.177H27.736L31 373.76l34.83 3.265 5.442 95.782 55.51-2.177-4.353-94.694 89.251-7.619-7.619-48.98-84.898 4.355v-181.77c-.398-60.674 58.227-51.908 104.49-57.686z', { roughness: 2.6, fill: 'white', fillStyle: 'solid', strokeWidth: 2 });

  var path4 = generator.path( 'M186.656 58.222a29.932 20.952 0 1 1-.002-.059', { roughness: 1, fill: 'white', fillStyle: 'solid' });

  var path5 = generator.path( 'M-94.675 216.842c-3.352-.23-6.793.146-9.623 2.09-3.303 1.42-7.517 1.235-9.844 4.407-1.803 1.917-2.783 3.834-3.424 6.32-1.568 3.71-2.262 7.7-2.176 11.723.054 3.522-.595 7.325 1.497 10.454 1.268 2.833 3.402 5.098 5.755 7.08 2.223 1.753 4.632 3.355 7.168 4.597 3 1.428 5.89 2.628 9.253 2.501 2.809.516 5.625.314 8.423.86 2.66.105 5.435.258 8.012-.448 2.75-1.074 4.796-3.258 6.717-5.386 2.684-2.078 6.042-3.872 7.029-7.386 1.188-2.844 2.528-5.629 3.131-8.685.304-2.908.427-5.976-.355-8.83-1.001-2.658-1.885-5.356-3.203-7.84-1.724-3.129-4.298-5.728-6.836-8.21-2.417-1.914-5.344-3.095-8.142-4.337a31.734 31.734 0 0 0-8.781-.49c-1.669.126-3.047 1.091-4.6 1.58z', {});
  
  var path6 = generator.path( 'M172.8 67.062a10.765 8.869 72.058 1 1-.01-.029', { fill: 'black', fillStyle: 'solid'});
  
  var path7 = generator.path( 'M145.96 15.766l34.526 53.419-27.36-48.858 28.011 47.555-25.056-56.633 29.901 55.172-21.81-47.761 18.466 51.293-14.356-58.035');
  
  return [path1, path2, path3, path4, path5, path6, path7];
}


//====  svg ====================

TweenMax.set("svg",{autoAlpha:1, delay:1})

function tippen(tippAmount) {
  var tl = new TimelineMax();
  for (var i = 0; i < tippAmount; i++){
    tl.to("#arm", random(0.1, 0.6), {rotation:-1,x: random(-23,-15),  transformOrigin: "right top", repeat:1, yoyo:true, ease:Sine.easeInOut})
    .to(".pupille",random(0.1, 0.4),{xPercent:random(20,0), yPercent:random(10,0)})
  }
  return tl;
}

var main = new TimelineMax()
//.to(".pupille",0.5,{rotation:-8, transformOrigin:"center -20px"},3)
.to(".pupille",0.5,{xPercent:22},2.5)
.to("#arm",2, {morphSVG:"#arm02", x:-20, ease: Power3.easeOut},3)
.add(tippen(10))
.add(theLeech(15))
.to("#arm",1, {morphSVG:"#arm", x:0, ease: Power3.easeOut})
.to("#mund",0.5,{rotation:30, x:4, transformOrigin:"left top "})
.to(".pupille",0.5,{xPercent:-20})


function random(min, max) {
  if (max == null) {max = min;min = 0;}
  return Math.random() * (max - min) + min;
}


// ====  info ===============================
TweenMax.set("#infoContent", {autoAlpha:1, scale:0});

var $button = $('#info'),
    $info = $('#infoContent');

var action = new TimelineMax({paused:true})
  .to($info, 0.8, {scale:1, transformOrigin:"top left"})

$button.on('mouseenter', function(e) {
  action.play();
});
$button.on('mouseout', function(e) {
  action.reverse();
});

Comments