Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected midtone color outputs #46

Merged
merged 2 commits into from
Jan 21, 2020
Merged

Conversation

NateBaldwinDesign
Copy link
Collaborator

Description

Lighter midtone base colors were outputting pure white for the generated colors when they should be outputting color.

Switched from using relative luminance as the measure of base color's brightness to a more perceptually uniform lightness value in HSLuv. Both are measured as 0-1 or 0-100 (such as percent), however the mid-value of each is very different. Perceptually, 50% should be the mid-mark, however this is not the case for relative luminance. Chart shows HSLuv value for a set of random colors (blue) vs the relative luminance of those same colors (orange) with a mid-tone mark at 50%
image

The 50% mark is not the sole motivation for switching to HSLuv lightness for calculating when to switch directionality of ratios, but also due to the inaccuracy of the relative luminance formula and the confidence level that is present with the perceptive luminance of colors in HSLuv space.

Specific changes:

  1. In contrast() function, baseV argument can be passed. BaseV is used rather than originally calculating the luminance of the base color as the condition.
  2. In generateContrastColors() function, baseV is defined as the base color's HSLuv lightness value and passed to the contrasts mapping function.
  3. In generateContrastColors() function, baseV is passed through the binary search function rather than the luminance of the base color.
  4. Added tests for bidirectional contrast in lighter & darker midtone colors, right near the split between directionality of generated colors. Tests for pure gray as well as tests for generating orange colors on a slate blue background.

Fixes #31

Motivation

Fix bugs

Screenshots

Screen Shot 2020-01-21 at 9 33 52 AM

Screen Shot 2020-01-21 at 9 34 04 AM

Screen Shot 2020-01-21 at 9 34 35 AM

Screen Shot 2020-01-21 at 9 34 51 AM

To-do list

  • This pull request is ready to merge.

@NateBaldwinDesign NateBaldwinDesign merged commit 5c780b7 into master Jan 21, 2020
@NateBaldwinDesign NateBaldwinDesign removed the request for review from lazd January 21, 2020 16:57
NateBaldwinDesign added a commit that referenced this pull request Feb 18, 2020
* added function for creating base scale

* updated demo contrast enhancement

* initial separation for base-scale package

* more refactoring with separate package

* Revert "updated demo contrast enhancement"

This reverts commit 2c932b2.
Modularization of base-scale to unique package moved to separate branch.

* Fixed revert errors. Updated demo for proper contrast multiplier mapping. Added test to generateBaseScale.

* created  function with tests

* added initial generateAdaptiveTheme function with tests

* feat: generateAdaptiveTheme outputs function allowing user to define theme as a function itself

* trivial: removed array brackets from test arguments for colorspace

* added error throw for missing name in color object

* feat: destructured arguments for generateAdaptiveTheme. Added condition to return values or return function depending on presence of brightness value

* updated Demo to use  function

* moved color config vars outside of createColors function for simplicity

* updated param names, demo, and tests. Added docs to README.md

* added output docs to readme

* update readme to show theme example at top of doc

* added site analytics to index and demo (#38)

* removed content that bled over from other branch (#39)

* updated issue templates

* Color converter (#40)

* feat: adding in color converter page

* updated citation on converter

* made logo into link back to index.html

* feat: output proper colors, converter include input formats for cross-conversion

* @trivial

* corrected order of colorspaces in converter for consistency

* feat: added hex to output conversion types (#41)

* fix: changed form to div in converter to prevent refresh on submit (#43)

* fix: corrected midtone color outputs (#46)

* fix: corrected midtone color outputs

* @trivial: removed temporary window export

* chore(release): release

 - @adobe/[email protected]
 - @adobe/[email protected]

* added function for creating base scale

* updated demo contrast enhancement

* initial separation for base-scale package

* more refactoring with separate package

* Revert "updated demo contrast enhancement"

This reverts commit 2c932b2.
Modularization of base-scale to unique package moved to separate branch.

* Fixed revert errors. Updated demo for proper contrast multiplier mapping. Added test to generateBaseScale.

* created  function with tests

* added initial generateAdaptiveTheme function with tests

* feat: generateAdaptiveTheme outputs function allowing user to define theme as a function itself

* trivial: removed array brackets from test arguments for colorspace

* added error throw for missing name in color object

* feat: destructured arguments for generateAdaptiveTheme. Added condition to return values or return function depending on presence of brightness value

* updated Demo to use  function

* moved color config vars outside of createColors function for simplicity

* updated param names, demo, and tests. Added docs to README.md

* added output docs to readme

* update readme to show theme example at top of doc

* updated generateAdaptiveTheme with currying

* updated theme output into structured json object

* updates to readme

* reformatting API reference in readme

* @trivial readme formatting

* updated docs, minPositive test, and formatting issues

* updated baseScale argument to be string enum of user input colorScale arguments

* added test to ensure base throws error if not valid option
@NateBaldwinDesign NateBaldwinDesign deleted the bugfix-midtones branch July 24, 2020 16:13
@GarthDB GarthDB mentioned this pull request Mar 14, 2024
thierryc pushed a commit to thierryc/leonardo that referenced this pull request Mar 29, 2024
* fix: corrected midtone color outputs

* @trivial: removed temporary window export
thierryc pushed a commit to thierryc/leonardo that referenced this pull request Mar 29, 2024
* added function for creating base scale

* updated demo contrast enhancement

* initial separation for base-scale package

* more refactoring with separate package

* Revert "updated demo contrast enhancement"

This reverts commit 2c932b2.
Modularization of base-scale to unique package moved to separate branch.

* Fixed revert errors. Updated demo for proper contrast multiplier mapping. Added test to generateBaseScale.

* created  function with tests

* added initial generateAdaptiveTheme function with tests

* feat: generateAdaptiveTheme outputs function allowing user to define theme as a function itself

* trivial: removed array brackets from test arguments for colorspace

* added error throw for missing name in color object

* feat: destructured arguments for generateAdaptiveTheme. Added condition to return values or return function depending on presence of brightness value

* updated Demo to use  function

* moved color config vars outside of createColors function for simplicity

* updated param names, demo, and tests. Added docs to README.md

* added output docs to readme

* update readme to show theme example at top of doc

* added site analytics to index and demo (adobe#38)

* removed content that bled over from other branch (adobe#39)

* updated issue templates

* Color converter (adobe#40)

* feat: adding in color converter page

* updated citation on converter

* made logo into link back to index.html

* feat: output proper colors, converter include input formats for cross-conversion

* @trivial

* corrected order of colorspaces in converter for consistency

* feat: added hex to output conversion types (adobe#41)

* fix: changed form to div in converter to prevent refresh on submit (adobe#43)

* fix: corrected midtone color outputs (adobe#46)

* fix: corrected midtone color outputs

* @trivial: removed temporary window export

* chore(release): release

 - @adobe/[email protected]
 - @adobe/[email protected]

* added function for creating base scale

* updated demo contrast enhancement

* initial separation for base-scale package

* more refactoring with separate package

* Revert "updated demo contrast enhancement"

This reverts commit 2c932b2.
Modularization of base-scale to unique package moved to separate branch.

* Fixed revert errors. Updated demo for proper contrast multiplier mapping. Added test to generateBaseScale.

* created  function with tests

* added initial generateAdaptiveTheme function with tests

* feat: generateAdaptiveTheme outputs function allowing user to define theme as a function itself

* trivial: removed array brackets from test arguments for colorspace

* added error throw for missing name in color object

* feat: destructured arguments for generateAdaptiveTheme. Added condition to return values or return function depending on presence of brightness value

* updated Demo to use  function

* moved color config vars outside of createColors function for simplicity

* updated param names, demo, and tests. Added docs to README.md

* added output docs to readme

* update readme to show theme example at top of doc

* updated generateAdaptiveTheme with currying

* updated theme output into structured json object

* updates to readme

* reformatting API reference in readme

* @trivial readme formatting

* updated docs, minPositive test, and formatting issues

* updated baseScale argument to be string enum of user input colorScale arguments

* added test to ensure base throws error if not valid option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Returning white when darker colors should be returned
1 participant