simple background colors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {noop} from './utils.js';
|
||||
import {getColor, noop} from './utils.js';
|
||||
|
||||
export default class Sketch {
|
||||
constructor (settings) {
|
||||
@@ -6,8 +6,9 @@ export default class Sketch {
|
||||
|
||||
[
|
||||
'getContext',
|
||||
'background',
|
||||
'onResize',
|
||||
'render'
|
||||
'render',
|
||||
].map(method => this[method] = this[method].bind(this));
|
||||
|
||||
this.draw = settings.draw || noop;
|
||||
@@ -32,6 +33,14 @@ export default class Sketch {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
background ({red, green, blue, alpha}) {
|
||||
this.context.beginPath();
|
||||
this.context.rect(0, 0, this.canvas.width, this.canvas.height);
|
||||
this.context.fillStyle = getColor({red, green, blue, alpha});
|
||||
this.context.closePath();
|
||||
this.context.fill();
|
||||
}
|
||||
|
||||
onResize (event) {
|
||||
const width = this.container.offsetWidth;
|
||||
const height = this.container.offsetHeight;
|
||||
|
||||
Reference in New Issue
Block a user