def createGraphics()

in src/main/groovy/groovy2d/paintingByNumbers.groovy [49:66]


def createGraphics(w, h) {
    def frame = new SwingBuilder().frame(
        title:'Painting by numbers',
        location:[20,20],
        size:[w, h],
        defaultCloseOperation:WC.EXIT_ON_CLOSE
    )
    frame.show()
              
    // obtain graphics context
    def gfx = frame.graphics
              
    // clear screen
    gfx.color = java.awt.Color.BLACK
    gfx.fillRect(0, 0, w, h)

    return gfx
}