gpt4 book ai didi

java - 创建给定 Paint 的半透明版本

转载 作者:行者123 更新时间:2023-11-30 03:12:45 26 4
gpt4 key购买 nike

下面,B 是颜色 A 的半透明版本。两者都源自s

String s = "1,2,3";
Paint A = Paint.valueOf("rgb(" + s + ")");
Paint B = Paint.valueOf("rgba(" + s + ",0.3)");

如果我只有 A 而没有 s,如何创建 B

最佳答案

首先,我会在这里使用颜色而不是绘画。然后你就可以做

Color a = Color.web("rgb(" + s + ")");
Color b = a.deriveColor(0, 1, 1, 0.3);

关于java - 创建给定 Paint 的半透明版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33280282/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com