graphico 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canvas.js CHANGED
@@ -61,7 +61,7 @@ var Canvas = /** @class */ (function () {
61
61
  // Create canvas layers
62
62
  for (var i = 0; i < this.config.numLayers; i++) {
63
63
  var canvas = document.createElement('canvas');
64
- var graphics = canvas.getContext('2d', { 'willReadFrequently': this.config.acceleration === 'software' });
64
+ var graphics = canvas.getContext('2d');
65
65
  if (graphics) {
66
66
  this.graphics.push(graphics);
67
67
  }
@@ -170,16 +170,11 @@ var Canvas = /** @class */ (function () {
170
170
  */
171
171
  Canvas.prototype.animate = function (time) {
172
172
  var _this = this;
173
- var _a;
174
173
  var currentFrame = time;
175
174
  var dt = currentFrame - this.lastFrame;
176
175
  this.lastFrame = currentFrame;
177
176
  this.log('animate', dt, currentFrame);
178
- var drawables = (_a = this.config.loop(dt)) !== null && _a !== void 0 ? _a : [];
179
- for (var _i = 0, drawables_1 = drawables; _i < drawables_1.length; _i++) {
180
- var drawable = drawables_1[_i];
181
- this.draw(drawable);
182
- }
177
+ this.config.loop(dt);
183
178
  this.animation = requestAnimationFrame(function (time) { return _this.animate(time); });
184
179
  };
185
180
  /**
@@ -205,37 +200,6 @@ var Canvas = /** @class */ (function () {
205
200
  Canvas.prototype.getMousePosition = function () {
206
201
  return [this.mouseX, this.mouseY];
207
202
  };
208
- /**
209
- * Get the color of the selected pixel.
210
- * @param x The pixel's x-coordinate
211
- * @param y The pixel's y-coordinate
212
- * @param layer The zero-indexed layer to get data from
213
- * @returns `[red, green, blue, alpha]`
214
- */
215
- Canvas.prototype.getPixel = function (x, y, layer) {
216
- if (layer === void 0) { layer = 0; }
217
- var data = this.graphics[layer].getImageData(x, y, 1, 1).data;
218
- this.log(this.graphics[layer].getImageData(x, y, 2, 2));
219
- ;
220
- return [data[0], data[1], data[2], data[3]];
221
- };
222
- /**
223
- * Set the color of the selected pixel.
224
- * @param x The pixel's x-coordinate
225
- * @param y The pixel's y-coordinate
226
- * @param color `[red, green, blue, alpha]`
227
- * @param layer The zero-indexed layer to set data to
228
- */
229
- Canvas.prototype.setPixel = function (x, y, color, layer) {
230
- if (layer === void 0) { layer = 0; }
231
- var data = this.graphics[layer].getImageData(x, y, 1, 1);
232
- data.data[0] = color[0];
233
- data.data[1] = color[1];
234
- data.data[2] = color[2];
235
- data.data[3] = color[3];
236
- this.log(data);
237
- this.graphics[layer].putImageData(data, x, y);
238
- };
239
203
  /**
240
204
  * Take a screenshot of the canvas contents and save to a .png file.
241
205
  * @param name The file name of the screenshot
@@ -329,7 +293,6 @@ var Canvas = /** @class */ (function () {
329
293
  borderBlur: 'transparent',
330
294
  showMouse: true,
331
295
  numLayers: 1,
332
- acceleration: 'hardware',
333
296
  keydown: function () { return; },
334
297
  keyup: function () { return; },
335
298
  mousemove: function () { return; },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphico",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Canvas 2D rendering toolkit for games and visual projects",
5
5
  "homepage": "https://npm.nicfv.com/",
6
6
  "bin": "",
package/types/canvas.d.ts CHANGED
@@ -80,22 +80,6 @@ export declare class Canvas {
80
80
  * @returns Cursor position as `[x, y]`
81
81
  */
82
82
  getMousePosition(): [number, number];
83
- /**
84
- * Get the color of the selected pixel.
85
- * @param x The pixel's x-coordinate
86
- * @param y The pixel's y-coordinate
87
- * @param layer The zero-indexed layer to get data from
88
- * @returns `[red, green, blue, alpha]`
89
- */
90
- getPixel(x: number, y: number, layer?: number): [number, number, number, number];
91
- /**
92
- * Set the color of the selected pixel.
93
- * @param x The pixel's x-coordinate
94
- * @param y The pixel's y-coordinate
95
- * @param color `[red, green, blue, alpha]`
96
- * @param layer The zero-indexed layer to set data to
97
- */
98
- setPixel(x: number, y: number, color: [number, number, number, number], layer?: number): void;
99
83
  /**
100
84
  * Take a screenshot of the canvas contents and save to a .png file.
101
85
  * @param name The file name of the screenshot
@@ -165,12 +149,6 @@ export interface Options {
165
149
  * The number of layers in this canvas
166
150
  */
167
151
  readonly numLayers: number;
168
- /**
169
- * Uses hardware (GPU) or software (CPU) acceleration
170
- * - For pixel manipulation, software acceleration is recommended
171
- * - Otherwise, hardware acceleration is recommended (default)
172
- */
173
- readonly acceleration: 'hardware' | 'software';
174
152
  /**
175
153
  * Event listener for when a key is pressed
176
154
  * @param key The key that was pressed
@@ -202,7 +180,7 @@ export interface Options {
202
180
  * @param dt The number of milliseconds in between frames
203
181
  * @returns An array of `Drawable` to render on layer 0, or void
204
182
  */
205
- readonly loop: (dt: number) => Drawable[] | (void | never);
183
+ readonly loop: (dt: number) => void;
206
184
  }
207
185
  /**
208
186
  * Represents an object that can be drawn on the canvas.