I made some nice aniso scratchmaps with the help of this program, thanks.
There is a small bug, in that you have to flip the mapping in X to achieve the right angles.
I changed the code so that you draw in a blue colour on a red background, then I can use darker colour as a clone method in PS to get a tileable map. By using red and blue I can save the red channel as the weightmap for the scratches and the blue channel as the angle map. (actually I do it in reverse - painting red onto blue, to save my eyes, and then I flip the channels in PS before cloning)
I also changed the code to only save the image if the s key is pressed, to make it run smoother.
I wanted to add an undo function but it was too hard for me to work it out, (I dont touch code normally)
Here is the map;
http://www.mediafire.com/download/ck5z3 ... atches.psd
Render is fast, bench over 1000, scratches are well defined around sl 8-10
int oldX = mouseX;
int oldY = mouseY;
int backCol = color(0, 0, 255);
int brushCol = backCol;
void setup()
{
size(1500, 1500);
background(backCol);
fill(backCol);
strokeWeight(2);
}
void draw()
{
float dx = mouseX - oldX;
float dy = -1 * (mouseY - oldY);
if ((dx!=0) || (dy!=0))
{
float mouseTravelAngle = atan2(dy,dx) / PI;
if (mouseTravelAngle < 0.)
{
mouseTravelAngle = 1. + (1. - abs(mouseTravelAngle));
}
brushCol = (int) color((255. * mouseTravelAngle / 2.), 0, 0);
}
stroke(brushCol);
if (mousePressed) {
line(oldX, oldY, mouseX, mouseY);
}
oldX = mouseX;
oldY = mouseY;
}
void keyReleased() {
if (key=='s') {
saveFrame();
}
}