Android 如何在两种颜色之间生成n种颜色
我遵循了这个参考链接: 但是这里有可能得到n个颜色而不通过任何百分比 我试过两种方法: 开始颜色:(a,b,c)结束颜色:(d,e,f) 计数是24Android 如何在两种颜色之间生成n种颜色,android,color-scheme,Android,Color Scheme,我遵循了这个参考链接: 但是这里有可能得到n个颜色而不通过任何百分比 我试过两种方法: 开始颜色:(a,b,c)结束颜色:(d,e,f) 计数是24 我用了这个公式 (a+(d-a)/24,b+(e-b)/24,c+(f-c)/24,(a+2*(d-a)/24,b+2*(e-b)/24,c+2*(f-c)/24)和(a+3*(d-a)/24,b+3*(e-b)/24,c+3*(f-c)/24)等 但是没有起作用 我的期望值: 0 : 96,76,252 - 1 : 75,93,255
0 : 96,76,252
- 1 : 75,93,255
- 2 : 56,111,255
- 3 : 37,129,252
- 4 : 21,146,241
- 5 : 8,163,226
- 6 : 0,179,208
- 7 : 0,192,186
- 8 : 0,204,163
- 9 : 1,213,140
- 10 : 12,220,117
- 11 : 26,224,95
- 12 : 45,225,76
- 13 : 68,224,61
- 14 : 92,221,50
- 15 : 119,216,43
- 16 : 146,210,41
- 17 : 173,204,45
- 18 : 198,197,53
- 19 : 222,190,66
- 20 : 242,184,82
- 21 : 255,179,102
- 22 : 255,176,123
- 23 : 255,174,146
您可以通过以下方法从颜色列表中获取随机颜色 类随机彩色Spicker{ 私人堆栈更改颜色、颜色
public RandomColorsPicker() {
colors = new Stack<>();
changeColors =new Stack<>();
changeColors.addAll(Arrays.asList(
0xfff44336,0xffe91e63,0xff9c27b0,0xff673ab7,
0xff3f51b5,0xff2196f3,0xff03a9f4,0xff00bcd4,
0xff009688,0xff4caf50,0xff8bc34a,0xffcddc39
)
);
}
public int getColors() {
if (colors.size()==0) {
while(!changeColors.isEmpty())
colors.push(changeColors.pop());
Collections.shuffle(colors);
}
Integer color= colors.pop();
changeColors.push(color);
return color;
}
}
不是随机颜色,我需要在两种颜色(如开始颜色和结束颜色)之间生成,然后我需要在n种颜色之间生成。因此,您需要通过百分比来获得新的ArgbEvaluator().evaluate(0.75,0x00ff00,0xff0000);其中我需要调用新的ArgbEvaluator().evaluate(0.75,0x00ff00,0xff0000)。起始颜色:96,76252结束颜色:255174146这些是我的颜色当你想要改变颜色时,只需传递一个浮点数以获得不同的颜色。我想要起始颜色和结束颜色之间的12种颜色,通过使用该逻辑,我如何获得如果你想要(a,b,c)和(d,e,f)之间的3种颜色,你想要(a+(d-a)/4,b+(e-b)/4,c+(f-c)/4),(a+2*(d-a)/4、b+2*(e-b)/4、c+2*(f-c)/4)和(a+3*(d-a)/4、b+3*(e-b)/4、c+3*(f-c)/4)颜色插值似乎已经被问到了:这里的4是什么,是我想要的n个颜色数4是n+1,其中n是你想要生成的颜色数,但它没有给出精确的值,我想要这样:0:96,76252 1:75,93255 2:56111255 3:37129252 4:21146241-5:8163226-6:0179208-7:0192186 - 8 : 0,204,163 - 9 : 1,213,140 - 10 : 12,220,117 - 11 : 26,224,95 - 12 : 45,225,76 - 13 : 68,224,61 - 14 : 92,221,50 - 15 : 119,216,43 - 16 : 146,210,41 - 17 : 173,204,45 - 18 : 198,197,53 - 19 : 222,190,66 - 20 : 242,184,82 - 21 : 255,179,102 - 22 : 255,176,123 - 23 : 255,174,146
RandomColorsPicker colors=new RandomColorsPicker();
int color=colors.getColors();
String hex = Integer.toHexString(color);