Skip to content

Commit

Permalink
menu cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pishty1 committed Dec 9, 2023
1 parent 04d9b46 commit 3de59c8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 38 deletions.
81 changes: 45 additions & 36 deletions src/sketches/menu.cljs
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
(ns sketches.menu
(:require [quil.core :as q]))

(defn draw-menu-item [x y c1 c2 c3]
(q/fill c1 c2 c3)
(q/rect x y 100 100))

(def menu-items
{:padding 10
:menu-list [{:label "Hello"
:color 255}
{:label "World"
:color 155}
{:label "Baby"
:color 15}]})

(defn generate-menu [num]
(map (fn [x] {:label (str "Item " x)
:color (rand-int (rand-int 255))})
(range num)))

(defn draw-menu [is-mobile? number-of-items]
(let [gen-menu (generate-menu number-of-items)
distance (if is-mobile? 300 500)
increments (if is-mobile? 70 100)]
(loop [index 1
menu-list (generate-menu number-of-items)]

(when (seq menu-list)
(let [item (first menu-list)
{:keys [label color]} item
new-x increments
new-y (* index increments)]
(draw-menu-item new-x new-y color color color)
(recur (inc index) (rest menu-list)))))))
(:require [quil.core :as q]))

(defn draw-menu-item [x y h w c1 c2 c3]
(q/fill c1 c2 c3)
(q/rect x y w h))


(defn gen-menu-items []
(let [myrange (range 7)
height 100
width 100]
(loop [index 0
mrange myrange
menu-list []]
(if (seq mrange)
(recur (inc index)
(rest mrange)
(conj menu-list {:label (str "index: " index)
:color (rand-int (rand-int 255))
:height height
:width width
:px 100 ; lets start here and stack them down
:py (+ 100 (* index height))}))
menu-list))))

(def menu-item-list
{:padding 10
:menu-list (gen-menu-items)})

(defn generate-menu [num]
(map (fn [x] {:label (str "Item " x)
:color (rand-int (rand-int 255))})
(range num)))

(defn draw-menu [is-mobile?]
(doseq [{:keys [px py height width color]} (:menu-list menu-item-list)]
(draw-menu-item
px
py
height
width
color
color
color)))


(comment
Expand All @@ -49,5 +59,4 @@
(println (first coll) " with index " index)
(recur (inc index) (rest coll)))))

(myloop)
)
(myloop))
4 changes: 2 additions & 2 deletions src/sketches/tut1.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
:left left :right right :top top :bottom bottom}))

(defn draw-state [{:keys [is-mobile left right top bottom
canvas-x-center canvas-y-center circ-size]} ]
canvas-x-center canvas-y-center circ-size]} ]

(q/background 230 230 230)
(q/stroke 130, 0 0)
(q/stroke-weight 4)

(when (q/mouse-pressed?)
(menu/draw-menu is-mobile 4))
(menu/draw-menu is-mobile))

(q/line left bottom right top)
(q/line right bottom left top)
Expand Down

0 comments on commit 3de59c8

Please sign in to comment.