void DrawBoneJoint(PixelFarm.Drawing.Painter painter, GlyphBoneJoint joint) { //-------------- EdgeLine p_contactEdge = joint.dbugGetEdge_P(); //mid point Vector2 jointPos = joint.OriginalJointPos * _pxscale;//scaled joint pos painter.FillRect(jointPos.X, jointPos.Y, 4, 4, PixelFarm.Drawing.Color.Yellow); if (joint.TipEdgeP != null) { EdgeLine tipEdge = joint.TipEdgeP; double p_x, p_y, q_x, q_y; tipEdge.dbugGetScaledXY(out p_x, out p_y, out q_x, out q_y, _pxscale); // painter.Line( jointPos.X, jointPos.Y, p_x, p_y, PixelFarm.Drawing.Color.White); painter.FillRect(p_x, p_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker // painter.Line( jointPos.X, jointPos.Y, q_x, q_y, PixelFarm.Drawing.Color.White); painter.FillRect(q_x, q_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker } if (joint.TipEdgeQ != null) { EdgeLine tipEdge = joint.TipEdgeQ; double p_x, p_y, q_x, q_y; tipEdge.dbugGetScaledXY(out p_x, out p_y, out q_x, out q_y, _pxscale); // painter.Line( jointPos.X, jointPos.Y, p_x, p_y, PixelFarm.Drawing.Color.White); painter.FillRect(p_x, p_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker // painter.Line( jointPos.X, jointPos.Y, q_x, q_y, PixelFarm.Drawing.Color.White); painter.FillRect(q_x, q_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker } }
protected override void OnDrawBone(GlyphBone bone, int boneIndex) { float pxscale = this._pxscale; GlyphBoneJoint jointA = bone.JointA; GlyphBoneJoint jointB = bone.JointB; bool valid = false; if (jointA != null && jointB != null) { Vector2 jointAPoint = jointA.OriginalJointPos; Vector2 jointBPoint = jointB.OriginalJointPos; painter.Line( jointAPoint.X * pxscale, jointAPoint.Y * pxscale, jointBPoint.X * pxscale, jointBPoint.Y * pxscale, bone.IsLongBone ? PixelFarm.Drawing.Color.Yellow : PixelFarm.Drawing.Color.Magenta); if (this.DrawDynamicOutline) { //**** painter.Line( jointA.FitX * pxscale, jointA.FitY * pxscale, jointB.FitX * pxscale, jointB.FitY * pxscale, PixelFarm.Drawing.Color.White); } valid = true; _infoView.ShowBone(bone, jointA, jointB); } if (jointA != null && bone.TipEdge != null) { Vector2 jointAPoint = jointA.OriginalJointPos; Vector2 mid = bone.TipEdge.GetMidPoint(); painter.Line( jointAPoint.X * pxscale, jointAPoint.Y * pxscale, mid.X * pxscale, mid.Y * pxscale, bone.IsLongBone ? PixelFarm.Drawing.Color.Yellow : PixelFarm.Drawing.Color.Magenta); valid = true; _infoView.ShowBone(bone, jointA, bone.TipEdge); } if (boneIndex == 0) { //for first bone painter.FillRect(_branchHeadPos.X * pxscale, _branchHeadPos.Y * pxscale, 5, 5, PixelFarm.Drawing.Color.DeepPink); } if (!valid) { throw new NotSupportedException(); } }
void DrawPerpendicularEdgeControlPoints(PixelFarm.Drawing.Painter painter, OutsideEdgeLine internalEdgeLine) { //Vector2 regen0 = edge._newRegen0 * _pxscale; //Vector2 regen1 = edge._newRegen1 * _pxscale; //painter.FillRectLBWH(regen0.X, regen0.Y, 5, 5, PixelFarm.Drawing.Color.Green); //painter.FillRectLBWH(regen1.X, regen1.Y, 5, 5, PixelFarm.Drawing.Color.Blue); bool foundSomePerpendicularEdge = false; if (internalEdgeLine.ControlEdge_P != null && internalEdgeLine.ControlEdge_Q != null) { Vector2 m0 = internalEdgeLine.ControlEdge_P.GetMidPoint(); Vector2 m1 = internalEdgeLine.ControlEdge_Q.GetMidPoint(); //find angle from m0-> m1 Vector2 v2 = (m0 + m1) / 2; //find perpendicular line from midpoint_m0m1 to edge Vector2 cutpoint; if (MyMath.FindPerpendicularCutPoint(internalEdgeLine, v2, out cutpoint)) { painter.Line( v2.X * _pxscale, v2.Y * _pxscale, cutpoint.X * _pxscale, cutpoint.Y * _pxscale, PixelFarm.Drawing.Color.Red); foundSomePerpendicularEdge = true; } //Vector2 e0_fitpos = internalEdgeLine.ControlEdge_P.GetFitPos() * _pxscale; //Vector2 e1_fitpos = internalEdgeLine.ControlEdge_Q.GetFitPos() * _pxscale; //painter.Line( // e0_fitpos.X, e0_fitpos.Y, // regen0.X, regen0.Y, // PixelFarm.Drawing.Color.Yellow); //painter.Line( // e1_fitpos.X, e1_fitpos.Y, // regen1.X, regen1.Y, // PixelFarm.Drawing.Color.Yellow); } if (internalEdgeLine.ControlEdge_P != null) { Vector2 v2 = internalEdgeLine.ControlEdge_P.GetMidPoint(); //Vector2 cutpoint = internalEdgeLine._ctrlEdge_P_cutAt; //painter.Line( // v2.X * _pxscale, v2.Y * _pxscale, // cutpoint.X * _pxscale, cutpoint.Y * _pxscale, // PixelFarm.Drawing.Color.Green); //foundSomePerpendicularEdge = true; } if (internalEdgeLine.ControlEdge_Q != null) { Vector2 v2 = internalEdgeLine.ControlEdge_Q.GetMidPoint(); //Vector2 cutpoint = internalEdgeLine._ctrlEdge_Q_cutAt; //painter.Line( // v2.X * _pxscale, v2.Y * _pxscale, // cutpoint.X * _pxscale, cutpoint.Y * _pxscale, // PixelFarm.Drawing.Color.Green); //foundSomePerpendicularEdge = true; } if (!foundSomePerpendicularEdge) { //TODO: reimplement this again //Vector2 midpoint = edge.GetMidPoint(); //painter.FillRectLBWH(midpoint.X, midpoint.Y, 5, 5, PixelFarm.Drawing.Color.White); } }
void DrawEdge(PixelFarm.Drawing.Painter painter, EdgeLine edge) { if (edge.IsOutside) { //free side { GlyphPoint p = edge.P; GlyphPoint q = edge.Q; DrawPointKind(painter, p); DrawPointKind(painter, q); _infoView.ShowEdge(edge); switch (edge.SlopeKind) { default: painter.StrokeColor = PixelFarm.Drawing.Color.Green; break; case LineSlopeKind.Vertical: if (edge.IsLeftSide) { painter.StrokeColor = PixelFarm.Drawing.Color.Blue; } else { painter.StrokeColor = PixelFarm.Drawing.Color.LightGray; } break; case LineSlopeKind.Horizontal: if (edge.IsUpper) { painter.StrokeColor = PixelFarm.Drawing.Color.Red; } else { //lower edge painter.StrokeColor = PixelFarm.Drawing.Color.Magenta; } break; } } float scale = this._pxscale; //show info: => edge point if (this.DrawPerpendicularLine && _infoView.HasDebugMark) { double prevWidth = painter.StrokeWidth; painter.StrokeWidth = 3; painter.Line(edge.PX * scale, edge.PY * scale, edge.QX * scale, edge.QY * scale, PixelFarm.Drawing.Color.Yellow); painter.StrokeWidth = prevWidth; //draw GlyphPoint p = edge.P; GlyphPoint q = edge.Q; // //AssocBoneCollection p_bones = glyphEdge._P.dbugGetAssocBones(); //if (p_bones != null) //{ // Vector2 v2 = new Vector2(q.x, q.y); // foreach (GlyphBone b in p_bones) // { // Vector2 v3 = b.GetMidPoint(); // painter.Line(v2.X * scale, v2.Y * scale, v3.X * scale, v3.Y * scale, PixelFarm.Drawing.Color.Yellow); // } //} //AssocBoneCollection q_bones = glyphEdge._Q.dbugGetAssocBones(); //if (q_bones != null) //{ // Vector2 v2 = new Vector2(p.x, p.y); // foreach (GlyphBone b in q_bones) // { // //Vector2 v2 = new Vector2(q.x, q.y); // Vector2 v3 = b.GetMidPoint(); // painter.Line(v2.X * scale, v2.Y * scale, v3.X * scale, v3.Y * scale, PixelFarm.Drawing.Color.Green); // } //} { //TODO: reimplement this again //Vector2 orginal_MidPoint = glyphEdge.GetMidPoint() * _pxscale; //Vector2 newMidPoint = glyphEdge.GetNewMidPoint() * _pxscale; //painter.FillRectLBWH(newMidPoint.X, newMidPoint.Y, 3, 3, PixelFarm.Drawing.Color.Red); //painter.Line(newMidPoint.X, newMidPoint.Y, orginal_MidPoint.X, orginal_MidPoint.Y, PixelFarm.Drawing.Color.LightGray); //painter.FillRectLBWH(glyphEdge.newEdgeCut_P_X * _pxscale, glyphEdge.newEdgeCut_P_Y * _pxscale, 6, 6, PixelFarm.Drawing.Color.Blue); //painter.FillRectLBWH(glyphEdge.newEdgeCut_Q_X * _pxscale, glyphEdge.newEdgeCut_Q_Y * _pxscale, 6, 6, PixelFarm.Drawing.Color.Blue); } } else { painter.DrawLine(edge.PX * scale, edge.PY * scale, edge.QX * scale, edge.QY * scale); } { GlyphPoint p = edge.P; GlyphPoint q = edge.Q; //--------- { //TODO: reimplement this again //Vector2 orginal_MidPoint = glyphEdge.GetMidPoint() * _pxscale; //Vector2 newMidPoint = glyphEdge.GetNewMidPoint() * _pxscale; //if (DrawEdgeMidPoint) //{ // painter.FillRectLBWH(newMidPoint.X, newMidPoint.Y, 3, 3, PixelFarm.Drawing.Color.Red); //} //// //painter.Line(newMidPoint.X, newMidPoint.Y, orginal_MidPoint.X, orginal_MidPoint.Y, PixelFarm.Drawing.Color.LightGray); //painter.FillRectLBWH(glyphEdge.newEdgeCut_P_X * _pxscale, glyphEdge.newEdgeCut_P_Y * _pxscale, 4, 4, PixelFarm.Drawing.Color.Blue); //painter.FillRectLBWH(glyphEdge.newEdgeCut_Q_X * _pxscale, glyphEdge.newEdgeCut_Q_Y * _pxscale, 4, 4, PixelFarm.Drawing.Color.Blue); } //--------- if (this.DrawPerpendicularLine) { var asOutsideEdge = edge as OutsideEdgeLine; if (asOutsideEdge != null) { DrawPerpendicularEdgeControlPoints(painter, asOutsideEdge); } } } } else { //draw inside edge painter.Line( edge.PX * _pxscale, edge.PY * _pxscale, edge.QX * _pxscale, edge.QY * _pxscale, PixelFarm.Drawing.Color.Gray); } }