Skip to content

Commit 245836c

Browse files
add colors, gradient, brushes
1 parent 1730043 commit 245836c

File tree

4 files changed

+352
-0
lines changed

4 files changed

+352
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
6+
fun gradientColorScaleHSV(
7+
saturation: Float = 1f,
8+
value: Float = 1f,
9+
alpha: Float = 1f
10+
) = listOf(
11+
Color.hsv(hue = 0f, saturation = saturation, value = value, alpha = alpha),
12+
Color.hsv(hue = 60f, saturation = saturation, value = value, alpha = alpha),
13+
Color.hsv(hue = 120f, saturation = saturation, value = value, alpha = alpha),
14+
Color.hsv(hue = 180f, saturation = saturation, value = value, alpha = alpha),
15+
Color.hsv(hue = 240f, saturation = saturation, value = value, alpha = alpha),
16+
Color.hsv(hue = 300f, saturation = saturation, value = value, alpha = alpha),
17+
Color.hsv(hue = 360f, saturation = saturation, value = value, alpha = alpha)
18+
)
19+
20+
fun gradientColorScaleHSL(
21+
saturation: Float = 1f,
22+
lightness: Float = .5f,
23+
alpha: Float = 1f
24+
) = listOf(
25+
Color.hsl(hue = 0f, saturation = saturation, lightness = lightness, alpha = alpha),
26+
Color.hsl(hue = 60f, saturation = saturation, lightness = lightness, alpha = alpha),
27+
Color.hsl(hue = 120f, saturation = saturation, lightness = lightness, alpha = alpha),
28+
Color.hsl(hue = 180f, saturation = saturation, lightness = lightness, alpha = alpha),
29+
Color.hsl(hue = 240f, saturation = saturation, lightness = lightness, alpha = alpha),
30+
Color.hsl(hue = 300f, saturation = saturation, lightness = lightness, alpha = alpha),
31+
Color.hsl(hue = 360f, saturation = saturation, lightness = lightness, alpha = alpha)
32+
)
33+
34+
35+
val gradientColorScaleRGB = listOf(
36+
Color.Red,
37+
Color.Magenta,
38+
Color.Blue,
39+
Color.Cyan,
40+
Color.Green,
41+
Color.Yellow,
42+
Color.Red
43+
)
44+
45+
val gradientColorScaleRGBReversed = listOf(
46+
Color.Red,
47+
Color.Yellow,
48+
Color.Green,
49+
Color.Cyan,
50+
Color.Blue,
51+
Color.Magenta,
52+
Color.Red
53+
)
54+
55+
val silverColors = listOf(
56+
Color(0xffC0C0C0),
57+
Color(0xffFFFFFF),
58+
Color(0xffC0C0C0),
59+
Color(0xffA9A9A9),
60+
Color(0xffFFFFFF),
61+
Color(0xff808080),
62+
)
63+
val silverColors2 = listOf(
64+
Color(0xffC0C0C0),
65+
Color(0xffCFCFCF),
66+
Color(0xffDDDDDD),
67+
Color(0xffCFCFCF),
68+
Color(0xff808080),
69+
)
70+
val goldColors = listOf(
71+
Color(0xffBF953F),
72+
Color(0xffFCF6BA),
73+
Color(0xffB38728),
74+
Color(0xffFBF5B7),
75+
Color(0xffAA771C),
76+
)
77+
78+
val sunsetColors = listOf(
79+
Color(0xff040308),
80+
Color(0xffAD4A28),
81+
Color(0xffDD723C),
82+
Color(0xffFC7001),
83+
Color(0xffDCB697),
84+
Color(0xff9BA5AE),
85+
Color(0xff3E5879),
86+
Color(0xff020B1A)
87+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme.brush
2+
3+
import androidx.compose.ui.geometry.Offset
4+
import androidx.compose.ui.graphics.Brush
5+
import androidx.compose.ui.graphics.Color
6+
import androidx.compose.ui.graphics.TileMode
7+
import com.smarttoolfactory.composematerialslider.ui.theme.goldColors
8+
import com.smarttoolfactory.composematerialslider.ui.theme.silverColors2
9+
import com.smarttoolfactory.composematerialslider.ui.theme.sunsetColors
10+
11+
fun goldGradient(): Brush {
12+
return Brush.linearGradient(colors = goldColors)
13+
}
14+
15+
fun silverGradient(): Brush {
16+
return Brush.linearGradient(colors = silverColors2)
17+
}
18+
19+
fun sugarGradient(): Brush {
20+
return Brush.linearGradient(
21+
listOf(
22+
Color.White,
23+
Color.Red,
24+
Color.White
25+
),
26+
start = Offset.Zero,
27+
end = Offset(40f, 40f),
28+
tileMode = TileMode.Repeated
29+
)
30+
}
31+
32+
fun sunsetGradient(): Brush {
33+
return Brush.linearGradient(colors = sunsetColors)
34+
}
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
package com.smarttoolfactory.composematerialslider.ui.theme.brush
2+
3+
import androidx.compose.ui.geometry.Offset
4+
import androidx.compose.ui.graphics.Brush
5+
import androidx.compose.ui.graphics.Color
6+
import com.smarttoolfactory.composematerialslider.ui.theme.gradientColorScaleHSL
7+
import com.smarttoolfactory.composematerialslider.ui.theme.gradientColorScaleHSV
8+
9+
10+
/*
11+
HSV Gradients
12+
*/
13+
/**
14+
* Gradient for Slider for selecting Hue from HSV
15+
*/
16+
fun sliderHueHSVGradient(
17+
saturation: Float = 1f,
18+
value: Float = 1f,
19+
alpha: Float = 1f,
20+
start: Offset = Offset.Zero,
21+
end: Offset = Offset.Infinite
22+
): Brush {
23+
return Brush.linearGradient(
24+
colors = gradientColorScaleHSV(
25+
saturation = saturation,
26+
value = value,
27+
alpha = alpha,
28+
),
29+
start = start,
30+
end = end
31+
)
32+
}
33+
34+
fun sliderSaturationHSVGradient(
35+
hue: Float,
36+
value: Float = 1f,
37+
alpha: Float = 1f,
38+
start: Offset = Offset.Zero,
39+
end: Offset = Offset.Infinite
40+
): Brush {
41+
return Brush.linearGradient(
42+
colors = listOf(
43+
Color.hsv(hue = hue, saturation = 0f, value = value, alpha = alpha),
44+
Color.hsv(hue = hue, saturation = 1f, value = value, alpha = alpha)
45+
),
46+
start = start,
47+
end = end
48+
)
49+
}
50+
51+
fun sliderValueGradient(
52+
hue: Float,
53+
alpha: Float = 1f,
54+
start: Offset = Offset.Zero,
55+
end: Offset = Offset.Infinite
56+
): Brush {
57+
return Brush.linearGradient(
58+
colors = listOf(
59+
Color.hsv(hue = hue, saturation = 1f, value = 0f, alpha = alpha),
60+
Color.hsv(hue = hue, saturation = 1f, value = 1f, alpha = alpha)
61+
),
62+
start = start,
63+
end = end
64+
)
65+
}
66+
67+
fun sliderAlphaHSVGradient(
68+
hue: Float = 0f,
69+
saturation: Float = 1f,
70+
value: Float = 1f,
71+
start: Offset = Offset.Zero,
72+
end: Offset = Offset.Infinite
73+
): Brush {
74+
return Brush.linearGradient(
75+
colors = listOf(
76+
Color.hsv(hue = hue, saturation = saturation, value = value, alpha = 0f),
77+
Color.hsv(hue = hue, saturation = saturation, value = value, alpha = 1f)
78+
),
79+
start = start,
80+
end = end
81+
)
82+
}
83+
84+
85+
/*
86+
HSL Gradients
87+
*/
88+
/**
89+
* Gradient for Slider for selecting Hue from HSL
90+
*/
91+
fun sliderHueHSLGradient(
92+
saturation: Float = 1f,
93+
lightness: Float = .5f,
94+
alpha: Float = 1f,
95+
start: Offset = Offset.Zero,
96+
end: Offset = Offset.Infinite
97+
): Brush {
98+
return Brush.linearGradient(
99+
colors = gradientColorScaleHSL(
100+
saturation = saturation,
101+
lightness = lightness,
102+
alpha = alpha,
103+
),
104+
start = start,
105+
end = end
106+
)
107+
}
108+
109+
fun sliderSaturationHSLGradient(
110+
hue: Float,
111+
lightness: Float = .5f,
112+
alpha: Float = 1f,
113+
start: Offset = Offset.Zero,
114+
end: Offset = Offset.Infinite
115+
): Brush {
116+
return Brush.linearGradient(
117+
colors = listOf(
118+
Color.hsl(hue = hue, saturation = 0f, lightness = lightness, alpha = alpha),
119+
Color.hsl(hue = hue, saturation = 1f, lightness = lightness, alpha = alpha),
120+
),
121+
start = start,
122+
end = end
123+
)
124+
}
125+
126+
fun sliderLightnessGradient(
127+
hue: Float,
128+
saturation: Float = 0f,
129+
alpha: Float = 1f,
130+
start: Offset = Offset.Zero,
131+
end: Offset = Offset.Infinite
132+
): Brush {
133+
return Brush.linearGradient(
134+
colors = listOf(
135+
Color.hsl(hue = hue, saturation = saturation, lightness = 0f, alpha = alpha),
136+
Color.hsl(hue = hue, saturation = saturation, lightness = .5f, alpha = alpha),
137+
Color.hsl(hue = hue, saturation = saturation, lightness = 1f, alpha = alpha)
138+
),
139+
start = start,
140+
end = end
141+
)
142+
}
143+
144+
fun sliderAlphaHSLGradient(
145+
hue: Float,
146+
saturation: Float = 1f,
147+
lightness: Float = .5f,
148+
start: Offset = Offset.Zero,
149+
end: Offset = Offset.Infinite
150+
): Brush {
151+
return Brush.linearGradient(
152+
colors = listOf(
153+
Color.hsl(hue = hue, saturation = saturation, lightness = lightness, alpha = 0f),
154+
Color.hsl(hue = hue, saturation = saturation, lightness = lightness, alpha = 1f)
155+
),
156+
start = start,
157+
end = end
158+
)
159+
}
160+
161+
/*
162+
RGB Gradients
163+
*/
164+
fun sliderRedGradient(
165+
alpha: Float = 1f,
166+
start: Offset = Offset.Zero,
167+
end: Offset = Offset.Infinite
168+
): Brush {
169+
return Brush.linearGradient(
170+
colors = listOf(
171+
Color.hsl(hue = 0f, saturation = 1f, lightness = 0f, alpha = alpha),
172+
Color.hsl(hue = 0f, saturation = 1f, lightness = .5f, alpha = alpha)
173+
),
174+
start = start,
175+
end = end
176+
)
177+
}
178+
179+
fun sliderGreenGradient(
180+
alpha: Float = 1f,
181+
start: Offset = Offset.Zero,
182+
end: Offset = Offset.Infinite
183+
): Brush {
184+
return Brush.linearGradient(
185+
colors = listOf(
186+
Color.hsl(hue = 120f, saturation = 1f, lightness = 0f, alpha = alpha),
187+
Color.hsl(hue = 120f, saturation = 1f, lightness = .5f, alpha = alpha)
188+
),
189+
start = start,
190+
end = end
191+
)
192+
}
193+
194+
fun sliderBlueGradient(
195+
alpha: Float = 1f,
196+
start: Offset = Offset.Zero,
197+
end: Offset = Offset.Infinite
198+
): Brush {
199+
return Brush.linearGradient(
200+
colors = listOf(
201+
Color.hsl(hue = 240f, saturation = 1f, lightness = 0f, alpha = alpha),
202+
Color.hsl(hue = 240f, saturation = 1f, lightness = .5f, alpha = alpha)
203+
),
204+
start = start,
205+
end = end
206+
)
207+
}
208+
209+
fun sliderAlphaRGBGradient(
210+
red: Float,
211+
green: Float,
212+
blue: Float,
213+
start: Offset = Offset.Zero,
214+
end: Offset = Offset.Infinite
215+
): Brush {
216+
return Brush.linearGradient(
217+
colors = listOf(
218+
Color(red,green, blue,0f),
219+
Color(red,green, blue,1f)
220+
),
221+
start = start,
222+
end = end
223+
)
224+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.smarttoolfactory.slider.ui
2+
3+
import androidx.compose.ui.graphics.Color
4+
5+
val ThumbColor = Color(0xfff0f0f0)
6+
val ActiveTrackColor = Color(0xff489cef)
7+
val InactiveTrackColor = Color(0xffcccccc)

0 commit comments

Comments
 (0)