Skip to content

Commit

Permalink
1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
quinton-ashley committed Sep 22, 2023
1 parent bce8ee0 commit 2957235
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "quinton-ashley",
"name": "q5",
"version": "1.4.3",
"version": "1.4.4",
"description": "An implementation of the p5.js 2D API that's smaller and faster",
"main": "q5.js",
"scripts": {
Expand Down
14 changes: 8 additions & 6 deletions q5.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function Q5(scope, parent) {
defaultStyle();

$.MAGIC = 0x9a0ce55;
$.pixels = [];
let imgData = null;

$.createCanvas = (width, height) => {
$.width = width;
Expand Down Expand Up @@ -347,7 +349,8 @@ function Q5(scope, parent) {
w = w || $.width;
h = h || $.height;
let img = $.createImage(w, h);
let imgData = ctx.getImageData(x * $._pixelDensity, y * $._pixelDensity, w * $._pixelDensity, h * $._pixelDensity);
let mod = $._pixelDensity || 1;
let imgData = ctx.getImageData(x * mod, y * mod, w * mod, h * mod);
img.canvas.getContext('2d').putImageData(imgData, 0, 0);
return img;
};
Expand All @@ -360,9 +363,10 @@ function Q5(scope, parent) {
$._tint = old;
return;
}
for (let i = 0; i < $._pixelDensity; i++) {
for (let j = 0; j < $._pixelDensity; j++) {
let idx = 4 * ((y * $._pixelDensity + i) * ctx.canvas.width + x * $._pixelDensity + j);
let mod = $._pixelDensity || 1;
for (let i = 0; i < mod; i++) {
for (let j = 0; j < mod; j++) {
let idx = 4 * ((y * mod + i) * ctx.canvas.width + x * mod + j);
$.pixels[idx] = c._r;
$.pixels[idx + 1] = c._g;
$.pixels[idx + 2] = c._b;
Expand Down Expand Up @@ -578,7 +582,6 @@ function Q5(scope, parent) {
$.mouseIsPressed = false;
$.key = null;
$.keyCode = null;
$.pixels = [];
$.accelerationX = 0;
$.accelerationY = 0;
$.accelerationZ = 0;
Expand Down Expand Up @@ -633,7 +636,6 @@ function Q5(scope, parent) {
let looper = null;
let firstVertex = true;
let curveBuff = [];
let imgData = null;
let preloadCnt = 0;
let keysHeld = {};
let millisStart = 0;
Expand Down
2 changes: 1 addition & 1 deletion q5.min.js

Large diffs are not rendered by default.

0 comments on commit 2957235

Please sign in to comment.