Skip to content

Commit

Permalink
[#15] Couple of image functions and fix bug with bgcolor option
Browse files Browse the repository at this point in the history
  • Loading branch information
jfacorro committed Dec 2, 2018
1 parent d416520 commit b52cb37
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/quil.core.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- [x] [`atan2`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L423) - "Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis"
- [ ] [`available-fonts`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L441) - "A sequence of strings representing the fonts on this system available for use"
- [x] [`background`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L462) - "Sets the color used for the background of the Processing window"
- [ ] [`background-image`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L482) - "Specify an image to be used as the background for a sketch"
- [x] [`background-image`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L482) - "Specify an image to be used as the background for a sketch"
- [ ] [`begin-camera`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L495) - "Sets the matrix mode to the camera matrix so calls such as translate, rotate, apply-matrix and reset-matrix affect the camera"
- [ ] [`begin-contour`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L512) - "Use the begin-contour and end-contour function to create negative shapes within shapes"
- [ ] [`begin-raw`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L527) - "Enables the creation of vectors from 3D data"
Expand All @@ -28,7 +28,7 @@
- [ ] [`bezier-tangent`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L632) - "Calculates the tangent of a point on a Bezier curve"
- [ ] [`bezier-vertex`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L645) - "Specifies vertex coordinates for Bezier curves"
- [ ] [`binary`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L671) - "Returns a string representing the binary value of an int, char or byte"
- [ ] [`blend`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L688) - "Blends a region of pixels from one image into another with full alpha channel support"
- [ ] [`blend`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L688) - "Blends a region of pixels from one image into another with full alpha channel support"
- [ ] [`blend-color`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L737) - "Blends two color values together based on the blending mode given specified with the mode keyword"
- [ ] [`blend-mode`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L781) - "Blends the pixels in the display window according to the defined mode"
- [ ] [`blend-modes`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L51)
Expand All @@ -46,7 +46,7 @@
- [x] [`cos`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1021) - "Calculates the cosine of an angle"
- [ ] [`create-font`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1050) - "Dynamically converts a font to the format used by Processing (a PFont) from either a font name that's installed on the computer, or from a "
- [ ] [`create-graphics`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1087) - "Creates and returns a new PGraphics object of the types :p2d, :p3d, :java2d, :pdf"
- [ ] [`create-image`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1126) - "Creates a new PImage (the datatype for storing images)"
- [x] [`create-image`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1126) - "Creates a new PImage (the datatype for storing images)"
- [x] [`current-fill`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1147) - "Return the current fill color"
- [x] [`current-frame-rate`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L1693) - "Returns the current framerate"
- [ ] [`current-graphics`](https://github.com/quil/quil/blob/2.8.0/src/cljc/quil/core.cljc#L32) - "Graphics currently used for drawing"
Expand Down
14 changes: 14 additions & 0 deletions src/doodler/core.clje
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@
(let* [#erl[_ _ _ min max _] (hsb-helper color)]
(/ (+ min max) 2)))

;; Image

(defn background-image
[img]
(wxDC/drawBitmap *canvas* img #erl[0 0]))

(defn create-image
[w h]
(wxBitmap/new w h))

;; Stroke & fill

(defn- save-current-stroke
Expand Down Expand Up @@ -315,10 +325,14 @@
([x y w h r]
(wxDC/drawRoundedRectangle *canvas* #erl[x y] #erl[w h] r)))

;; Text

(defn text
[s x y]
(wxDC/drawText *canvas* s #erl[x y]))

;; Dimension

(defn width
[]
(:width *sketch*))
Expand Down
6 changes: 4 additions & 2 deletions src/doodler/sketch.clje
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
features)
canvas (gui/make-canvas frame)

bgcolor (apply core/color (:bgcolor opts))
bgcolor (when-let [bgcolor (:bgcolor opts)]
(apply core/color bgcolor))

draw-fn (or (:draw opts) u/no-fn)
setup-fn (or (:setup opts) u/no-fn)
Expand All @@ -147,7 +148,8 @@
(e/listen canvas event-name))

;; Set background color before showing the frame
(wxWindow/setBackgroundColour canvas bgcolor)
(when bgcolor
(wxWindow/setBackgroundColour canvas bgcolor))

;; Show frame, maybe in fullscreen
(wxFrame/showFullScreen frame (:present features))
Expand Down

0 comments on commit b52cb37

Please sign in to comment.