This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const e2d = require('e2d'); | |
const canvas = document.createElement('canvas'); | |
canvas.width = 400; | |
canvas.height = 300; | |
document.body.appendChild(canvas); | |
const ctx = canvas.getContext('2d'); | |
e2d.initialize(ctx); | |
e2d.raf(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const e2d = require('e2d'); | |
const ctx = document.createElement('canvas').getContext('2d'); | |
ctx.canvas.width = 500; | |
ctx.canvas.height = 500; | |
e2d.initialize(ctx); | |
document.body.appendChild(ctx.canvas); | |
const count = 5; | |
const radius = 10; | |
let spacing = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const e2d = require('e2d'); | |
const ctx = document.createElement('canvas').getContext('2d'); | |
ctx.canvas.width = 500; | |
ctx.canvas.height = 500; | |
e2d.initialize(ctx); | |
document.body.appendChild(ctx.canvas); | |
const patternRadius = 100; | |
const bulletRadius = 10; | |
const bulletCount = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//promisify.js | |
module.exports = (func, bound = null) => (...args) => new Promise( | |
(resolve, reject) => func.call(bound, ...args, (err, ...results) => err ? reject(err) : resolve(...results)) | |
); | |
/**************************************************************************************** | |
* This function is used to turn a callback style function into an await(able) result. | |
* | |
* For example, fs.readFile takes two parameters: fs.readFile(name, callback); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let canvas = document.createElement('canvas'); | |
canvas.width = 800; | |
canvas.height = 600; | |
//get the canvas context | |
let ctx = canvas.getContext('2d'); | |
//add it to the dom | |
document.body.appendChild(canvas); | |
e2d.raf( | |
() => <render ctx={ctx}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let canvas = document.createElement('canvas'); | |
canvas.width = 800; | |
canvas.height = 600; | |
//get the canvas context | |
let ctx = canvas.getContext('2d'); | |
//add it to the dom | |
document.body.appendChild(canvas); | |
e2d.raf( | |
() => e2d.render( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let r = new e2d.Render(width, height); | |
r.ready(); | |
r.on('frame', () => r.render( | |
e2d.clearRect(width, height), | |
e2d.fillText("Hello World!", 100, 100) | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let React = require('react'); | |
let ReactDOM = require('react-dom'); | |
let DOM = React.DOM; | |
let outsideText = "testing the text put inside the span"; | |
let App = class App extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
index: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var e2d = require('e2d'); | |
var r = e2d.Renderer.create(800, 600); | |
var cookie = new e2d.Img(); | |
var cookieShape; | |
cookie.src = 'http://piecrust.org/wp-content/uploads/2016/03/Cookie1.gif'; | |
cookie.on('load', function() { | |
cookieShape = e2d.createRegularPolygon(cookie.width / 2, [0, 0], 100); | |
console.log(cookieShape); |