Paint texture on terrain with scripting

Hey Guys,

I have finally accomplished it that i can paint textures on certain places of my terrain at runtime. The Problem is that on the places that i don't want to paint a new texture, must be painted again with the old texture. To make it clearer here is my code:

public class TerrainPaint : MonoBehaviour {

public void Paint () {

    TerrainData td = Terrain.activeTerrain.terrainData;

    float[,,] splatmapData = new float[td.alphamapWidth, td.alphamapHeight, td.alphamapLayers];

    for (int y = 0; y < td.alphamapHeight; y++)
    {
        for (int x = 0; x < td.alphamapWidth; x++)
        {

        float[] tex = getmethatcrapmap(x, y);
        Vector4 splat = new Vector4(tex[0], tex[1], tex[2], tex[3]);

        if(y % 20 == 0)
        {
            splat = new Vector4(1, 0, 0, 0);
        }

        // now assign the values to the correct location in the array
        splat.Normalize();
        splatmapData[x, y, 0] = splat.x;
        splatmapData[x, y, 1] = splat.y;
        splatmapData[x, y, 2] = splat.z;
        splatmapData[x, y, 3] = splat.w;
        }
    }

    // and finally assign the new splatmap to the terrainData:
    td.SetAlphamaps(0, 0, splatmapData);
}

public float[] getmethatcrapmap(int x, int y) {

    TerrainData td = Terrain.activeTerrain.terrainData;
    float[,,] splatmapData = td.GetAlphamaps(y, x, 1, 1);

    float[] cellMix = new float[splatmapData.GetUpperBound(2)+1];

    for(int n=0; n < cellMix.Length; ++n)
    {
        cellMix[n] = splatmapData[0,0,n];
    }

    return cellMix;
}   

}

This only places a new texture every 20th x position. Now if i want to paint a texture at ,for example, 50 coordinates, it's I guess a lot of work, if the whole terrain is painted again.

So my question is, is there a way to paint a texture on a certain position without drawing the whole terrain again?

ok i've made it^^

is this only happening to me or someone else that sometime after you decide to ask something you come to a solution yourself^^