painbrush
1.0.21.1.0
src/layer/make-rectangle.js+
src/layer/make-rectangle.jsNew file+28
Index: package/src/layer/make-rectangle.js
===================================================================
--- package/src/layer/make-rectangle.js
+++ package/src/layer/make-rectangle.js
@@ -0,0 +1,28 @@
+import { COLOR_BLACK } from "../color/utils.js";
+import { solidFillBrush, alphaBrush, } from "../color/brush.js";
+/**
+This makes a rectangle with any fill.
+Useful for the initial canvas
+*/
+export const makeRectangleLayer = ({ x: width, y: height }, brush = solidFillBrush(COLOR_BLACK)) => {
+ let data = [];
+ const meta = {
+ width,
+ id: Math.random(),
+ height,
+ };
+ for (let index = 0; index < width * height * 3; index = index + 3) {
+ const color = brush(index, meta);
+ data.push(color[0]);
+ data.push(color[1]);
+ data.push(color[2]);
+ }
+ return {
+ ...meta,
+ data,
+ };
+};
+/**
+ * Utility method to make a blank rectangle, makes a great bg
+ */
+export const makeBlankLayer = (coords) => makeRectangleLayer(coords, alphaBrush());