Skip to content

Commit 758184d

Browse files
update README.md
1 parent 29edd01 commit 758184d

File tree

2 files changed

+54
-53
lines changed

2 files changed

+54
-53
lines changed

README.md

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
* Functions to convert between `androidx.compose.ui.graphics.Color`, HSL, HSV, `RGB`, HCT, and
1313
colors with nearest **Name** based on distance is in 3D space using `Red`, `Green`, `Blue`.
1414

15-
| M2 Color Swatches | M3 Tone Palettes | | ----------|-----------| -----------| -----------|
16-
| <img src="./screenshots/material_design2.gif" width="250">
17-
| <img src="./screenshots/colorpicker/material_design_3.gif" width="250"> |
15+
| M2 Color Swatches | M3 Tone Palettes |
16+
| ----------|-----------|
17+
| <img src="./screenshots/material_design2.gif" width="450">
18+
| <img src="./screenshots/screenshots/material_design3.gif" width="450"> |
1819

1920
## Material Design 2 Colors && Swatches
2021

2122
### Material Colors
2223

23-
<img src="https://i.stack.imgur.com/mteGN.png">
24+
<img src="./screenshots/m2_palette.png">
2425

2526
[Material Colors](material_design2.gif material_design3.gif) can be accessed from Red to Brown.
2627
Brown, Grey, and BlueGrey swatches only have primary colors.
@@ -51,18 +52,18 @@ primary color `Map<Int,Color>`
5152

5253
```kotlin
5354
val red by lazy {
54-
linkedMapOf(
55-
50 to Color(0xffFFEBEE),
56-
100 to Color(0xffFFCDD2),
57-
200 to Color(0xffEF9A9A),
58-
300 to Color(0xffE57373),
59-
400 to Color(0xffEF5350),
60-
500 to Color(0xffF44336),
61-
600 to Color(0xffE53935),
62-
700 to Color(0xffD32F2F),
63-
800 to Color(0xffC62828),
64-
900 to Color(0xffB71C1C)
65-
)
55+
linkedMapOf(
56+
50 to Color(0xffFFEBEE),
57+
100 to Color(0xffFFCDD2),
58+
200 to Color(0xffEF9A9A),
59+
300 to Color(0xffE57373),
60+
400 to Color(0xffEF5350),
61+
500 to Color(0xffF44336),
62+
600 to Color(0xffE53935),
63+
700 to Color(0xffD32F2F),
64+
800 to Color(0xffC62828),
65+
900 to Color(0xffB71C1C)
66+
)
6667
}
6768
```
6869

@@ -77,39 +78,39 @@ Swatch that returns header(50 variants)
7778

7879
```kotlin
7980
val primaryHeaderColors by lazy {
80-
listOf(
81-
Color(0xffF44336),
82-
Color(0xffE91E63),
83-
Color(0xff9C27B0),
84-
Color(0xff673AB7),
85-
Color(0xff3F51B5),
86-
Color(0xff2196F3),
87-
Color(0xff03A9F4),
88-
Color(0xff00BCD4),
89-
Color(0xff00ACC1),
90-
Color(0xff4CAF50),
91-
Color(0xff8BC34A),
92-
Color(0xffCDDC39),
93-
Color(0xffFFEB3B),
94-
Color(0xffFFC107),
95-
Color(0xffFF9800),
96-
Color(0xffFF5722),
97-
Color(0xff795548),
98-
Color(0xff9E9E9E),
99-
Color(0xff607D8B)
100-
)
81+
listOf(
82+
Color(0xffF44336),
83+
Color(0xffE91E63),
84+
Color(0xff9C27B0),
85+
Color(0xff673AB7),
86+
Color(0xff3F51B5),
87+
Color(0xff2196F3),
88+
Color(0xff03A9F4),
89+
Color(0xff00BCD4),
90+
Color(0xff00ACC1),
91+
Color(0xff4CAF50),
92+
Color(0xff8BC34A),
93+
Color(0xffCDDC39),
94+
Color(0xffFFEB3B),
95+
Color(0xffFFC107),
96+
Color(0xffFF9800),
97+
Color(0xffFF5722),
98+
Color(0xff795548),
99+
Color(0xff9E9E9E),
100+
Color(0xff607D8B)
101+
)
101102
}
102103
```
103104

104105
## Material Design 3 Tonal Palette
105106
A tonal palette consists of thirteen tones, including white and black. A tone value of 100 is equivalent to the idea of light at its maximum and results in white. Every tone value between 0 and 100 expresses the amount of light present in the color.
106107

107108

108-
| <img src="./screenshots/m3_tones.png" width="250">
109-
From range 0 to 100
109+
| <img src="./screenshots/m3_tones.png" width="320">
110+
From range 0 to 100
110111
```kotlin
111112
val material3ToneRange = listOf(
112-
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100
113+
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100
113114
)
114115

115116
```
@@ -118,29 +119,29 @@ Call
118119
```kotlin
119120
fun getColorTonesList(color: Color): List< Color> {
120121

121-
val camColor = Cam16.fromInt(color.toArgb())
122-
val palette: TonalPalette = TonalPalette.fromHueAndChroma(camColor.hue, max(48.0,camColor.chroma))
123-
val toneList = mutableListOf<Color>()
122+
val camColor = Cam16.fromInt(color.toArgb())
123+
val palette: TonalPalette = TonalPalette.fromHueAndChroma(camColor.hue, max(48.0,camColor.chroma))
124+
val toneList = mutableListOf<Color>()
124125

125-
material3ToneRange.forEach { shade ->
126-
toneList.add(Color(palette.tone(shade)))
127-
}
126+
material3ToneRange.forEach { shade ->
127+
toneList.add(Color(palette.tone(shade)))
128+
}
128129

129-
return toneList
130+
return toneList
130131
}
131132
```
132133
that returns list of colors or
133134

134135
```kotlin
135136
fun getColorTonesMap(color: Color): Map<Int, Color> {
136-
val palette: TonalPalette = TonalPalette.fromInt(color.toArgb())
137-
val toneMap = linkedMapOf<Int, Color>()
137+
val palette: TonalPalette = TonalPalette.fromInt(color.toArgb())
138+
val toneMap = linkedMapOf<Int, Color>()
138139

139-
material3ToneRange.forEach { shade ->
140-
toneMap[shade] = Color(palette.tone(shade))
141-
}
140+
material3ToneRange.forEach { shade ->
141+
toneMap[shade] = Color(palette.tone(shade))
142+
}
142143

143-
return toneMap
144+
return toneMap
144145
}
145146

146147
```

screenshots/m2_palette.png

151 KB
Loading

0 commit comments

Comments
 (0)