Spiro Sample: Animated Drawing Game
The Spiro sample is a drawing game that shows how to work with the following features:
- Memory DCs in applications requiring animation effects.
- MM_LOENGLISH mapping mode.
- Image lists (created using CImageList), including transparency mode and bitmap dragging and dropping.
Building and Running the Sample
To build and run the Spiro sample
- Open the solution spiro.sln.
- On the Build menu, click Build.
- On the Debug menu, click Start Without Debugging.
The toolbar contains four ring types and seven wheel types. The rings and wheels can be combined (one and one) to create different "spirograph" drawings.
Note The wheels can also be used as rings. In this case, a wheel is set outside another wheel.
Once the ring and the wheel are set on the drawing area, you can click the wheel's "pen-spot" and drag it to another position on the wheel. By changing the pen-spot location, different drawings are generated. In addition, you can select which colors to use from the toolbar. Finally, you can select the width of the pen by clicking the "width setting" button on the toolbar.
Once these settings have been selected, start drawing by clicking the "Play" button. This triggers the drawing action, which can be paused with the "Pause" button. It can be "stepped" with the "step" button.
- Drawing Speed The drawing speed is controlled using the "Fast Drawing" and "Slow Drawing" buttons on the toolbar.
- Clearing or Repositioning the Rings Once the drawing is complete, you can remove the rings or wheel from the drawing surface by clicking the "cancel-ring" or "cancel-wheel" button on the toolbar.
Note Clicking the "cancel-ring" button removes the drawing wheel as well if it is present.
To reposition the wheel or ring, remove the ring and place it again.
- Copying and Dragging Spirographs Completed spirographs can be dragged to different locations on the drawing area using the mouse. To copy a drawing, hold down the Ctrl key and drag it to a new location.
- Removing Spirographs To remove a drawing from the drawing area, drag and drop it off the drawing surface. To accomplish this, you may need to zoom out one or more times until the limits of the drawing area are displayed on the screen.
- Zooming There are two toolbar buttons to perform zoom-in and zoom-out. These buttons work even while a drawing is being created. You can zoom out several times until the limits of the drawing area are visible.
- Printing You can see the drawings prior to printing using the Print Preview option on the File menu. Very nice patterns can be printed with a color printer.
Classes and Keywords
This sample demonstrates the following classes:
CImageList, CToolbar, CPoint, CPen, CBrush, CDC, CArchive, CPaintDC, CRgn, CBitmap, CCmdUI, CToolbarCtrl, CSize
This sample demonstrates the following keywords:
CBitmap::CreateCompatibleBitmap, CBitmap::DeleteObject, CImageList::DragEnter, CImageList::DragLeave, CImageList::DragMove, CImageList::EndDrag, CDC::DPtoLP, CDC::LPtoDP, CDC::IsPrinting, CDC::SetWindowOrg, CDC::SetViewportOrg, CDC::FillRect, CCmdUI::Enable, CView::OnPrepareDC, CRect::SetRect, CRect::InflateRect, CToolbarCtrl::IsButtonChecked