gpt4 book ai didi

graphics - 基于渐变的条件着色

转载 作者:行者123 更新时间:2023-12-04 16:55:18 26 4
gpt4 key购买 nike

请考虑 :

Manipulate[
Row[{
Graphics[Disk[]],
Graphics[{
Polygon[{{0, 0}, {3, 0}, {3, 1}, {0, 1}},
VertexColors -> {White, Blend[{White, Blue}],
Blend[{White, Blue}], White}],
Black, Thick,
Line[{{i, 0}, {i, 1}}]}, ImageSize -> 300]}],
{i, 0, 3}]

enter image description here

Gradient Filling 上使用 Szabolcs 的解决方案

如何使用位于黑线下方的颜色为磁盘着色?

最佳答案

这是一种有效的解决方案,因为左侧的颜色是 White并且梯度是线性的。

With[{max = 3, color = Blend[{White, Blue}]}, 
Manipulate[
Row[{Graphics[{Opacity[i/max], color, Disk[]}],
Graphics[{Polygon[{{0, 0}, {max, 0}, {max, 1}, {0, 1}},
VertexColors -> {White, color, color, White}], Black, Thick,
Line[{{i, 0}, {i, 1}}]}, ImageSize -> 300]}], {i, 0, max}]]

enter image description here

如果每一端都有两种不同的颜色(即除 White 之外的其他颜色),则 Opacity方法行不通。相反,您可以将可选的混合分数参数用于 Blend所需比例的颜色。下面是一个例子:
With[{max = 3, color1 = Red, color2 = Green}, 
Manipulate[
Row[{Graphics[{Blend[{color1, color2}, i/max], Disk[]}],
Graphics[{Polygon[{{0, 0}, {max, 0}, {max, 1}, {0, 1}},
VertexColors -> {color1, color2, color2, color1}], Black,
Thick, Line[{{i, 0}, {i, 1}}]}, ImageSize -> 300]}], {i, 0,
max}]]

enter image description here

关于graphics - 基于渐变的条件着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8142865/

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