void CShapeEffectCreator::CreateShapeRegion (int iAngle, int iLength, int iWidth, CG16bitRegion *pRegion) // CreateShapeRegion // // Creates a transformed polygon from m_Points and the given parameters { // Define a transformation for this shape CXForm Trans(xformScale, ((Metric)iLength)/100.0, ((Metric)iWidth)/100.0); Trans = Trans * CXForm(xformRotate, iAngle); // Transform the points for (int i = 0; i < m_iPointCount; i++) { Metric x, y; Trans.Transform(m_Points[i].x, m_Points[i].y, &x, &y); m_TransBuffer[i].x = (int)(x + 0.5); m_TransBuffer[i].y = -(int)(y + 0.5); } // Create the region if (m_bConvexPolygon) pRegion->CreateFromConvexPolygon(m_iPointCount, m_TransBuffer); else pRegion->CreateFromPolygon(m_iPointCount, m_TransBuffer); }
IAnimatron *CAniVScroller::HitTest (const CXForm &ToDest, int x, int y) // HitTest // // Hit test { int i; IAnimatron *pHit; // Transform Metric yScrollPos = m_Properties[INDEX_SCROLL_POS].GetMetric(); Metric cyViewport = m_Properties[INDEX_VIEWPORT_HEIGHT].GetMetric(); CVector vPos = m_Properties[INDEX_POSITION].GetVector(); CXForm LocalToDest = CXForm(xformTranslate, vPos - CVector(0.0, yScrollPos)) * ToDest; // Loop over all lines for (i = 0; i < m_List.GetCount(); i++) { SLine *pList = &m_List[i]; // Are we in the viewport? RECT rcLine; pList->pAni->GetSpacingRect(&rcLine); Metric cyLine = (Metric)RectHeight(rcLine); Metric yLinePos = pList->pAni->GetPropertyVector(PROP_POSITION).GetY() - yScrollPos; if (yLinePos + cyLine < 0.0 || yLinePos >= cyViewport) continue; // Hit test if (pHit = pList->pAni->HitTest(LocalToDest, x, y)) return pHit; } return NULL; }
void CreateBlasterShape (int iAngle, int iLength, int iWidth, SPoint *Poly) // CreateBlasterShape // // Creates a blaster-shaped polygon { // Define a transformation for this shape CXForm Trans(xformScale, ((Metric)iWidth)/100.0, ((Metric)iLength)/100.0); Trans = Trans * CXForm(xformRotate, iAngle + 270); // Generate the points for (int i = 0; i < 8; i++) { Metric x, y; Trans.Transform(g_BlasterShape[i].x, g_BlasterShape[i].y, &x, &y); Poly[i].x = (int)x; Poly[i].y = (int)y; } }
void CMoltenBoltEffectCreator::CreateBoltShape (int iAngle, int iLength, int iWidth, SPoint *Poly) // CreateBoltShape // // Creates a bolt-shaped polygon { // Define a transformation for this shape CXForm Trans(xformScale, ((Metric)iLength)/100.0, ((Metric)iWidth)/34.0); Trans = Trans * CXForm(xformRotate, iAngle); // Generate the points for (int i = 0; i < SHAPE_COUNT; i++) { Metric x, y; Trans.Transform(g_Shape[i].x, g_Shape[i].y, &x, &y); Poly[i].x = (int)(x + 0.5); Poly[i].y = -(int)(y + 0.5); } }
void CAniVScroller::Paint (SAniPaintCtx &Ctx) // Paint // // Paint the lines { int i; // Basic metrics Metric yScrollPos = m_Properties[INDEX_SCROLL_POS].GetMetric(); Metric cyViewport = m_Properties[INDEX_VIEWPORT_HEIGHT].GetMetric(); Metric cyFadeEdge = m_Properties[INDEX_FADE_EDGE_HEIGHT].GetMetric(); DWORD dwBaseOpacity = m_Properties[INDEX_OPACITY].GetOpacity() * Ctx.dwOpacityToDest / 255; // Transform CVector vPos = m_Properties[INDEX_POSITION].GetVector(); CXForm LocalToDest = CXForm(xformTranslate, vPos - CVector(0.0, yScrollPos)) * Ctx.ToDest; // Local paint ctx SAniPaintCtx LocalCtx(Ctx.Dest, LocalToDest, 0, Ctx.iFrame); // Clip RECT rcSavedClip = Ctx.Dest.GetClipRect(); RECT rcClip = rcSavedClip; rcClip.top = (int)vPos.GetY(); rcClip.bottom = (int)(vPos.GetY() + cyViewport); Ctx.Dest.SetClipRect(rcClip); // Loop over all lines for (i = 0; i < m_List.GetCount(); i++) { SLine *pList = &m_List[i]; // Are we in the viewport? RECT rcLine; pList->pAni->GetSpacingRect(&rcLine); Metric cyLine = (Metric)RectHeight(rcLine); Metric yLinePos = pList->pAni->GetPropertyVector(PROP_POSITION).GetY() - yScrollPos; if (yLinePos + cyLine < 0.0 || yLinePos >= cyViewport) continue; // Fade edges if (cyFadeEdge > 0.0) { if (yLinePos < 0.0) LocalCtx.dwOpacityToDest = 0; else if (yLinePos < cyFadeEdge) LocalCtx.dwOpacityToDest = (DWORD)((Metric)dwBaseOpacity * (yLinePos / cyFadeEdge)); else if (yLinePos + cyFadeEdge > cyViewport) LocalCtx.dwOpacityToDest = (DWORD)((Metric)dwBaseOpacity * (cyViewport - yLinePos) / cyFadeEdge); else LocalCtx.dwOpacityToDest = dwBaseOpacity; } else LocalCtx.dwOpacityToDest = dwBaseOpacity; // Paint pList->pAni->Paint(LocalCtx); } Ctx.Dest.SetClipRect(rcSavedClip); }