Skip to content

Commit

Permalink
added early pget
Browse files Browse the repository at this point in the history
  • Loading branch information
sixhat committed Nov 8, 2018
1 parent 033241d commit c8ba7a6
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/color.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
class Dave {
// Short version of functions bellow.
constructor(){
this.grid=new Grid();
constructor() {
this.grid = new Grid();
this.g = this.grid;
}
// alias for fillHsluv
f(h, s, l) {
this.fillHsluv(h,s,l);
this.fillHsluv(h, s, l);
}
// alias for strokeHsluv
s(h, s, l) {
this.strokeHsluv(h,s,l);
this.strokeHsluv(h, s, l);
}
// sets fill according to hsluv parameters
fillHsluv(h, s, l) {
Expand All @@ -22,4 +22,23 @@ class Dave {
let rgb = hsluv.hsluvToRgb([h, s, l]);
stroke(rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);
}
// Create a fast get function to use instead of in P5.
pget(x, y, img) {
img.loadPixels();
let d = pixelDensity();

for (var i = 0; i < d; i++) {
for (var j = 0; j < d; j++) {
// loop over
let idx = 4 * ((y * d + j) * img.width * d + (x * d + i));
pixels[idx] = r;
pixels[idx + 1] = g;
pixels[idx + 2] = b;
pixels[idx + 3] = a;
}
}
// Things to take into consideration: x,y must be in image.
// pixelDensity has to be taken into consideration.
// loadPixels should be called only during the first time for this particular image.
}
}

0 comments on commit c8ba7a6

Please sign in to comment.