Add logo to main menu

This commit is contained in:
asraelite 2018-03-02 19:37:24 +00:00
parent cfe9c55c9a
commit 435b24cb6a
15 changed files with 135 additions and 40 deletions

View file

@ -1,10 +1,24 @@
import {canvas, context} from './index.mjs';
import * as gui from '../gui/index.mjs';
export function render() {
renderElement(gui.root);
}
export function renderFrame(frame) {
context.fillStyle = '#eb9';
context.fillRect(frame.x, frame.y, frame.w, frame.h);
function renderElement(element) {
//console.log(element.options);
if (element.options.draw) {
if (element.type == 'frame') renderFrame(element);
if (element.type == 'image') renderImage(element);
}
element.children.forEach(renderElement);
}
function renderFrame(element) {
context.fillStyle = '#eb9';
context.fillRect(...element.shape);
}
function renderImage(element) {
context.drawImage(element.image, ...element.shape);
}