How to draw pixel at specific location on the buffer?

Embedded systems is a wide term, but nevertheless, one way to export the pixel array to another platform after completing the icon design, is by saving it as a text file. (or if you wish as a byte file).

void setup() {
  size(150, 150);
  pg = createGraphics(32, 32); 
  pg.beginDraw();
  pg.background(0);
  pg.set(3, 5, color(255, 0, 0));
  pg.noStroke();
  pg.fill(255, 0, 0);
  pg.rect(10, 10, 5, 5);
  pg.endDraw();
  image(pg, 0, 0);
  //pg.loadPixels();
  String[]list = new String[pg.pixels.length];
  for (int i = 0; i < pg.pixels.length; i++) {
    float r = red(pg.pixels [i]); 
    float g = green(pg.pixels[i]); 
    float b = blue(pg.pixels[i]);
    list[i] = str(r)+" "+str(g)+" "+str(b);
  }
  saveStrings("data/data.txt", list);
}
2 Likes