CS 345: Spring 2025

Programming Assignment 1

Building Blocks

We are now ready to begin creating our graphics library.
    class GCanvas {
    public:
        virtual ~GCanvas() {}
    
        /**
         *  Fill the entire canvas with the specified color, using SRC porter-duff mode.
         */
        virtual void clear(const GColor&) = 0;
        
        /**
         *  Fill the rectangle with the color, using SRC_OVER porter-duff mode.
         *
         *  The affected pixels are those whose centers are "contained" inside the rectangle:
         *      e.g. contained == center > min_edge && center <= max_edge
         *
         *  Any area in the rectangle that is outside of the bounds of the canvas is ignored.
         */
        virtual void fillRect(const GRect&, const GColor&) = 0;
    };

    /**
     *  Implemnt this, returning an instance of your subclass of GCanvas.
     */
    std::unique_ptr<GCanvas> GCreateCanvas(const GBitmap&);

    /**
     *  Implement this, drawing into the provided canvas, and returning the title of your artwork.
     */
    std::string GDrawSomething(GCanvas*, GISize dimension);
    
You have 3 tasks:
The pa1 directory will look something like this: Add your files as needed at the root level (whatever .cpp or .h files you need). e.g. To test your code...
    > make
    > ./image -e expected
    > ./tests
    > ./bench
    > ./dbench
    
For more details when testing...
    > mkdir diff
    > ./image -e expected -d diff
    > open diff/index.html
    >
    > ./tests -v
    >
    > ./bench -m substring-to-match
    
       

Bench scores on the VM

   clear         2.01
   rects_blend   6.3
   rects_opaque  0.66
   rect_big      0.35
   rect_tiny     0.34