# Weird "Pixelate" Tool

**URL:** <https://discourse.processing.org/t/weird-pixelate-tool/30431>\
**Category:** Gallery\
**Created:** [June 1, 2021, 8:59pm UTC](https://discourse.processing.org/t/weird-pixelate-tool/30431 "2021-06-01T20:59:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VOIDupgraded](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@VOIDupgraded](https://discourse.processing.org/u/VOIDupgraded)\
**Post date:** [June 1, 2021, 8:59pm UTC](https://discourse.processing.org/t/weird-pixelate-tool/30431/1 "2021-06-01T20:59:42Z")

</div>

# Hi, for my first topic I’m sharing what I have been up to today.

I spent a bit of time today making a weird tool to “pixelate” images, for now it as a bunch of is statements with preset brush sizes, but I intend change that so pixel size and spacing to be controlled more precisely and independently of one another.

##### After that I may start thinking of adding more shapes ( triangles , circles ) instead of just squares.

* * *

> **Image of the first tests**
>
> ![capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/738e4a11ac929b117c0f972c2a7cb6ac140c9624.png)

* * *

> **Code**
>
> ```auto
> PImage img;
> int Image = width*height;
> int pixel;
> int brush_setup;
> int X, Y;
> 
> void setup() {
> img = loadImage("test.png");
> 
> size(512, 512);
> 
> image(img, 0, 0);
> 
> brush_setup = 1;
> 
> noStroke();
> 
> println("Brush Setup: ", brush_setup);
> }
> 
> void draw() {
> pixel = get(mouseX, mouseY);
> fill(pixel);
> }
> 
> void mouseDragged() {
> brush_change();
> }
> 
> void keyPressed() {
> if (key == 'b' || key == 'B') {
> brush_setup = brush_setup + 1;
> println("Brush Setup: ", brush_setup);
> }
> 
> if (key == 'r' || key == 'R') {
> image(img, 0, 0);
> println("Reseted!");
> }
> }
> 
> void brush_change() {
> 
> if (brush_setup == 1) {
> X = mouseX - (mouseX % 7);
> Y = mouseY - (mouseY % 7);
> rect(X, Y, 5, 5);
> }
> 
> if (brush_setup == 2) {
> X = mouseX - (mouseX % 13);
> Y = mouseY - (mouseY % 13);
> rect(X, Y, 10, 10);
> }
> 
> if (brush_setup == 3) {
> X = mouseX - (mouseX % 19);
> Y = mouseY - (mouseY % 19);
> rect(X, Y, 15, 15);
> }
> 
> if (brush_setup == 4) {
> X = mouseX - (mouseX % 25);
> Y = mouseY - (mouseY % 25);
> rect(X, Y, 20, 20);
> }
> 
> if (brush_setup == 5) {
> X = mouseX - (mouseX % 51);
> Y = mouseY - (mouseY % 11);
> rect(X, Y, 50, 10);
> }
> 
> if (brush_setup == 6) {
> X = mouseX - (mouseX % 6);
> Y = mouseY - (mouseY % 76);
> rect(X, Y, 5, 75);
> }
> 
> if (brush_setup == 7) {
> brush_setup = 1;
> println("Brush Setup: ", brush_setup);
> }
> }
> 
> ```
