mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 18:40:50 +08:00 
			
		
		
		
	Add example infrastructure
* Add "Shared" projects for all examples * Update "Colors" example with better TrueColor demo * Use same namespace for all examples
This commit is contained in:
		
				
					committed by
					
						
						Phil Scott
					
				
			
			
				
	
			
			
			
						parent
						
							2fe2bb3c32
						
					
				
				
					commit
					3545e0f6b5
				
			
							
								
								
									
										15
									
								
								examples/Shared/Extensions/ColorExtensions.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								examples/Shared/Extensions/ColorExtensions.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
namespace Spectre.Console.Examples
 | 
			
		||||
{
 | 
			
		||||
    public static class ColorExtensions
 | 
			
		||||
    {
 | 
			
		||||
        public static Color GetInvertedColor(this Color color)
 | 
			
		||||
        {
 | 
			
		||||
            return GetLuminance(color) < 140 ? Color.White : Color.Black;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static float GetLuminance(this Color color)
 | 
			
		||||
        {
 | 
			
		||||
            return (float)((0.2126 * color.R) + (0.7152 * color.G) + (0.0722 * color.B));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user