1- # ColorTheme demo showing the following:
2- # - construction of TColor themes via textual descriptions of shades and Colors
3- # - adding an rand element to the theme
4- #
5- # Press SPACE to toggle rendering mode, any other key will re-generate a
6- # random variation of the color theme
7- #
8- # @author Karsten Schmidt <info at postspectacular dot com>
9- # Copyright (c) 2009 Karsten Schmidt
10- #
11- # This demo & library is free software you can redistribute it and/or
12- # modify it under the terms of the GNU Lesser General Public
13- # License as published by the Free Software Foundation either
14- # version 2.1 of the License, or (at your option) any later version.
15- #
16- # http://creativecommons.org/licenses/LGPL/2.1/
17- #
18- # This library is distributed in the hope that it will be useful,
19- # but WITHOUT ANY WARRANTY without even the implied warranty of
20- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21- # Lesser General Public License for more details.
22- #
23- # You should have received a copy of the GNU Lesser General Public
24- # License along with this library if not, write to the Free Software
25- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
261
272require 'toxiclibs'
28- include_package 'toxi.color'
29- include_package 'toxi.util.datatypes'
303
314SWATCH_HEIGHT = 40.0
325SWATCH_WIDTH = 5.0
@@ -50,15 +23,15 @@ def setup
5023
5124def draw
5225 # first define our new theme
53- t = ColorTheme . new ( 'test' )
26+ t = Toxi :: ColorTheme . new ( 'test' )
5427 # add different color options, each with their own weight
5528 t . add_range ( 'soft ivory' , 0.5 )
5629 t . add_range ( 'intense goldenrod' , 0.25 )
5730 t . add_range ( 'warm saddlebrown' , 0.15 )
5831 t . add_range ( 'fresh teal' , 0.05 )
5932 t . add_range ( 'bright yellowgreen' , 0.05 )
6033 # now add another rand hue which is using only bright shades
61- t . add_range ( ColorRange ::BRIGHT , TColor . new_random , rand ( 0.02 ..0.05 ) )
34+ t . add_range ( Toxi :: ColorRange ::BRIGHT , TColor . new_random , rand ( 0.02 ..0.05 ) )
6235 # use the TColor theme to create a list of 160 Colors
6336 list = t . get_colors ( 160 )
6437 if show_discs
@@ -70,19 +43,19 @@ def draw
7043 list . sort_by_distance ( false )
7144 swatches ( list , 32 , yoff )
7245 yoff += SWATCH_HEIGHT + 10
73- list . sort_by_criteria ( AccessCriteria ::LUMINANCE , false )
46+ list . sort_by_criteria ( Toxi :: AccessCriteria ::LUMINANCE , false )
7447 swatches ( list , 32 , yoff )
7548 yoff += SWATCH_HEIGHT + 10
76- list . sort_by_criteria ( AccessCriteria ::BRIGHTNESS , false )
49+ list . sort_by_criteria ( Toxi :: AccessCriteria ::BRIGHTNESS , false )
7750 swatches ( list , 32 , yoff )
7851 yoff += SWATCH_HEIGHT + 10
79- list . sort_by_criteria ( AccessCriteria ::SATURATION , false )
52+ list . sort_by_criteria ( Toxi :: AccessCriteria ::SATURATION , false )
8053 swatches ( list , 32 , yoff )
8154 yoff += SWATCH_HEIGHT + 10
82- list . sort_by_criteria ( AccessCriteria ::HUE , false )
55+ list . sort_by_criteria ( Toxi :: AccessCriteria ::HUE , false )
8356 swatches ( list , 32 , yoff )
8457 yoff += SWATCH_HEIGHT + 10
85- list . sort_by_proximity_to ( NamedColor ::WHITE , RGBDistanceProxy . new , false )
58+ list . sort_by_proximity_to ( Toxi :: NamedColor ::WHITE , RGBDistanceProxy . new , false )
8659 swatches ( list , 32 , yoff )
8760 end
8861 # save_frame(format('theme-%s%s', timestamp, '_##.png'))
0 commit comments