   Transformations such as translate, rotate, and scale do not work within
   begin-shape. It is also not possible to use other shapes, such as ellipse
   or rect within begin-shape."
-  ([] `(.beginShape *applet*))
+  ([] (.beginShape *applet*))
   ([mode]
-     (let [kind (shapes-map mode)]
-       `(.beginShape *applet* (int ~kind)))))
+     (let [mode (resolve-shape-mode  mode)]
+       (.beginShape *applet* (int mode)))))
 
 (defn bezier
   "Draws a Bezier curve on the screen. These curves are defined by a series of

             :dodge DODGE
             :burn BURN})

(defn- resolve-mode
  [mode]
  (if (keyword? mode)
    (get blend-map mode)
    mode))

(defmacro blend
  "Blends a region of pixels from one image into another (or in itself again) with full alpha channel support."
  ([x y width height dx dy dwidth dheight mode]
     (let [mode (resolve-mode mode)]
       `(.blend *applet* (int x) (int y) (int width) (int height)
                (int dx) (int dy) (int dwidth) (int dheight) (int ~mode))))
  ([^PImage src x y width height dx dy dwidth dheight mode]
     (let [mode (resolve-mode mode)]
       `(.blend *applet* src (int x) (int y) (int width) (int height)
                (int dx) (int dy) (int dwidth) (int dheight) (int ~mode)))))

(defn blend-color
  [c1 c2 mode] (PApplet/blendColor (int c1) (int c2) (int mode)))

(defn blue [what] (.blue *applet* (int what)))

(defn box
  ([size] (.box *applet* (int size)))
  ([w h d] (.box *applet* (float w) (float h) (float d))))

(defn brightness [what] (.brightness *applet* (int what)))

(defn camera
  ([] (.camera *applet*))
  ([eyeX eyeY eyeZ centerX centerY centerZ upX upY upZ]
     (.camera *applet* (float eyeX) (float eyeY) (float eyeZ)


(defn can-draw? [] (.canDraw *applet*))

(defn ceil
  "Calculates the closest int value that is greater than or equal to the value
  of the parameter. For example, (ceil 9.03) returns the value 10."
  [n]
  (PApplet/ceil (float n)))

(defn color-float
  ([gray] (.color *applet* (float gray)))
