     return NSMakeRect(CGFloat(x), CGFloat(y), CGFloat(w), CGFloat(h))
 }
 
-struct BitmapCanvas {
+class BitmapCanvas {
     
     let bitmapImageRep : NSBitmapImageRep
     let context : NSGraphicsContext

        context.restoreGraphicsState()
    }
    
    func polygon(points:[NSPoint], stroke stroke_:ConvertibleToNSColor? = NSColor.blackColor(), fill fill_:ConvertibleToNSColor? = nil) {
        
        guard points.count >= 3 else {
            assertionFailure("at least 3 points are needed")

        
        CGContextScaleCTM(cgContext, 1.0, -1.0)
        CGContextTranslateCTM(cgContext, 0.0, -2.0 * p.y - font.pointSize)
        
        text.drawAtPoint(p, withAttributes: attr)
        
        context.restoreGraphicsState()
