forked from overtone/overtone
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on stepinator - monophonic sequencer.
* starting on basic color theme support * fixing ir? check function so duty works with a numeric reset argument * trying (unsuccessfully) to get adjustment-popup working with stepinator - (Dave Ray, help! ;-) * using with-error-log to catch exceptions in swing thread handlers
- Loading branch information
Showing
7 changed files
with
220 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
(ns overtone.gui.color | ||
(:use [seesaw core color])) | ||
|
||
(def theme* (atom | ||
{ | ||
:background-fill (color 40 40 40) | ||
:background-stroke (color 30 30 30) | ||
|
||
:highlight (color 100 100 255) | ||
|
||
:fill-1 (color 0 130 226 150) | ||
:stroke-1 (color 0 140 236) | ||
|
||
:fill-2 (color 170 170 170 150) | ||
:stroke-2 (color 170 170 170) | ||
|
||
:fill-3 (color 170 30 30 150) | ||
:stroke-3 (color 170 30 30) | ||
|
||
:bounding-box (color 250 20 20 150) | ||
})) | ||
|
||
(defn theme-color [tag] | ||
(get @theme* tag)) | ||
|
||
(defn adjust-brightness | ||
"Adjust color brightness by adding an amount to each of red, green, and blue." | ||
([color amount] | ||
(let [{:keys [red green blue]} (bean color)] | ||
(color (max 0 (+ red amount)) | ||
(max 0 (+ green amount)) | ||
(max 0 (+ blue amount)))))) | ||
|
||
(defn darken-color | ||
"Darken a color in steps of -10 for each of r, g, and b." | ||
([color] (adjust-brightness color 1)) | ||
([color factor] | ||
(adjust-brightness color (* factor -10)))) | ||
|
||
(defn lighten-color | ||
"Lighten a color in steps of 10 for each of r, g, and b." | ||
([color] (lighten-color color 1)) | ||
([color factor] | ||
(adjust-brightness color (* factor 10)))) | ||
|
||
(defn clarify-color | ||
"Increase the color transparency in steps of 10." | ||
([color] (clarify-color color 1)) | ||
([color factor] | ||
(let [r (.getRed color) | ||
g (.getGreen color) | ||
b (.getBlue color)] | ||
(color r g b (- (.getTransparency color) (* factor 10)))))) |
Oops, something went wrong.