Create a Patterned Brush

  1. Consider the following code, which will fill the inside of a rounded rectangle with a pattern.
    
    // Create a hatched bit pattern.
    WORD HatchBits[8] = { 0x18, 0x24, 0x42, 0xFF, 0x18, 0x24, 0x42, 0xFF, };
    
    // Use the bit pattern to create a bitmap.
    CBitmap bm;
    bm.CreateBitmap(8,8,1,1, HatchBits);
    
    // Create a pattern brush from the bitmap.
    CBrush brush;
    brush.CreatePatternBrush(&bm);
    
    // Select the brush into a device context, and draw.
    CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
    pDC->RoundRect(CRect(50, 50, 200, 200), CPoint(10,10));
    
    // Restore the original brush.
    pDC->SelectObject(pOldBrush);
    
    
    Patterned Brush
  2. Modify the above code and design a beautiful pattern of your own.
  3. Submit your project (ZIP) and the figure it draws (PNG).