11using ScottPlot ;
22using ScottPlot . Plottables ;
3+ using Wacton . Unicolour . Datasets ;
34using Wacton . Unicolour . Example . Diagrams ;
45
56const string outputDirectory = "../../../../Unicolour.Readme/docs/" ;
1516var rgbGamut = Utils . GetRgbGamut ( ) ;
1617var blackbodyLocus = Utils . GetBlackbodyLocus ( ) ;
1718var isotherms = Utils . GetIsotherms ( ) ;
19+ var macAdamLimits = new [ ]
20+ {
21+ MacAdam . Limits10 , MacAdam . Limits20 , MacAdam . Limits30 , MacAdam . Limits40 , MacAdam . Limits50 ,
22+ MacAdam . Limits60 , MacAdam . Limits70 , MacAdam . Limits80 , MacAdam . Limits90 , MacAdam . Limits95
23+ } ;
1824
1925SpectralLocus ( ) ;
2026XyChromaticityWithRgb ( ) ;
2127XyChromaticityWithBlackbody ( ) ;
22- UvChromaticity ( ) ;
28+ XyMacAdamLimits ( ) ;
2329UvChromaticityWithBlackbody ( ) ;
30+ UvMacAdamLimits ( ) ;
2431return ;
2532
2633void SpectralLocus ( )
@@ -129,33 +136,40 @@ void XyChromaticityWithBlackbody()
129136 plot . SavePng ( Path . Combine ( outputDirectory , "diagram-xy-chromaticity-blackbody.png" ) , width , height ) ;
130137}
131138
132- void UvChromaticity ( )
139+ void XyMacAdamLimits ( )
133140{
134- var rangeU = ( 0.0 , 0.7 ) ;
135- var rangeV = ( 0.0 , 0.4 ) ;
136- var plot = Utils . GetEmptyPlot ( rangeU , rangeV , majorTickInterval : 0.05 ) ;
137-
138- var fillMarkers = Utils . GetUvFillMarkers ( rangeU , rangeV , increment : 0.00025 ) ;
139- foreach ( var marker in fillMarkers )
140- {
141- plot . Add . Plottable ( marker ) ;
142- }
141+ var rangeX = ( 0.0 , 0.8 ) ;
142+ var rangeY = ( 0.0 , 0.9 ) ;
143+ var plot = Utils . GetEmptyPlot ( rangeX , rangeY , majorTickInterval : 0.1 ) ;
143144
144- var spectralCoordinates = spectralLocus . Select ( colour => new Coordinates ( colour . Chromaticity . U , colour . Chromaticity . V ) ) . ToList ( ) ;
145+ var spectralCoordinates = spectralLocus . Select ( colour => new Coordinates ( colour . Chromaticity . X , colour . Chromaticity . Y ) ) . ToList ( ) ;
145146 spectralCoordinates . Add ( spectralCoordinates . First ( ) ) ;
146147 var spectralLocusScatter = plot . Add . Scatter ( spectralCoordinates ) ;
147148 spectralLocusScatter . Color = Colors . Black ;
148149 spectralLocusScatter . LineWidth = 2.5f ;
149150 spectralLocusScatter . MarkerStyle = MarkerStyle . None ;
150151
151- var width = Utils . GetWidth ( rangeU , rangeV , height ) ;
152- plot . SavePng ( Path . Combine ( outputDirectory , "diagram-uv-chromaticity.png" ) , width , height ) ;
152+ foreach ( var limits in macAdamLimits )
153+ {
154+ var coordinates = limits . Select ( colour => new Coordinates ( colour . Chromaticity . X , colour . Chromaticity . Y ) ) . ToList ( ) ;
155+ coordinates . Add ( coordinates . First ( ) ) ;
156+ var scatter = plot . Add . Scatter ( coordinates ) ;
157+
158+ var luminance = limits . First ( ) . RelativeLuminance ; // all colours in the group will have the same luminance
159+ var mapColour = Colourmaps . Flare . Map ( 1 - luminance ) . Rgb . Byte255 ;
160+ var color = new Color ( ( byte ) mapColour . R , ( byte ) mapColour . G , ( byte ) mapColour . B ) ;
161+ scatter . LineStyle = new LineStyle { Color = color , Width = 2.5f } ;
162+ scatter . MarkerStyle = MarkerStyle . None ;
163+ }
164+
165+ var width = Utils . GetWidth ( rangeX , rangeY , height ) ;
166+ plot . SavePng ( Path . Combine ( outputDirectory , "diagram-xy-macadam-limits.png" ) , width , height ) ;
153167}
154168
155169void UvChromaticityWithBlackbody ( )
156170{
157- var rangeU = ( 0.1 , 0.45 ) ;
158- var rangeV = ( 0.25 , 0.4 ) ;
171+ var rangeU = ( 0.0 , 0.7 ) ;
172+ var rangeV = ( 0.0 , 0.4 ) ;
159173 var plot = Utils . GetEmptyPlot ( rangeU , rangeV , majorTickInterval : 0.05 ) ;
160174
161175 var fillMarkers = Utils . GetUvFillMarkers ( rangeU , rangeV , increment : 0.00025 ) ;
@@ -170,13 +184,13 @@ void UvChromaticityWithBlackbody()
170184 spectralLocusScatter . Color = Colors . Black ;
171185 spectralLocusScatter . LineWidth = 2.5f ;
172186 spectralLocusScatter . MarkerStyle = MarkerStyle . None ;
173-
187+
174188 var blackbodyCoordinates = blackbodyLocus . Select ( colour => new Coordinates ( colour . Chromaticity . U , colour . Chromaticity . V ) ) . ToList ( ) ;
175189 var blackbodyScatter = plot . Add . Scatter ( blackbodyCoordinates ) ;
176190 blackbodyScatter . Color = Colors . Black ;
177191 blackbodyScatter . LineWidth = 2.5f ;
178192 blackbodyScatter . MarkerStyle = MarkerStyle . None ;
179-
193+
180194 foreach ( var ( startColour , endColour ) in isotherms )
181195 {
182196 var startCoordinates = new Coordinates ( startColour . Chromaticity . U , startColour . Chromaticity . V ) ;
@@ -188,4 +202,34 @@ void UvChromaticityWithBlackbody()
188202
189203 var width = Utils . GetWidth ( rangeU , rangeV , height ) ;
190204 plot . SavePng ( Path . Combine ( outputDirectory , "diagram-uv-chromaticity-blackbody.png" ) , width , height ) ;
205+ }
206+
207+ void UvMacAdamLimits ( )
208+ {
209+ var rangeU = ( 0.0 , 0.7 ) ;
210+ var rangeV = ( 0.0 , 0.4 ) ;
211+ var plot = Utils . GetEmptyPlot ( rangeU , rangeV , majorTickInterval : 0.05 ) ;
212+
213+ var spectralCoordinates = spectralLocus . Select ( colour => new Coordinates ( colour . Chromaticity . U , colour . Chromaticity . V ) ) . ToList ( ) ;
214+ spectralCoordinates . Add ( spectralCoordinates . First ( ) ) ;
215+ var spectralLocusScatter = plot . Add . Scatter ( spectralCoordinates ) ;
216+ spectralLocusScatter . Color = Colors . Black ;
217+ spectralLocusScatter . LineWidth = 2.5f ;
218+ spectralLocusScatter . MarkerStyle = MarkerStyle . None ;
219+
220+ foreach ( var limits in macAdamLimits )
221+ {
222+ var coordinates = limits . Select ( colour => new Coordinates ( colour . Chromaticity . U , colour . Chromaticity . V ) ) . ToList ( ) ;
223+ coordinates . Add ( coordinates . First ( ) ) ;
224+ var scatter = plot . Add . Scatter ( coordinates ) ;
225+
226+ var luminance = limits . First ( ) . RelativeLuminance ; // all colours in the group will have the same luminance
227+ var mapColour = Colourmaps . Flare . Map ( 1 - luminance ) . Rgb . Byte255 ;
228+ var color = new Color ( ( byte ) mapColour . R , ( byte ) mapColour . G , ( byte ) mapColour . B ) ;
229+ scatter . LineStyle = new LineStyle { Color = color , Width = 2.5f } ;
230+ scatter . MarkerStyle = MarkerStyle . None ;
231+ }
232+
233+ var width = Utils . GetWidth ( rangeU , rangeV , height ) ;
234+ plot . SavePng ( Path . Combine ( outputDirectory , "diagram-uv-macadam-limits.png" ) , width , height ) ;
191235}
0 commit comments