├── .gitignore
├── LICENSE
├── README.md
├── Spectrum.Demo
├── Spectrum.Demo.Shared
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Controls
│ │ └── UniformGrid.cs
│ ├── Converters
│ │ ├── ColorHexConveter.cs
│ │ ├── ColorToBrushConverter.cs
│ │ └── StringFormatConverter.cs
│ ├── Extensions
│ │ ├── ComparableExtensions.cs
│ │ ├── EnumerableExtensions.cs
│ │ └── StoryboardExtensions.cs
│ ├── Resources
│ │ ├── Fonts
│ │ │ └── Lobster-Regular.ttf
│ │ └── Styles.Shared.xaml
│ ├── Services
│ │ ├── AppSettingsService.cs
│ │ ├── BitmapService.cs
│ │ ├── ColorConverter.cs
│ │ ├── IAppSettingsService.cs
│ │ ├── IBitmapService.cs
│ │ ├── ISchemeStorageService.cs
│ │ ├── ITileService.cs
│ │ ├── IWindowManager.cs
│ │ ├── Scheme.cs
│ │ ├── SchemeStorageService.cs
│ │ ├── SchemeType.cs
│ │ ├── TileService.cs
│ │ └── TileSize.cs
│ ├── Spectrum.Demo.Shared.projitems
│ ├── Spectrum.Demo.Shared.shproj
│ ├── ViewModels
│ │ ├── EditSchemeViewModel.cs
│ │ ├── Editors
│ │ │ ├── AnalogousSchemeEditorViewModel.cs
│ │ │ ├── ColourViewModel.cs
│ │ │ ├── ComplimentarySchemeEditorViewModel.cs
│ │ │ ├── CustomSchemeEditorViewModel.cs
│ │ │ ├── EditColourViewModel.cs
│ │ │ ├── MonochromeSchemeEditorViewModel.cs
│ │ │ ├── SchemeEditorViewModelBase.cs
│ │ │ ├── SingleColorSchemeEditorViewModelBase.cs
│ │ │ └── TriadSchemeEditorViewModel.cs
│ │ ├── SaveSchemeViewModel.cs
│ │ ├── SchemeListViewModel.cs
│ │ ├── SchemeTypeViewModel.cs
│ │ └── SchemeViewModel.cs
│ └── Views
│ │ ├── Editors
│ │ ├── EditColourView.xaml
│ │ ├── EditColourView.xaml.cs
│ │ └── IColourView.cs
│ │ ├── SaveSchemeView.xaml
│ │ ├── SaveSchemeView.xaml.cs
│ │ ├── SchemeView.xaml
│ │ └── SchemeView.xaml.cs
├── Spectrum.Demo.Windows
│ ├── BundleArtifacts
│ │ └── neutral.txt
│ ├── Controls
│ │ ├── DialogAction.cs
│ │ ├── DialogContentControl.cs
│ │ └── DialogDismissedEventArgs.cs
│ ├── FodyWeavers.xml
│ ├── Package.StoreAssociation.xml
│ ├── Package.appxmanifest
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Resources
│ │ ├── Images
│ │ │ ├── Splash.scale-100.png
│ │ │ ├── Splash.scale-140.png
│ │ │ ├── Splash.scale-180.png
│ │ │ ├── Square150.scale-100.png
│ │ │ ├── Square150.scale-140.png
│ │ │ ├── Square150.scale-180.png
│ │ │ ├── Square30.scale-100.png
│ │ │ ├── Square30.scale-140.png
│ │ │ ├── Square30.scale-180.png
│ │ │ ├── Square50.scale-100.png
│ │ │ ├── Square50.scale-140.png
│ │ │ ├── Square50.scale-180.png
│ │ │ ├── Square70.scale-100.png
│ │ │ ├── Square70.scale-140.png
│ │ │ ├── Square70.scale-180.png
│ │ │ ├── Wide.scale-100.png
│ │ │ ├── Wide.scale-140.png
│ │ │ └── Wide.scale-180.png
│ │ └── Styles.xaml
│ ├── Services
│ │ └── WindowManager.cs
│ ├── Spectrum.Demo.Windows.csproj
│ ├── Themes
│ │ └── Generic.xaml
│ ├── Views
│ │ ├── EditSchemeView.xaml
│ │ ├── EditSchemeView.xaml.cs
│ │ ├── Editors
│ │ │ ├── AnalogousSchemeEditorView.xaml
│ │ │ ├── AnalogousSchemeEditorView.xaml.cs
│ │ │ ├── ColourView.xaml
│ │ │ ├── ColourView.xaml.cs
│ │ │ ├── ComplimentarySchemeEditorView.xaml
│ │ │ ├── ComplimentarySchemeEditorView.xaml.cs
│ │ │ ├── CustomSchemeEditorView.xaml
│ │ │ ├── CustomSchemeEditorView.xaml.cs
│ │ │ ├── DerivedColourView.xaml
│ │ │ ├── DerivedColourView.xaml.cs
│ │ │ ├── MonochromeSchemeEditorView.xaml
│ │ │ ├── MonochromeSchemeEditorView.xaml.cs
│ │ │ ├── SingleColorSchemeEditorViewBase.cs
│ │ │ ├── TriadSchemeEditorView.xaml
│ │ │ └── TriadSchemeEditorView.xaml.cs
│ │ ├── SchemeListView.xaml
│ │ └── SchemeListView.xaml.cs
│ └── packages.config
└── Spectrum.Demo.WindowsPhone
│ ├── BundleArtifacts
│ └── neutral.txt
│ ├── FodyWeavers.xml
│ ├── Package.StoreAssociation.xml
│ ├── Package.appxmanifest
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Resources
│ ├── Images
│ │ ├── Splash.scale-100.png
│ │ ├── Splash.scale-140.png
│ │ ├── Splash.scale-240.png
│ │ ├── Square150.scale-100.png
│ │ ├── Square150.scale-140.png
│ │ ├── Square150.scale-240.png
│ │ ├── Square44.scale-100.png
│ │ ├── Square44.scale-140.png
│ │ ├── Square44.scale-240.png
│ │ ├── Square50.scale-100.png
│ │ ├── Square50.scale-140.png
│ │ ├── Square50.scale-240.png
│ │ ├── Square71.scale-100.png
│ │ ├── Square71.scale-140.png
│ │ ├── Square71.scale-240.png
│ │ ├── Wide.scale-100.png
│ │ ├── Wide.scale-140.png
│ │ └── Wide.scale-240.png
│ └── Styles.xaml
│ ├── Services
│ └── WindowManager.cs
│ ├── Spectrum.Demo.WindowsPhone.csproj
│ ├── Views
│ ├── EditSchemeView.xaml
│ ├── EditSchemeView.xaml.cs
│ ├── Editors
│ │ ├── AnalogousSchemeEditorView.xaml
│ │ ├── AnalogousSchemeEditorView.xaml.cs
│ │ ├── ColourView.xaml
│ │ ├── ColourView.xaml.cs
│ │ ├── ComplimentarySchemeEditorView.xaml
│ │ ├── ComplimentarySchemeEditorView.xaml.cs
│ │ ├── CustomSchemeEditorView.xaml
│ │ ├── CustomSchemeEditorView.xaml.cs
│ │ ├── DerivedColourView.xaml
│ │ ├── DerivedColourView.xaml.cs
│ │ ├── MonochromeSchemeEditorView.xaml
│ │ ├── MonochromeSchemeEditorView.xaml.cs
│ │ ├── SingleColorSchemeEditorViewBase.cs
│ │ ├── TriadSchemeEditorView.xaml
│ │ └── TriadSchemeEditorView.xaml.cs
│ ├── SchemeListView.xaml
│ └── SchemeListView.xaml.cs
│ └── packages.config
├── Spectrum.Tests
├── ColorTests.HSL.cs
├── ColorTests.HSV.cs
├── ColorTests.RGB.cs
├── Properties
│ └── AssemblyInfo.cs
└── Spectrum.Tests.csproj
├── Spectrum.Universal
├── Color.RGB.Extensions.cs
├── Converters
│ ├── ComplimentConverter.cs
│ ├── ForegroundTextConverter.cs
│ ├── ShiftHueConverter.cs
│ ├── ShiftLightnessConverter.cs
│ └── ShiftSaturationConverter.cs
├── Properties
│ └── AssemblyInfo.cs
└── Spectrum.Universal.csproj
├── Spectrum.sln
├── Spectrum
├── Color.HSL.cs
├── Color.HSV.cs
├── Color.RGB.cs
├── DoubleExtensions.cs
├── Properties
│ └── AssemblyInfo.cs
└── Spectrum.csproj
├── design
├── Splash.Windows.design
├── Splash.design
├── Square.design
└── Wide.design
└── tools
└── nuget
├── NuGet.exe
├── Spectrum.Universal.nuspec
├── Spectrum.nuspec
└── build-packages.ps1
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | [Rr]eleases/
14 | x64/
15 | x86/
16 | build/
17 | bld/
18 | [Bb]in/
19 | [Oo]bj/
20 |
21 | # Roslyn cache directories
22 | *.ide/
23 |
24 | # MSTest test Results
25 | [Tt]est[Rr]esult*/
26 | [Bb]uild[Ll]og.*
27 |
28 | #NUNIT
29 | *.VisualState.xml
30 | TestResult.xml
31 |
32 | # Build Results of an ATL Project
33 | [Dd]ebugPS/
34 | [Rr]eleasePS/
35 | dlldata.c
36 |
37 | *_i.c
38 | *_p.c
39 | *_i.h
40 | *.ilk
41 | *.meta
42 | *.obj
43 | *.pch
44 | *.pdb
45 | *.pgc
46 | *.pgd
47 | *.rsp
48 | *.sbr
49 | *.tlb
50 | *.tli
51 | *.tlh
52 | *.tmp
53 | *.tmp_proj
54 | *.log
55 | *.vspscc
56 | *.vssscc
57 | .builds
58 | *.pidb
59 | *.svclog
60 | *.scc
61 |
62 | # Chutzpah Test files
63 | _Chutzpah*
64 |
65 | # Visual C++ cache files
66 | ipch/
67 | *.aps
68 | *.ncb
69 | *.opensdf
70 | *.sdf
71 | *.cachefile
72 |
73 | # Visual Studio profiler
74 | *.psess
75 | *.vsp
76 | *.vspx
77 |
78 | # TFS 2012 Local Workspace
79 | $tf/
80 |
81 | # Guidance Automation Toolkit
82 | *.gpState
83 |
84 | # ReSharper is a .NET coding add-in
85 | _ReSharper*/
86 | *.[Rr]e[Ss]harper
87 | *.DotSettings.user
88 |
89 | # JustCode is a .NET coding addin-in
90 | .JustCode
91 |
92 | # TeamCity is a build add-in
93 | _TeamCity*
94 |
95 | # DotCover is a Code Coverage Tool
96 | *.dotCover
97 |
98 | # NCrunch
99 | _NCrunch_*
100 | .*crunch*.local.xml
101 |
102 | # MightyMoose
103 | *.mm.*
104 | AutoTest.Net/
105 |
106 | # Web workbench (sass)
107 | .sass-cache/
108 |
109 | # Installshield output folder
110 | [Ee]xpress/
111 |
112 | # DocProject is a documentation generator add-in
113 | DocProject/buildhelp/
114 | DocProject/Help/*.HxT
115 | DocProject/Help/*.HxC
116 | DocProject/Help/*.hhc
117 | DocProject/Help/*.hhk
118 | DocProject/Help/*.hhp
119 | DocProject/Help/Html2
120 | DocProject/Help/html
121 |
122 | # Click-Once directory
123 | publish/
124 |
125 | # Publish Web Output
126 | *.[Pp]ublish.xml
127 | *.azurePubxml
128 | # TODO: Comment the next line if you want to checkin your web deploy settings
129 | # but database connection strings (with potential passwords) will be unencrypted
130 | *.pubxml
131 | *.publishproj
132 |
133 | # NuGet Packages
134 | *.nupkg
135 | # The packages folder can be ignored because of Package Restore
136 | **/packages/*
137 | # except build/, which is used as an MSBuild target.
138 | !**/packages/build/
139 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
140 | #!**/packages/repositories.config
141 |
142 | # Windows Azure Build Output
143 | csx/
144 | *.build.csdef
145 |
146 | # Windows Store app package directory
147 | AppPackages/
148 |
149 | # Others
150 | sql/
151 | *.Cache
152 | ClientBin/
153 | [Ss]tyle[Cc]op.*
154 | ~$*
155 | *~
156 | *.dbmdl
157 | *.dbproj.schemaview
158 | *.pfx
159 | *.publishsettings
160 | node_modules/
161 |
162 | # RIA/Silverlight projects
163 | Generated_Code/
164 |
165 | # Backup & report files from converting an old project file
166 | # to a newer Visual Studio version. Backup files are not needed,
167 | # because we have git ;-)
168 | _UpgradeReport_Files/
169 | Backup*/
170 | UpgradeLog*.XML
171 | UpgradeLog*.htm
172 |
173 | # SQL Server files
174 | *.mdf
175 | *.ldf
176 |
177 | # Business Intelligence projects
178 | *.rdl.data
179 | *.bim.layout
180 | *.bim_*.settings
181 |
182 | # Microsoft Fakes
183 | FakesAssemblies/
184 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Spectrum
2 |
3 | ## What is it?
4 |
5 | Spectrum is a library to manipulate colours in the .NET framework, specifically in the RGB, HSL and HSV colour spaces.
6 |
7 | It's currently not designed to the be all and end all in terms of colour but more to assist developers in building harmonious colour schemes for their applications.
8 |
9 | It exists as two parts:
10 |
11 | 1. **Spectrum** is the core library that contains the classes you'd expect in a library such as this. It's a portable class library covering all the major platforms (math is very portable).
12 | 2. **Spectrum.Universal** is the interesting part and is where I hope to extend most of all, it's a playground for how we can use colour space calculations in our apps. It's portable across Windows 8 and Windows Phone 8.1.
13 |
14 | ## How does it work?
15 |
16 | The core Spectrum library has only three classes `Color.RGB`, `Color.HSL` and `Color.HSV`, these naturally have methods to convert between themselves.
17 |
18 | ``` csharp
19 | var accent = new Color.RGB(240, 150, 9);
20 |
21 | var hsl = accent.ToHSL();
22 |
23 | Assert.AreEqual(new Color.HSL(36.6, 0.928, 0.488), hsl);
24 | ```
25 |
26 | The `Color.HSL` class has number of helper methods to create other related colours.
27 |
28 | ``` csharp
29 | var hsl = new Color.HSL(90, 0.5, 0.5);
30 |
31 | var compliment = hsl.ShiftHue(180.0d);
32 |
33 | var analogous = hsl.GetAnalogous();
34 | ```
35 |
36 | It gets more interesting when we start to use **Spectrum.Universal**. This contains a few Xaml Value Converters that can shift between `Windows.UI.Color` instances for us.
37 |
38 | Given resource declarations like the following:
39 |
40 | ``` xml
41 |
42 |
43 |
44 | ```
45 |
46 | and our base accent colour:
47 |
48 | ``` xml
49 | #FF0088D1
50 |
51 | ```
52 |
53 | We can create lighter and darker versions of that same colour using
54 |
55 | ``` xml
56 |
61 |
62 |
67 | ```
68 |
69 | as well as create a minor accent colour
70 |
71 | ``` xml
72 |
77 | ```
78 |
79 | We can now manage an app's full palatte of colour resources by tweaking a few base colours.
80 |
81 | ## Where I can get this?
82 |
83 | Source is obviously here, and is also on [nuget](http://www.nuget.org/packages/Spectrum.Universal/).
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Spectrum.Demo/Spectrum.Demo.Shared/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Spectrum.Demo/Spectrum.Demo.Shared/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Windows.ApplicationModel.Activation;
4 | using Windows.UI.ViewManagement;
5 | using Windows.UI.Xaml.Controls;
6 | using Caliburn.Micro;
7 | using Spectrum.Demo.Services;
8 | using Spectrum.Demo.ViewModels;
9 | using Spectrum.Demo.Views;
10 |
11 | namespace Spectrum.Demo
12 | {
13 | public sealed partial class App
14 | {
15 | private WinRTContainer container;
16 |
17 | public App()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | protected override void Configure()
23 | {
24 | var baseGetLog = LogManager.GetLog;
25 |
26 | LogManager.GetLog = t => t == typeof (ViewModelBinder) ? new DebugLog(t) : baseGetLog(t);
27 |
28 | ConfigureSpecialValues();
29 |
30 | container = new WinRTContainer();
31 |
32 | container.RegisterWinRTServices();
33 |
34 | container
35 | .Singleton()
36 | .Singleton()
37 | .Singleton()
38 | .Singleton()
39 | .Singleton();
40 |
41 | container
42 | .PerRequest()
43 | .PerRequest();
44 |
45 | container.RegisterSharingService();
46 |
47 | #if WINDOWS_PHONE_APP
48 | var statusBar = StatusBar.GetForCurrentView();
49 |
50 | statusBar.HideAsync();
51 | #endif
52 |
53 | var tileService = container.GetInstance();
54 |
55 | tileService.Initialise();
56 | }
57 |
58 | private static void ConfigureSpecialValues()
59 | {
60 | MessageBinder.SpecialValues.Add("$clickeditem", c => ((ItemClickEventArgs)c.EventArgs).ClickedItem);
61 | }
62 |
63 | protected override void PrepareViewFirst(Frame rootFrame)
64 | {
65 | container.RegisterNavigationService(rootFrame);
66 | }
67 |
68 | protected override void OnLaunched(LaunchActivatedEventArgs args)
69 | {
70 | DisplayRootView();
71 | }
72 |
73 | protected override void BuildUp(object instance)
74 | {
75 | container.BuildUp(instance);
76 | }
77 |
78 | protected override IEnumerable