// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1) void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) { wxPoint2DDouble current; GetCurrentPoint(¤t.m_x,¤t.m_y); wxPoint2DDouble p1(x1,y1); wxPoint2DDouble p2(x2,y2); wxPoint2DDouble v1 = current - p1; v1.Normalize(); wxPoint2DDouble v2 = p2 - p1; v2.Normalize(); wxDouble alpha = v1.GetVectorAngle() - v2.GetVectorAngle(); if ( alpha < 0 ) alpha = 360 + alpha; // TODO obtuse angles alpha = DegToRad(alpha); wxDouble dist = r / sin(alpha/2) * cos(alpha/2); // calculate tangential points wxPoint2DDouble t1 = dist*v1 + p1; wxPoint2DDouble nv1 = v1; nv1.SetVectorAngle(v1.GetVectorAngle()-90); wxPoint2DDouble c = t1 + r*nv1; wxDouble a1 = v1.GetVectorAngle()+90; wxDouble a2 = v2.GetVectorAngle()-90; AddLineToPoint(t1.m_x,t1.m_y); AddArc(c.m_x,c.m_y,r,DegToRad(a1),DegToRad(a2),true); AddLineToPoint(p2.m_x,p2.m_y); }
void wxGraphicsPathData::AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y ) { // calculate using degree elevation to a cubic bezier wxPoint2DDouble c1; wxPoint2DDouble c2; wxPoint2DDouble start; GetCurrentPoint(&start.m_x,&start.m_y); wxPoint2DDouble end(x,y); wxPoint2DDouble c(cx,cy); c1 = wxDouble(1/3.0) * start + wxDouble(2/3.0) * c; c2 = wxDouble(2/3.0) * c + wxDouble(1/3.0) * end; AddCurveToPoint(c1.m_x,c1.m_y,c2.m_x,c2.m_y,x,y); }
AnimatePoint AnimateCompile::GetEndingPosition(const ContToken* token) const { auto sheet = curr_sheet + 1; while (1) { if (sheet == mShow.GetSheetEnd()) { RegisterError(ANIMERR_UNDEFINED, token); return GetPointPosition(); } if (sheet->IsInAnimation()) { return sheet->GetPosition(GetCurrentPoint()); } ++sheet; } }
wxPoint2DDouble wxGraphicsPath::GetCurrentPoint() const { wxDouble x,y; GetCurrentPoint(&x,&y); return wxPoint2DDouble(x,y); }
AnimatePoint AnimateCompile::GetReferencePointPosition(unsigned refnum) const { return curr_sheet->GetPosition(GetCurrentPoint(), refnum+1); }
AnimatePoint AnimateCompile::GetStartingPosition() const { return curr_sheet->GetPosition(GetCurrentPoint()); }