   * `:dilate`    - increases the light areas. Doesn't work with level."
   ([mode]
    (.filter (current-graphics)
-            (u/resolve-constant-key mode filter-modes)))
+            (int (u/resolve-constant-key mode filter-modes))))
 
   ([mode level]
-   (let [mode (u/resolve-constant-key mode filter-modes)]
+   (let [mode (int (u/resolve-constant-key mode filter-modes))]
      (.filter (current-graphics) mode (float level)))))
 
 #?(:clj

  "Returns true if object is loaded."
  [object]
  (condp = (type object)
    #?@(:clj  (PImage (pos? (.-width object))
               ; shader is loaded synchronously
                      PShader true)
        :cljs (js/p5.Shader (and (aget object "_vertSrc") (aget object "_fragSrc"))

        ; instead we convert extract alphas into array and use array version of mask()
        ; see https://processing.org/reference/PImage_mask_.html
      (let [pxls (pixels mask)
            ^ints alphas (amap ^ints pxls idx ret (int (alpha (aget ^ints pxls idx))))]
        (.mask img alphas))
      :cljs (.mask img mask))))

