Advertisement
Advertisement
| 04.24.2008 at 09:13AM PDT, ID: 23350809 |
|
[x]
Attachment Details
|
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 04.24.2008 at 09:39AM PDT, ID: 21432748 |
| 04.24.2008 at 11:53PM PDT, ID: 21437464 |
| 05.03.2008 at 07:27AM PDT, ID: 21492458 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: |
shape reactangle(P1,P2)
viewport V(V1,V2)
zoomFactor Z // default Z=1
displacement D(dx,dy) // defauly dx=0, dy=0
function render(shapes, Z, D)
{
foreach shape
s1.x = P1.x * Z - dx
s1.y = P1.y * Z - dy
s2.x = P2.x * Z - dx
s2.y = P2.y * Z - dy
draw shape(s1,s2)
}
|
| 05.03.2008 at 07:35AM PDT, ID: 21492490 |
| 05.03.2008 at 09:26AM PDT, ID: 21492822 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: |
void DrawRectangle(HDC hdc,POINT point,HPEN pencolor,
int x1, int y1, int x2, int y2, // shape end points
float Z
{
int dx,dy; // displacement
dx=Width/2; dy=Height/2; // middle size of the viewport
MoveToEx(hdc,(x1-dx)*Z+dx, (y1-dy)*Z+dy, &point);
LineTo(hdc, (x2-dx)*Z+dx, (y1-dy)*Z+dy);
LineTo(hdc, (x2-dx)*Z+dx, (y2-dy)*Z+dy);
LineTo(hdc, (x1-dx)*Z+dx, (y2-dy)*Z+dy);
LineTo(hdc, (x1-dx)*Z+dx, (y1-dy)*Z+dy);
}
|
| 05.10.2008 at 03:53AM PDT, ID: 21538460 |
| 05.10.2008 at 03:48PM PDT, ID: 21540816 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: |
Code to call the DrawRectangles function:
DrawRectangles(hdc,point,penBlue,100,50, 250,135,zoom)
DrawRectangles(hdc,point,penRed,180,97,350,258,zoom)
Code of DrawRectangles function
void DrawRectangle(HDC hdc,POINT point,HPEN pencolor, x1, y1, x2, y2, double Z)
{
dx=Width/2; dy=Height/2; <-- equivalent to put orign at center of the viewport
x1 = (int)((x1-dx+offsetx)*Z)+dx; y1 = (int)((y1-dy)*Z)+dy;
x2 = (int)((x2-dx+offsetx)*Z)+dx; y2 = (int)((y2-dy)*Z)+dy;
SelectObject(hdc, pencolor);
MoveToEx(hdc,x1-1, y1, &point);
LineTo( hdc, x2, y1);
LineTo( hdc, x2, y2);
LineTo( hdc, x1, y2);
LineTo( hdc, x1, y1);
}
|