int main(){ CRectangle rect; rect.set_values(3, 4); cout << "area: " << rect.area(); return 0; }
void CPicTracker::DrawTracker( CDRectangle* lpRect, CWnd* pWndClipTo, CDC* pDC, CWnd* pWnd) { // first, normalize the rectangle for drawing CRectangle rect = lpRect->GetRectangle(); LPPOINT lpPointsNew = NULL; LPPOINT lpPointsLast = NULL; if (!m_bFinalErase) { lpPointsNew = rect.GetPoints(); } if(!m_RectLast.IsNullRectangle()) lpPointsLast = m_RectLast.GetPoints(); // and draw it if (m_bFinalErase || !m_bErase) { CPolygonTracker::DrawDragPolygon(pDC, lpPointsNew, 1, lpPointsLast, 1, CRectangle::GetNumOfPoints()); } // remember last rectangles m_RectLast = rect; }
/***************************************************************** * CUISubsystemIndicator(): * * Ins: * * Outs: * * Returns: * * Mod. Date: 05/12/2015 * Mod. Initials: *****************************************************************/ CUISubsystemIndicator::CUISubsystemIndicator(PSUBSYSTEM target) { if (dynamic_cast<CLifeSupport*>(target)) { m_pTexture = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/lifeSupport.png"); //m_pBackTex = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/lifeSupportBack.png"); } if (dynamic_cast<CReactor*>(target)) { m_pTexture = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/reactor.png"); //m_pBackTex = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/reactorBack.png"); } if (dynamic_cast<CEngines*>(target)) { m_pTexture = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/engines.png"); //m_pBackTex = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/enginesBack.png"); } m_bounds = CRectangle(m_vPosition.x - 140.f, m_vPosition.x + 140.f, m_vPosition.y - 36.f, m_vPosition.y + 36.f); m_pLightTex = new CTexture2D(0.f, 0.f, 230.f, 70.f, L"Assets/Images/ColorLight.png"); m_pLightTex->SetColor({ 1.0f, 1.0f, 1.0f, 1.0f }); CRectangle rect = { m_vPosition.x - 70.f, m_vPosition.x + 70.f, m_vPosition.y - 18.f, m_vPosition.y + 18.f }; rect = CGUIManager::ComputeBounds(rect); m_pLightTex->SetWidth(rect.ComputeWidth()); m_pLightTex->SetHeight(rect.ComputeHeight()); m_pSubsystem = target; m_bSpaceToggled = false; m_fPositionMod = 0; }
///////////////////////////////////////////////////////////// /// Met à jour les pixels de la texture /// /// \param Rect : Rectangle à mettre à jour dans la texture /// //////////////////////////////////////////////////////////// void DX9Texture::Update(const CRectangle& Rect) { CA_ASSERT(CRectangle(0, 0, m_Size.x, m_Size.y).Intersects(Rect) == INT_IN, "DX9Texture::Update() : rectangle out of bounds"); // Si le format des pixels à copier est le même que celui de la texture on fait une simple copie, // sinon on effectue une conversion if (m_Format == m_Data.GetFormat()) { // Verrouillage de la texture D3DLOCKED_RECT LockedRect; RECT Lock = {Rect.Left(), Rect.Top(), Rect.Right(), Rect.Bottom()}; DXCheck(m_Texture->LockRect(0, &LockedRect, &Lock, 0)); // Copie des pixels UpdateSurface(LockedRect, Rect); // Déverrouillage de la texture m_Texture->UnlockRect(0); } else { // Récupération du device SmartPtr<IDirect3DDevice9, CResourceCOM> Device; m_Texture->GetDevice(&GetPtr(Device)); // Création d'une texture en mémoire système pour y copier les pixels SmartPtr<IDirect3DSurface9, CResourceCOM> Src; if (FAILED(Device->CreateOffscreenPlainSurface(Rect.Width(), Rect.Height(), DX9Enum::Get(m_Data.GetFormat()), D3DPOOL_SYSTEMMEM, &GetPtr(Src), nullptr))) throw DX9Exception("CreateOffscreenPlainSurface", "DX9Texture::Update"); // Verrouillage de la texture temporaire D3DLOCKED_RECT LockedRect; Src->LockRect(&LockedRect, nullptr, 0); // Copie des pixels UpdateSurface(LockedRect, Rect); // Déverrouillage de la texture temporaire Src->UnlockRect(); // Récupération de la surface de niveau 0 de la texture SmartPtr<IDirect3DSurface9, CResourceCOM> Dest; m_Texture->GetSurfaceLevel(0, &GetPtr(Dest)); // Copie de la surface Src sur la surface Dest (c'est ici qu'est effectuée la conversion de format) RECT DestRect = {Rect.Left(), Rect.Top(), Rect.Right(), Rect.Bottom()}; if (FAILED(D3DXLoadSurfaceFromSurface(Dest, nullptr, &DestRect, Src, nullptr, nullptr, D3DX_DEFAULT, 0))) throw DX9Exception("D3DXLoadSurfaceFromSurface", "DX9Texture::Update"); } // Génération des niveaux de mipmapping si nécessaire if (m_HasMipmaps) { if (m_AutoMipmaps) m_Texture->GenerateMipSubLevels(); else D3DXFilterTexture(m_Texture, nullptr, D3DX_DEFAULT, D3DX_DEFAULT); } }
int main () { CSquare sqr; //pilha CRectangle rect; //pilha sqr.set_side(4); rect.convert(sqr); cout << rect.area(); return 0; }
CRectangle CRectangle::Subtract(const CRectangle& rc) const { CRectangle result(*this); result.X() -= rc.GetX(); result.Y() -= rc.GetY(); result.W() -= rc.GetW(); result.H() -= rc.GetH(); return result; }
int main() { CRectangle rect(3,4); CRectangle rectb; cout << "rect area: "<< rect.area()<<endl; cout << "rectb area: "<< rectb.area()<<endl; return 0; }
int main() { CRectangle rect; CTriangle trgl; rect.set_values(4,5); trgl.set_values(4,5); cout << rect.area() << endl; cout << trgl.area() << endl; return 0; }
int main(){ CRectangle rect; CTriangle trgl; rect.set_values(4, 5); trgl.set_values(4, 5); rect.output(rect.area()); trgl.output(trgl.area()); return 0; }
CBlockType2::CBlockType2(const int &x, const int &y) :CBlock(x,y) { for (int i = 0; i < getBlockNum(); i++) { CRectangle *temp = new CRectangle(x, y + ((i * 2) * 16), 16); temp->setColor(getColor()); setRectArr(i, temp); } }
int main () { CRectangle rect; rect.set_values (3,4); printf("Rect Area : %i\n", rect.area()); return 0; }
int main(){ CRectangle rect; CTriangle trgl; CPolygon*ppoly1 = ▭ CPolygon&ppoly2 = &trgl; ppoly1->set_values (4,5); ppoly2->set_values (4,5); cout << rect.area() << endl; cout << trgl.area() << endl; return 0; }
void CText::RenderPut(const CCanvas* canvas, const CRectangle& dstRect, const CRectangle& srcRect) { CRectangle dest(dstRect); CRectangle src(srcRect); dest.SetW(srcRect.GetW()); dest.SetH(srcRect.GetH()); ApplyModifiers(src, dest); ApplyAnimators(src, dest); m_pText->RenderCopy(&dest, &src); }
int main() { CSquare sqr; CRectangle rect; sqr.set_side(4); rect.convert(sqr); cout << rect.area() << endl; return 0; }
void FillRectangle(CRectangle const &rect, char code, CCanvas &canvas) { for (size_t y = rect.GetTop(); y != (size_t)rect.GetBottom(); ++y) { for (size_t x = rect.GetLeft(); x != (size_t)rect.GetRight(); ++x) { canvas.SetPixel(x, y, code); } } }
int main () { CRectangle rect; cout<<"Enter length of rectangle:"; cin>>rect.x; cout<<"Enter breadth of rectangle:"; cin>>rect.y; cout <<"Area:"<< rect.area(); return 0; }
void testFunction () { int a,b; CRectangle rect; CTriangle trgl; CPolygon * ppoly1 = ▭ CPolygon * ppoly2 = &trgl; ppoly1->set_values (4,5); ppoly2->set_values (4,5); a = rect.area(); b = trgl.area(); }
void RectangleActions(CRectangle &rect, ifstream &fin) { string action; fin >> action; if (action == "Rectangle") { int width, height, left, top; fin >> left >> top >> width >> height; rect.SetLeft(left); rect.SetTop(top); rect.SetWidth(width); rect.SetHeight(height); }
void CProcessRectangles::ProcessRectangleCommand(const listArguments & arguments, CRectangle & rectangle) { if (arguments.size() != AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Rectangle)]) { throw invalid_argument(MESSAGE_INCORRECT_AMOUNT_ARGUMENTS + to_string(AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Rectangle)])); } rectangle.SetLeft(stoi(arguments[1])); rectangle.SetTop(stoi(arguments[2])); rectangle.SetWidth(stoi(arguments[3])); rectangle.SetHeight(stoi(arguments[4])); }
void CBlockType2::reBuild() { for (int i = 0; i < getBlockNum(); i++) { delete getRectArr()[i]; } setBlockNum(rand() % 3 + 4); for (int i = 0; i < getBlockNum(); i++) { CRectangle *temp = new CRectangle(getX(), getY() + ((i * 2) * 16), 16); temp->setColor(getColor()); setRectArr(i, temp); } }
int main(){ int w,h; CRectangle r; cin>>w>>h; r.Init(w,h); r.w=7; printArea(r); cout<<"f**k"<<r.Area()<<endl; Complex c1; c1.real=1;c1.imag=2; Complex c2(c1); cout<<c2.real<<endl; return 0; }
//////////////////////////////////////////////////////////// /// Copie les pixels de la texture sur une surface verrouillée /// /// \param LockedRect : Structure contenant les infos de verrouillage /// \param Rect : Rectangle source à copier /// //////////////////////////////////////////////////////////// void DX9Texture::UpdateSurface(const D3DLOCKED_RECT& LockedRect, const CRectangle& Rect) { // Récupération d'un pointeur sur les pixels source et destination unsigned char* DestPix = reinterpret_cast<unsigned char*>(LockedRect.pBits); const unsigned char* SrcPix = m_Data.GetData() + (Rect.Left() + Rect.Top() * m_Size.x) * GetBytesPerPixel(m_Data.GetFormat()); // Copie des pixels sur la surface unsigned int Bpp = GetBytesPerPixel(m_Data.GetFormat()); for (int i = 0; i < Rect.Height(); ++i) { std::copy(SrcPix, SrcPix + Rect.Width() * Bpp, DestPix); SrcPix += m_Size.x * Bpp; DestPix += LockedRect.Pitch; } }
void Learn::test(){ CRectangle a, *b, *c; CRectangle * d = new CRectangle[2]; b= new CRectangle; c= &a; a.set_values (1,2); b->set_values (3,4); d->set_values (5,6); d[1].set_values (7,8); cout << "a area: " << a.area() << endl; cout << "*b area: " << b->area() << endl; cout << "*c area: " << c->area() << endl; cout << "d[0] area: " << d[0].area() << endl; cout << "d[1] area: " << d[1].area() << endl; }
int main () { CRectangle a, *b, *c; CRectangle * d = new CRectangle[2]; b= new CRectangle; c= &a; a.set_values (1,2); b->set_values (3,4); d->set_values (5,6); d[1].set_values (7,8); cout << "a area: " << a.area() << endl; cout << "*b area: " << b->area() << endl; cout << "*c area: " << c->area() << endl; cout << "d[0] area: " << d[0].area() << endl; cout << "d[1] area: " << d[1].area() << endl; delete[] d; delete b; return 0; }
/***************************************************************** * CHealthBar(): * * Ins: * * Outs: * * Returns: * * Mod. Date: 05/12/2015 * Mod. Initials: *****************************************************************/ CHealthBar::CHealthBar(float fMaxHealth) : m_fMaxHealth(fMaxHealth), m_fHealth(fMaxHealth) { //m_pTexture = new CTexture2D(0.f, 0.f, 250.f, 50.f, L"Assets/Images/healthBar.dds"); m_pTexture = new CTexture2D(100, 300.0f, 250.f, 50.f, L"Assets/Images/RedBar.png"); m_pTexture->SetColor(XMFLOAT4(1, 0, 0, 1)); m_pOverlayTexture = new CTexture2D(100, 300.0f, 250.f, 50.f, L"Assets/Images/BarOverlayThin.png"); CRectangle rect = { 0.f, 310.0f, 0.f, 144.0f }; rect = CGUIManager::ComputeBounds(rect); m_pOverlayTexture->SetWidth(rect.ComputeWidth()); m_pOverlayTexture->SetHeight(rect.ComputeHeight()); m_pOverlayTexture->SetScreenPosition(0.731f, -0.810f); //m_pBackTexture = new CTexture2D(CRenderer::GetReference().GetWidth() * .5f, 300.f, 250.f, 50.f, L"Assets/Images/RedBar.png"); //m_pBackTexture->SetColor(DirectX::XMFLOAT4 { 0.f, 0.f, 0.f, 1.f }); }
int main () { CPolygon* polygons[4]; polygons[0] = new CRectangle(20,30); polygons[1] = new CTriangle(20,25); polygons[2] = new CCircle(25,25); polygons[3] = new CSquare(18,18); for(int i = 0; i < 4; i++) { CTriangle* trin = dynamic_cast <CTriangle *> (polygons[i]); if (trin != 0) { trin->set_values(10, 10); assert(trin->area() != 50); } CCircle* circ = dynamic_cast <CCircle *> (polygons[i]); if (circ != 0) { circ->set_values(10, 10); assert(circ->area() != 78); } CSquare* sqrr = dynamic_cast <CSquare *> (polygons[i]); if (sqrr != 0) { sqrr->set_values(10, 10); assert(sqrr->area() != 100); } CRectangle* rect = dynamic_cast <CRectangle *> (polygons[i]); if (rect != 0) { rect->set_values(10, 20); assert(rect->area() != 200); } } /* */ return 0; }
void CProcessRectangles::ProcessMoveCommand(const listArguments & arguments, CRectangle & rectangle) { if (arguments.size() != AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Move)]) { throw invalid_argument(MESSAGE_INCORRECT_AMOUNT_ARGUMENTS + to_string(AMOUNT_ARGUMENTS_FOR_COMMAND[static_cast<int>(IdCommand::Move)])); } rectangle.Move(stoi(arguments[1]), stoi(arguments[2])); }
void CText::Layout(SInt2 sPosition, SInt2 sAreaSize) { CRectangle cRect; BOOL bValid; mcTextData.Layout(); CDrawable::Layout(sPosition, sAreaSize); bValid = mcTextData.GetBounds(msCaretPos.x, msCaretPos.y, &cRect); if (bValid) { mpcCaret->SetPosition(cRect.miLeft + sPosition.x, cRect.miTop + sPosition.y); mpcCaret->SetActualSize(1, cRect.GetHeight()); } else { mbCaretVisible = FALSE; } }
int main () { //first example CRectangle rect; rect.set_values (3,4); cout << "area: " << rect.area() << "\n"; //example of internal vs external class func defn CRectangle_internal rect_internal; cout << "area internal: " << rect_internal.area() << "\n"; rect_internal.set_values(3,4); cout << "area internal: " << rect_internal.area() << "\n"; //example of multiple instances CRectangle rectb; rectb.set_values(5,6); cout << "areab: " << rectb.area() << "\n"; //constructors CRectangle_con rectc; CRectangle_con rectd (5,6); cout << "rectc area: " << rectc.area() << endl; cout << "rectd area: " << rectd.area() << endl; //destructor //implicit default // CRectangle_implicit rect_implict (2,3); // CRectangle_implicit rect_implicit2 (rect_implicit); // cout << "rect_implict: " << rect_implict.area() << endl; // cout << "rect_implict2: " << rect_implict2.area() << endl; // CExample ex (2,3); // CExample ex2 (ex); //pointers return 0; }
bool CRectangle::Contains(const CRectangle& rc) const { int left1, top1, right1, bottom1; int left2, top2, right2, bottom2; left1 = GetX(); top1 = GetY(); right1 = GetX() + GetW(); bottom1 = GetY() + GetH(); left2 = rc.GetX(); top2 = rc.GetY(); right2 = rc.GetX() + rc.GetW(); bottom2 = rc.GetY() + rc.GetH(); // return !(left1 < right2 && right1 > left2 && // top1 > bottom2 && bottom1 < top2); // return (left1 < right2 || right1 > left2 || // top1 > bottom2 || bottom1 < top2); // return ((left1 < right2) || (right1 > left2) || // (top1 > bottom2) || (bottom1 < top2)); // return (!(left1 < right2) || !(right1 > left2) || // !(top1 > bottom2) || !(bottom1 < top2)); // return (!(left1 < right2) && !(right1 > left2) && // !(top1 > bottom2) && !(bottom1 < top2)); bool xOverlap = valueInRange(left1, left2, right2) || valueInRange(left2, left1, right1); bool yOverlap = valueInRange(top1, top2, bottom2) || valueInRange(top2, top1, bottom1); return xOverlap && yOverlap; }