It looks like a lot of duplication could be condensed by setting

```
color[posY][posX] = whichType;
```

here, as there's no other logic in the statements.