protected void ThreadMission_Pixel2(int i, int j) { base.ThreadMission_Pixel(i, j); Vector2 uv = SWTextureProcess.TexUV(texWidth, texHeight, i, j); for (int k = 0; k < info.pts.Count; k++) { var p0 = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)]; var p1 = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)]; var p2 = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)]; float pcg = SWTextureProcess.PointOnSegPcgSign(uv, p1.uv, p2.uv); pcg = p1.pcg + (p2.pcg - p1.pcg) * pcg; // float innerDis = 0; // bool seg = SWTextureProcess.Point2SegOnlyDisSign (uv, p1.after, p2.pre,ref innerDis); if (texColorBuffer [(texHeight - j - 1) * texWidth + i].b <= 0.5) { float dis1 = SWTextureProcess.Point2SegDis(uv, p0.uv, p1.uv); float dis2 = SWTextureProcess.Point2SegDis(uv, p1.uv, p2.uv); bool e1 = Vector2.Dot(uv - p1.pre, p0.uv - p1.pre) < 0; bool e2 = Vector2.Dot(uv - p1.after, p2.uv - p1.after) < 0; if (e1 && e2 && (dis1 <= size || dis2 <= size)) { Vector2 v1 = p1.pre - p1.center; Vector2 v2 = uv - p1.center; Vector2 v3 = p1.after - p1.center; float angle1 = Vector2.Angle(v2, v1); float angleAll = Vector2.Angle(v1, v3); pcg = p1.prePcg + (p1.afterPcg - p1.prePcg) * angle1 / angleAll; // float disSigned1 = -SWTextureProcess.Point2LineDisSign (uv, p0.uv, p1.uv); // float disSigned2 = -SWTextureProcess.Point2LineDisSign (uv, p1.uv, p2.uv); // float disSigned = disSigned1 + (disSigned2 - disSigned1) * angle1 /angleAll; //float g = ( disSigned / size+1)*0.5f; float g = 0; if (SWCommon.AngleSigned(v3, v1, new Vector3(0, 0, 1)) < 0) { g = Vector2.Distance(uv, p1.center) / (size * 2); } else { g = 1 - Vector2.Distance(uv, p1.center) / (size * 2); } float b = (pcg > 0.995f || pcg < 0.005f)? 1:0; float a = GreenToAlpha(g); texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color(pcg, g, b, a); } } } }
protected override void ThreadMission_Pixel(int i, int j) { base.ThreadMission_Pixel(i, j); Vector2 _uv = SWTextureProcess.TexUV(texWidth, texHeight, i, j); float dis = SWTextureProcess.Point2SegDis(_uv, startUV, endUV); float isize = (float)brush.size / (float)SWWindowDrawMask.size; if (dis < isize) { float disPcg = dis / isize; SWTextureProcess.Brush_Apply(ref texColorBuffer [(texHeight - j - 1) * texWidth + i], brush, disPcg, i, j); } }
protected override void ThreadMission_Pixel(int i, int j) { base.ThreadMission_Pixel(i, j); Vector2 uv = SWTextureProcess.TexUV(texWidth, texHeight, i, j); for (int k = 0; k < info.pts.Count - 1; k++) { var p0 = info.pts [SWTextureProcess.LoopID(k - 1, info.pts.Count)]; var p1 = info.pts [SWTextureProcess.LoopID(k, info.pts.Count)]; var p2 = info.pts [SWTextureProcess.LoopID(k + 1, info.pts.Count)]; float pcg = SWTextureProcess.PointOnSegPcgSign(uv, p1.uv, p2.uv); pcg = p1.pcg + (p2.pcg - p1.pcg) * pcg; float disSeg = SWTextureProcess.Point2SegDis(uv, p1.uv, p2.uv); float disLineSign = SWTextureProcess.Point2LineDisSign(uv, p1.uv, p2.uv); disLineSign = -disLineSign; float g = (disLineSign / size + 1) * 0.5f; float b = 0; float a = GreenToAlpha(g); //first seg cap if (k == 0) { if (disSeg <= size) { if (Vector2.Dot(uv - p2.pre, p1.uv - p2.pre) >= 0) { texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color(pcg, g, b, a); } } } //last seg cap else if (k == info.pts.Count - 2) { if (disSeg <= size) { if (Vector2.Dot(uv - p1.after, p2.uv - p1.after) >= 0) { texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color(pcg, g, b, a); } } } else { if (SWTextureProcess.PointInSeg(uv, p1.after, p2.pre, size)) { texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color(pcg, g, b, a); } } if (k == 0) { if (disSeg <= size) { if (Vector2.Dot(uv - p1.uv, p2.uv - p1.uv) <= 0) { float disCenter = (uv - p1.uv).magnitude; if (disCenter / size > 1 - threhold * 2) { a = 1 - (disCenter / size - (1 - threhold * 2)) / (threhold * 2); texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color( texColorBuffer [(texHeight - j - 1) * texWidth + i].r, texColorBuffer [(texHeight - j - 1) * texWidth + i].g, texColorBuffer [(texHeight - j - 1) * texWidth + i].b, a ); } } } } if (k == info.pts.Count - 2 || info.pts.Count == 2) { if (disSeg <= size) { if (Vector2.Dot(uv - p2.uv, p1.uv - p2.uv) <= 0) { float disCenter = (uv - p2.uv).magnitude; if (disCenter / size > 1 - threhold * 2) { a = 1 - (disCenter / size - (1 - threhold * 2)) / (threhold * 2); texColorBuffer [(texHeight - j - 1) * texWidth + i] = new Color( texColorBuffer [(texHeight - j - 1) * texWidth + i].r, texColorBuffer [(texHeight - j - 1) * texWidth + i].g, texColorBuffer [(texHeight - j - 1) * texWidth + i].b, a ); } } } } } }