Skip to content

Commit ce99247

Browse files
Material Engcopybara-github
authored andcommitted
Remove Albers adjustment.
PiperOrigin-RevId: 551514050
1 parent cac6466 commit ce99247

File tree

6 files changed

+20
-127
lines changed

6 files changed

+20
-127
lines changed

cpp/dynamiccolor/material_dynamic_colors.cc

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "cpp/cam/cam.h"
2222
#include "cpp/cam/hct.h"
23-
#include "cpp/cam/viewing_conditions.h"
2423
#include "cpp/dislike/dislike.h"
2524
#include "cpp/dynamiccolor/contrast_curve.h"
2625
#include "cpp/dynamiccolor/dynamic_color.h"
@@ -112,21 +111,6 @@ Hct InViewingConditions(Hct hct, ViewingConditions vc) {
112111
return recast_hct;
113112
}
114113

115-
ViewingConditions ViewingConditionsForAlbers(const DynamicScheme& scheme) {
116-
return DefaultWithBackgroundLstar(scheme.is_dark ? 30.0 : 80.0);
117-
}
118-
119-
double PerformAlbers(Hct pre_albers, const DynamicScheme& scheme) {
120-
Hct albersd =
121-
InViewingConditions(pre_albers, ViewingConditionsForAlbers(scheme));
122-
if (TonePrefersLightForeground(pre_albers.get_tone()) &&
123-
!ToneAllowsLightForeground(albersd.get_tone())) {
124-
return EnableLightForeground(pre_albers.get_tone());
125-
} else {
126-
return EnableLightForeground(albersd.get_tone());
127-
}
128-
}
129-
130114
double FindDesiredChromaByTone(double hue, double chroma, double tone,
131115
bool by_decreasing_tone) {
132116
double answer = tone;
@@ -556,7 +540,7 @@ DynamicColor MaterialDynamicColors::PrimaryContainer() {
556540
/* tone= */
557541
[](const DynamicScheme& s) -> double {
558542
if (IsFidelity(s)) {
559-
return PerformAlbers(s.source_color_hct, s);
543+
return s.source_color_hct.get_tone();
560544
}
561545
if (IsMonochrome(s)) {
562546
return s.is_dark ? 85.0 : 25.0;
@@ -673,11 +657,9 @@ DynamicColor MaterialDynamicColors::SecondaryContainer() {
673657
if (!IsFidelity(s)) {
674658
return initialTone;
675659
}
676-
double answer = FindDesiredChromaByTone(
677-
s.secondary_palette.get_hue(), s.secondary_palette.get_chroma(),
678-
initialTone, s.is_dark ? false : true);
679-
answer = PerformAlbers(Hct(s.secondary_palette.get(answer)), s);
680-
return answer;
660+
return FindDesiredChromaByTone(s.secondary_palette.get_hue(),
661+
s.secondary_palette.get_chroma(),
662+
initialTone, s.is_dark ? false : true);
681663
},
682664
/* isBackground= */ true,
683665
/* background= */
@@ -772,9 +754,8 @@ DynamicColor MaterialDynamicColors::TertiaryContainer() {
772754
if (!IsFidelity(s)) {
773755
return s.is_dark ? 30.0 : 90.0;
774756
}
775-
double albersTone = PerformAlbers(
776-
Hct(s.tertiary_palette.get(s.source_color_hct.get_tone())), s);
777-
Hct proposedHct = Hct(s.tertiary_palette.get(albersTone));
757+
Hct proposedHct =
758+
Hct(s.tertiary_palette.get(s.source_color_hct.get_tone()));
778759
return FixIfDisliked(proposedHct).get_tone();
779760
},
780761
/* isBackground= */ true,

dart/lib/dynamiccolor/material_dynamic_colors.dart

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import 'dart:math' as math;
1616

1717
import 'package:material_color_utilities/dislike/dislike_analyzer.dart';
1818
import 'package:material_color_utilities/hct/hct.dart';
19-
import 'package:material_color_utilities/hct/viewing_conditions.dart';
2019
import 'package:material_color_utilities/scheme/dynamic_scheme.dart';
2120
import 'package:material_color_utilities/scheme/variant.dart';
2221

@@ -37,10 +36,6 @@ class MaterialDynamicColors {
3736
return s.isDark ? surfaceBright : surfaceDim;
3837
}
3938

40-
static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
41-
return ViewingConditions.make(backgroundLstar: scheme.isDark ? 30 : 80);
42-
}
43-
4439
static DynamicColor primaryPaletteKeyColor = DynamicColor.fromPalette(
4540
name: 'primary_palette_key_color',
4641
palette: (s) => s.primaryPalette,
@@ -248,7 +243,7 @@ class MaterialDynamicColors {
248243
palette: (s) => s.primaryPalette,
249244
tone: (s) {
250245
if (_isFidelity(s)) {
251-
return _performAlbers(s.sourceColorHct, s);
246+
return s.sourceColorHct.tone;
252247
}
253248
if (_isMonochrome(s)) {
254249
return s.isDark ? 85 : 25;
@@ -327,10 +322,8 @@ class MaterialDynamicColors {
327322
if (!_isFidelity(s)) {
328323
return initialTone;
329324
}
330-
var answer = _findDesiredChromaByTone(s.secondaryPalette.hue,
325+
return _findDesiredChromaByTone(s.secondaryPalette.hue,
331326
s.secondaryPalette.chroma, initialTone, s.isDark ? false : true);
332-
answer = _performAlbers(s.secondaryPalette.getHct(answer), s);
333-
return answer;
334327
},
335328
isBackground: true,
336329
background: (s) => MaterialDynamicColors.highestSurface(s),
@@ -396,9 +389,7 @@ class MaterialDynamicColors {
396389
if (!_isFidelity(s)) {
397390
return s.isDark ? 30 : 90;
398391
}
399-
final albersTone =
400-
_performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.tone), s);
401-
final proposedHct = s.tertiaryPalette.getHct(albersTone);
392+
final proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);
402393
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
403394
},
404395
isBackground: true,
@@ -619,15 +610,4 @@ class MaterialDynamicColors {
619610

620611
return answer;
621612
}
622-
623-
static double _performAlbers(Hct prealbers, DynamicScheme scheme) {
624-
final albersd =
625-
prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
626-
if (DynamicColor.tonePrefersLightForeground(prealbers.tone) &&
627-
!DynamicColor.toneAllowsLightForeground(albersd.tone)) {
628-
return DynamicColor.enableLightForeground(prealbers.tone);
629-
} else {
630-
return DynamicColor.enableLightForeground(albersd.tone);
631-
}
632-
}
633613
}

java/dynamiccolor/MaterialDynamicColors.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import androidx.annotation.NonNull;
2020
import dislike.DislikeAnalyzer;
2121
import hct.Hct;
22-
import hct.ViewingConditions;
2322
import scheme.DynamicScheme;
2423
import scheme.Variant;
2524

@@ -395,7 +394,7 @@ public DynamicColor primaryContainer() {
395394
/* palette= */ (s) -> s.primaryPalette,
396395
/* tone= */ (s) -> {
397396
if (isFidelity(s)) {
398-
return performAlbers(s.sourceColorHct, s);
397+
return s.sourceColorHct.getTone();
399398
}
400399
if (isMonochrome(s)) {
401400
return s.isDark ? 85.0 : 25.0;
@@ -490,14 +489,8 @@ public DynamicColor secondaryContainer() {
490489
if (!isFidelity(s)) {
491490
return initialTone;
492491
}
493-
double answer =
494-
findDesiredChromaByTone(
495-
s.secondaryPalette.getHue(),
496-
s.secondaryPalette.getChroma(),
497-
initialTone,
498-
!s.isDark);
499-
answer = performAlbers(s.secondaryPalette.getHct(answer), s);
500-
return answer;
492+
return findDesiredChromaByTone(
493+
s.secondaryPalette.getHue(), s.secondaryPalette.getChroma(), initialTone, !s.isDark);
501494
},
502495
/* isBackground= */ true,
503496
/* background= */ this::highestSurface,
@@ -574,9 +567,7 @@ public DynamicColor tertiaryContainer() {
574567
if (!isFidelity(s)) {
575568
return s.isDark ? 30.0 : 90.0;
576569
}
577-
final double albersTone =
578-
performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.getTone()), s);
579-
final Hct proposedHct = s.tertiaryPalette.getHct(albersTone);
570+
final Hct proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.getTone());
580571
return DislikeAnalyzer.fixIfDisliked(proposedHct).getTone();
581572
},
582573
/* isBackground= */ true,
@@ -930,10 +921,6 @@ private boolean isFidelity(DynamicScheme scheme) {
930921
return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT;
931922
}
932923

933-
private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
934-
return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0);
935-
}
936-
937924
private static boolean isMonochrome(DynamicScheme scheme) {
938925
return scheme.variant == Variant.MONOCHROME;
939926
}
@@ -966,14 +953,4 @@ static double findDesiredChromaByTone(
966953

967954
return answer;
968955
}
969-
970-
static double performAlbers(Hct prealbers, DynamicScheme scheme) {
971-
final Hct albersd = prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
972-
if (DynamicColor.tonePrefersLightForeground(prealbers.getTone())
973-
&& !DynamicColor.toneAllowsLightForeground(albersd.getTone())) {
974-
return DynamicColor.enableLightForeground(prealbers.getTone());
975-
} else {
976-
return DynamicColor.enableLightForeground(albersd.getTone());
977-
}
978-
}
979956
}

swift/Sources/MaterialColorUtilities/DynamicColor/MaterialDynamicColors.swift

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ public class MaterialDynamicColors {
3030
return scheme.isDark ? surfaceBright : surfaceDim
3131
}
3232

33-
static func viewingConditionsForAlbers(_ scheme: DynamicScheme) -> ViewingConditions {
34-
return ViewingConditions.make(backgroundLstar: scheme.isDark ? 30 : 80)
35-
}
36-
3733
public static let primaryPaletteKeyColor: DynamicColor = DynamicColor(
3834
name: "primary_palette_key_color",
3935
palette: { scheme in
@@ -366,7 +362,7 @@ public class MaterialDynamicColors {
366362
},
367363
tone: { scheme in
368364
if _isFidelity(scheme) {
369-
return _performAlbers(scheme.sourceColorHct, scheme)
365+
return scheme.sourceColorHct.tone
370366
}
371367
if _isMonochrome(scheme) {
372368
return scheme.isDark ? 85 : 25
@@ -471,11 +467,9 @@ public class MaterialDynamicColors {
471467
if !_isFidelity(scheme) {
472468
return initialTone
473469
}
474-
var answer = _findDesiredChromaByTone(
470+
return _findDesiredChromaByTone(
475471
scheme.secondaryPalette.hue, scheme.secondaryPalette.chroma, initialTone,
476472
scheme.isDark ? false : true)
477-
answer = _performAlbers(scheme.secondaryPalette.getHct(answer), scheme)
478-
return answer
479473
},
480474
isBackground: true,
481475
background: { scheme in
@@ -559,9 +553,7 @@ public class MaterialDynamicColors {
559553
if !_isFidelity(scheme) {
560554
return scheme.isDark ? 30 : 90
561555
}
562-
let albersTone =
563-
_performAlbers(scheme.tertiaryPalette.getHct(scheme.sourceColorHct.tone), scheme)
564-
let proposedHct = scheme.tertiaryPalette.getHct(albersTone)
556+
let proposedHct = scheme.tertiaryPalette.getHct(scheme.sourceColorHct.tone)
565557
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone
566558
},
567559
isBackground: true,
@@ -922,15 +914,4 @@ public class MaterialDynamicColors {
922914

923915
return answer
924916
}
925-
926-
static private func _performAlbers(_ prealbers: Hct, _ scheme: DynamicScheme) -> Double {
927-
let albersd = prealbers.inViewingConditions(viewingConditionsForAlbers(scheme))
928-
if DynamicColor.tonePrefersLightForeground(prealbers.tone)
929-
&& !DynamicColor.toneAllowsLightForeground(albersd.tone)
930-
{
931-
return DynamicColor.enableLightForeground(prealbers.tone)
932-
} else {
933-
return DynamicColor.enableLightForeground(albersd.tone)
934-
}
935-
}
936917
}

swift/Tests/MaterialColorUtilitiesTests/SchemeTests/SchemeContentTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class SchemeContentTests: XCTestCase {
3737
contrastLevel: 0
3838
)
3939

40-
XCTAssertEqual(MaterialDynamicColors.tertiaryContainer.getArgb(scheme), 0xffac_1b57)
40+
XCTAssertEqual(MaterialDynamicColors.tertiaryContainer.getArgb(scheme), 0xff98_0249)
4141
}
4242

4343
func testLightThemeMaxContrastObjectionabeTertiaryContainerDarkens() {

typescript/dynamiccolor/material_dynamic_colors.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import {DislikeAnalyzer} from '../dislike/dislike_analyzer.js';
1919
import {Hct} from '../hct/hct.js';
20-
import {ViewingConditions} from '../hct/viewing_conditions.js';
2120
import {DynamicScheme} from '../scheme/dynamic_scheme.js';
2221
import {Variant} from '../scheme/variant.js';
2322

@@ -64,27 +63,6 @@ function findDesiredChromaByTone(
6463
return answer;
6564
}
6665

67-
function viewingConditionsForAlbers(scheme: DynamicScheme): ViewingConditions {
68-
return ViewingConditions.make(
69-
/*whitePoint=*/ undefined,
70-
/*adaptingLuminance=*/ undefined,
71-
/*backgroundLstar=*/ scheme.isDark ? 30 : 80,
72-
/*surround=*/ undefined,
73-
/*discountingIlluminant=*/ undefined,
74-
);
75-
}
76-
77-
function performAlbers(prealbers: Hct, scheme: DynamicScheme): number {
78-
const albersd =
79-
prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
80-
if (DynamicColor.tonePrefersLightForeground(prealbers.tone) &&
81-
!DynamicColor.toneAllowsLightForeground(albersd.tone)) {
82-
return DynamicColor.enableLightForeground(prealbers.tone);
83-
} else {
84-
return DynamicColor.enableLightForeground(albersd.tone);
85-
}
86-
}
87-
8866
/**
8967
* DynamicColors for the colors in the Material Design system.
9068
*/
@@ -308,7 +286,7 @@ export class MaterialDynamicColors {
308286
tone:
309287
(s) => {
310288
if (isFidelity(s)) {
311-
return performAlbers(s.sourceColorHct, s);
289+
return s.sourceColorHct.tone;
312290
}
313291
if (isMonochrome(s)) {
314292
return s.isDark ? 85 : 25;
@@ -388,11 +366,9 @@ export class MaterialDynamicColors {
388366
if (!isFidelity(s)) {
389367
return initialTone;
390368
}
391-
let answer = findDesiredChromaByTone(
369+
return findDesiredChromaByTone(
392370
s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone,
393371
s.isDark ? false : true);
394-
answer = performAlbers(s.secondaryPalette.getHct(answer), s);
395-
return answer;
396372
},
397373
isBackground: true,
398374
background: (s) => MaterialDynamicColors.highestSurface(s),
@@ -460,9 +436,7 @@ export class MaterialDynamicColors {
460436
if (!isFidelity(s)) {
461437
return s.isDark ? 30 : 90;
462438
}
463-
const albersTone =
464-
performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.tone), s);
465-
const proposedHct = s.tertiaryPalette.getHct(albersTone);
439+
const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);
466440
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
467441
},
468442
isBackground: true,

0 commit comments

Comments
 (0)