public SWTexThread_Tex(SWTexture2DEx _tex, SWBrush _brush) : base() { tex = _tex; texWidth = tex.width; texHeight = tex.height; brush = _brush; }
public SWTexThread_SrcTex(SWTexture2DEx _tex, SWTexture2DEx _texSrc, SWBrush _brush) : base(_tex, _brush) { texColorBuffer = _tex.GetPixels(); texSrc = _texSrc; texSrcColorBuffer = _texSrc.GetPixels(); texSrcWidth = texSrc.width; texSrcHeight = texSrc.height; }
public override void InitOnce() { base.InitOnce(); brush = new SWBrush(); brush.size = 30; brush.mode = SWBrushMode.brush; brush.color = new Color(0, 1, 0, 1); brush.mask = new bool[] { true, true, true, true }; }
public static void ProcessMask_DrawPoint(SWTexture2DEx tex, Vector2 _uv, SWBrush _brush) { colorStartBuffer = tex.GetPixels(); brushBuffer = new float[tex.width, tex.height]; SWUndo.RegisterCompleteObjectUndo(tex); SWTexThread_TexDrawPoint t = new SWTexThread_TexDrawPoint(tex, _brush); t.Process(_uv); }
public override void InitOnce() { base.InitOnce(); brush = new SWBrush(); brush.size = 50; brush.mode = SWBrushMode.brush; brush.color = new Color(0, 1, 0, 1); brush.mask = new bool[] { true, true, true, true }; drawRect = new Rect(0, 0, size, size); previewRect = new Rect(drawRect.width, 0, drawRect.width, drawRect.height); }
/// <summary> /// 连续笔刷,例如 笔刷/橡皮. 一笔操作需防止重复叠加,又因橡皮的公式为*(1-x) x量不可以拆分,因此统一处理为 初始值x最大笔刷量 /// </summary> public static void Brush_Apply(ref Color c, SWBrush brush, float disPcg, int x, int y) { float pcg = Brush_CalPcg(brush, disPcg); if (pcg <= brushBuffer [x, y]) { return; } brushBuffer [x, y] = pcg; int id = XYtoIndex(brushBuffer.GetLength(0), brushBuffer.GetLength(1), x, y); Brush_SetColor(ref c, brush, pcg, id); }
private static float Brush_CalPcg(SWBrush brush, float disPcg = -1) { float realPcg = 0; if (disPcg < 0.55f) { realPcg = 1; } else { realPcg = Mathf.Lerp(1, 0, (disPcg - 0.55f) / 0.45f); } realPcg *= brush.trans; return(realPcg); }
private static void Brush_SetColor(ref Color c, SWBrush brush, float applyPcg, int id) { if (brush.mode == SWBrushMode.erase) { c = colorStartBuffer [id] * (1 - applyPcg); return; } if (brush.mask [0]) { c.r = colorStartBuffer [id].r + brush.color.r * applyPcg; } if (brush.mask [1]) { c.g = colorStartBuffer [id].g + brush.color.g * applyPcg; } if (brush.mask [2]) { c.b = colorStartBuffer [id].b + brush.color.b * applyPcg; } if (brush.mask [3]) { c.a = colorStartBuffer [id].a + brush.color.a * applyPcg; } }
private static void Brush_SetColorOnce(ref Color c, SWBrush brush, float applyPcg) { if (brush.mode == SWBrushMode.erase) { c *= (1 - applyPcg); return; } if (brush.mask [0]) { c.r += brush.color.r * applyPcg; } if (brush.mask [1]) { c.g += brush.color.g * applyPcg; } if (brush.mask [2]) { c.b += brush.color.b * applyPcg; } if (brush.mask [3]) { c.a += brush.color.a * applyPcg; } }
public TexThread_RemapLine(SWTexture2DEx _tex, SWBrush _brush) : base(_tex, _brush) { texColorBuffer = tex.GetPixels(); displayProgress = true; }
public SWTexThread_TexDrawPoint(SWTexture2DEx _tex, SWBrush _brush) : base(_tex, _brush) { texColorBuffer = tex.GetPixels(); }
public SWTexThread_RemapDir(SWTexture2DEx _tex, SWTexture2DEx _texSrc, SWBrush _brush) : base(_tex, _texSrc, _brush) { texColorBuffer = new Color[texSrcColorBuffer.Length]; displayProgress = true; }
public static void ProcessMask_Wand(SWTexture2DEx tex, SWTexture2DEx texSource, Vector2 _uv, SWBrush _brush, float tolerance) { SWUndo.RegisterCompleteObjectUndo(tex); texSource.filterMode = FilterMode.Point; SWTexThread_Wand t = new SWTexThread_Wand(tex, texSource, _brush); t.Process(_uv, tolerance); }
public static void ProcessMask_Dropper(SWTexture2DEx tex, SWTexture2DEx texSource, Vector2 _uv, SWBrush _brush, float tolerance) { SWUndo.RegisterCompleteObjectUndo(tex); SWTexThread_ColorRange t = new SWTexThread_ColorRange(tex, texSource, _brush); t.Process(_uv, tolerance); }
public static void ProcessMask_DrawLine(SWTexture2DEx tex, Vector2 _startUV, Vector2 _endUV, SWBrush brush) { SWUndo.RegisterCompleteObjectUndo(tex); SWTexThread_TexDrawLine t = new SWTexThread_TexDrawLine(tex, brush); t.Process(_startUV, _endUV); }
public SWTexThread_ColorRange(SWTexture2DEx _tex, SWTexture2DEx _texSrc, SWBrush _brush) : base(_tex, _texSrc, _brush) { displayProgress = true; }
/// <summary> /// 单次笔刷,例如魔棒,取色.单次操作不会重复叠加,因此直接加上去即可. /// </summary> public static void Brush_ApplyOnce(ref Color c, SWBrush brush, float disPcg) { float pcg = Brush_CalPcg(brush, disPcg); Brush_SetColorOnce(ref c, brush, pcg); }
public SWTexThread_TexDrawLine(SWTexture2DEx _tex, SWBrush _brush) : base(_tex, _brush) { }