Hello everyone! I am trying to fill a sprite using a pattern.
The logic is this: I get all the colors of the main image as well as all the colors of the pattern image
currentColors
Color32[] patternColors = filTexture.GetPixels32();
Then I iterate through the color array of the main image, avoiding the black borders and changing the color based on the alpha of the pattern.
int patternPixelPosition = 0;
int patternPixelLength = patternColors.Length;
for (int i = 0; i < currentColors.Length; i++)
{
if (!DrawUtils.CompareColor(currentColors[i], new Color32(0, 0, 0, 255))) // black border
{
if (patternPixelPosition >= patternPixelLength)
patternPixelPosition = 0;
if (patternColors[patternPixelPosition].a > 0)
currentColors[i] = сurrentDrawingColor;
else
currentColors[i] = new Color32(255, 255, 255, 255);
patternPixelPosition+=1;
}
}

in the end it turns out like this
How can I fill in without distortion?