I wanted the same thing, but also didnt find a way to do it in processing. I guess you could do it with pure gl statements but I just wrote myself a method which returns a PImage with the tiled image.
You put in the desired x1,x2,y1,y2 rectangle dimensions of the resulting tiled image, the original image to tile over that space, and a tint value. You´ll get a new tiled PImage in result.
Quote:private PImage getTiledImageFromSingleImage(int x1, int y1, int x2, int y2, PImage texture, float tint){
float planeWidth = x2 - x1;
float planeHeight = y2 - y1;
int textureWidth = texture.width;
int textureHeight = texture.height;
if(planeWidth<texture.width)
planeWidth = texture.width;
if(planeHeight<texture.height)
planeHeight = texture.height;
int timesWidth = (int)(planeWidth/textureWidth);
int timesHeight = (int)(planeHeight/textureHeight);
double restWidth = (planeWidth%textureWidth);
double restHeight = (planeHeight%textureHeight);
PImage tiledImage = new PImage((int)planeWidth, (int)planeHeight, PImage.ARGB);
for (int i = 0; i < timesWidth; i++) {
int startX = i * textureWidth;
for (int j = 0; j < timesHeight; j++) {
int startY = j * textureHeight;
tiledImage.copy(texture, 0, 0, texture.width, texture.height, startX, startY, textureWidth, textureHeight);
if(restWidth > 0 && !((i+1) < timesWidth)){ //rest zeichnen, der ganz nicht hinpasste
tiledImage.copy(texture, 0, 0, (int)restWidth, texture.height , startX + textureWidth, startY, (int)restWidth, textureHeight);
}
if(restHeight > 0 && !((j+1) < timesHeight)){
tiledImage.copy(texture, 0, 0, texture.width,(int)restHeight , startX, startY + textureHeight, textureWidth, (int)restHeight);
}
if((restHeight > 0 && !((j+1) < timesHeight)) && (restWidth > 0 && !((i+1) < timesWidth)) ){
tiledImage.copy(texture, 0, 0, (int)restWidth,(int)restHeight , startX + textureWidth , startY + textureHeight, (int)restWidth, (int)restHeight);
}
}
}
return tiledImage;
}