public void MixPixels(FixedShape2D shape, Color mixer) { UsePaintActionOnArea((int)shape.GetBoundingBoxMinY() - 1, (int)shape.GetBoundingBoxMaxY() + 1, (int)shape.GetBoundingBoxMinX() - 1, (int)shape.GetBoundingBoxMaxX() + 1, mixer, MixPixel, shape); }
public void DrawPixels(FixedShape2D shape, Color value) { UsePaintActionOnArea((int)shape.GetBoundingBoxMinY() - 1, (int)shape.GetBoundingBoxMaxY() + 1, (int)shape.GetBoundingBoxMinX() - 1, (int)shape.GetBoundingBoxMaxX() + 1, value, DrawPixel, shape); }
void Start() { int texSizeD2 = textureSize / 2; int texSizeD4 = textureSize / 4; switch (shapeType) { case 0: shape = new FixedCircle2D(new FixedVertex2D(textureSize / 2, textureSize / 2), (Fixed)textureSize / 4); break; case 1: FixedVector2 a = new FixedVector2(texSizeD2 - texSizeD4, texSizeD2 - texSizeD4); FixedVector2 b = new FixedVector2(texSizeD2 + texSizeD4, texSizeD2 - texSizeD4); FixedVector2 c = new FixedVector2(texSizeD2, texSizeD2 + texSizeD4); shape = new FixedTriangle2D(a, b, c); break; case 2: Fixed bot = (Fixed)(texSizeD2 - texSizeD4); Fixed l = (Fixed)(texSizeD2 - texSizeD4); Fixed s = (Fixed)(texSizeD2); shape = new FixedRectangle2D(l, bot, s, s); break; default: shape = new FixedCircle2D(new FixedVertex2D(textureSize / 2, textureSize / 2), (Fixed)textureSize / 4); break; } text = new Texture2D(textureSize, textureSize); pm = new FixedTexturePaintManager(text); pm.Clear(clear); pm.DrawPixels(shape, figure); text.Apply(); material.mainTexture = text; }
private void UsePaintActionOnArea(int bottom, int top, int left, int right, Color value, PaintAction action, FixedShape2D shape) { for (int y = bottom; y <= top; y++) { for (int x = left; x <= right; x++) { if (CheckBounds(x, y)) { if (shape != null) { if (shape.Contains(x, y)) { action(x, y, value); //Debug.Log("Draw"); } } else { action(x, y, value); } } } } }