fun with canvas

In this example below you will see how to do a fun with canvas with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by -dan, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright -dan ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>fun with canvas</title>
  
  
  
  
  
</head>

<body>

  <canvas id='bar'></canvas>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'></script>

  

    <script type="module" src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/-dan/fun-with-canvas-JLPGWo */
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

//pure
//impure
var createElement = function createElement(tag) {
  return document.createElement(tag);
};
var createCanvas = function createCanvas() {
  return createElement("canvas");
};
var addChild = function addChild(parent) {
  return function (child) {
    return parent.appendChild(child);
  };
};
var addChildToBody = addChild(document.body);
var setWidth = function setWidth(width) {
  return function (el) {
    return _extends({}, el, { width: width });
  };
};
var returnSameElement = function returnSameElement(el) {
  return _extends({}, el);
};

var c = document.getElementById('bar');

console.log(c);
console.log(returnSameElement(c));

var init = compose(addChildToBody, compose(setWidth(100), createCanvas));

init();

Comments