h3

类别:编程语言 点击:0 评论:0 推荐:
Homework Assignment #3  - Enhanced version of SimpleDraw   SimpleDraw is a 2D graphics drawing product.  In homework assignment #2, we already wrote the core engine of the graphics system to implements the abstraction of a drawing, this time we need work out the enhanced core engine of and add more features.   A drawing is defined as a 2D space (canvas) that contains an unlimited number of drawing primitives.  Canvas has initial size, use a unified x,y coordinate system ( left corner is 0.0, 0.0 ) to define Canvas can set backgroud color (black, white, grey, red, green, blue, yellow) and border type  (thin, heavy, none) Each drawing primitives (element) in canvas must has his center within the range of canvas.   There are 4 drawing primitives (element) defined:   1. dot 2. ellipse (width, height) 3. rectangle (width, height) 4. polygon (diameter, vertex)   Element use centre point to represent its location (x,y) Element can be set different foreground color (black, white, grey, red, green, blue, yellow ) Element can use different kind of line type (solid, dash, dot) to display   Canvas can support zoom in/out operation, at same time, elements in drawing also support zoom in/out with the same ratio as canvas. (zoom in/out base on its centre point)   Your software need to support draw function to out the result of drawing, but it not means you really need use DC to draw the canvas and those elements on screen, just display the drawing in the following format:   Drawing Name: Drawing 1                     <-- drawing info Background color: White Border type: none Zoom level: 2.5 Total number of elements: 59 Canvas Size: 1020, 768   Element1: Ellipse                                <-- here begin the elements info Location: 0, 10 Color: red Width: 100 Heigh: 400   Element2: Rectangle Location: 30, 78 Color: black Width: 500 Height:800   Element3: Dot Location: 500, 600 Color: yellow   .....   Primitive59: Polygon Location 100, 600 Color: green diameter: 250 vertex: 6     Note: 1) coordinate system use double value to represent 2) zoom level use double value to represent 3) vertex in polygon means the number of vertex (>=3, <=32) 4) each element has same format in displaying their information, but the content is different, some feature only available in given element    e.g. Dot without width and height, Polygon has diameter and vertex

#ifndef CANVAS_H
#define CANVAS_H typedef double Coordinate;
typedef enum Colors{black, white, grey, red, green, blue ,yellow}Colors;
class Canvas{
    public:
        Canvas();
        ~Canvas(); 
    private:
        Coordinate x_, y_;
        Colors backgroudColor_;
       
}; #endif //CANVAS_H

本文地址:http://com.8s8s.com/it/it25920.htm