是图元的一个选项,指定分配给顶点的颜色.
VertexColors
是图元的一个选项,指定分配给顶点的颜色.
更多信息
- VertexColors 可以和 Polygon、Line、Tube、Point 和 GraphicsComplex 一起使用.
- VertexColors->{col1,col2,…} 指定顶点 i 应采用颜色 coli.
- 多边形内部的颜色,采用 VertexColors 指定颜色之间的插值颜色.
- 在三维图形中, VertexColors 的设置方式类似灯光模拟,包括在任何平面或物质的属性上的设置.
- 每个顶点的颜色 coli 可以明确指定,例如GrayLevel[g] 或 RGBColor[r,g,b] 或采用下面的形式:
-
g GrayLevel[g] {g,a} GrayLevel[g,a] {r,g,b} RGBColor[r,g,b] {r,g,b,a} RGBColor[r,g,b,a]
范例
打开所有单元 关闭所有单元基本范例 (3)
Graphics[Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, VertexColors -> {Blue, Green, Brown, Purple}]]Graphics3D[{Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 1}}, VertexColors -> {Blue, Yellow, Orange}]}]Graphics[{Thick, Line[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardRed, StandardYellow, StandardGreen}]}]范围 (17)
图形对象 (5)
Graphics[Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, VertexColors -> {Red, Green, Blue}]]Graphics[Polygon[{{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, {{2, 0}, {4, 0}, {3, Sqrt[3]}}}, VertexColors -> {{Red, Green, Blue}, {Yellow, Cyan, Magenta}}]]Line:
Graphics[{Thick, Line[{{0, 0}, {2, 1}}, VertexColors -> {Red, Green}]}]Graphics[{Thick, Line[{{{0, 0}, {2, 1}}, {{1, 0}, {3, 1}}}, VertexColors -> {{Red, Green}, {Yellow, Blue}}]}]Graphics[{PointSize[0.1], Point[{{0, 0}, {1, 1}, {2, 2}}, VertexColors -> {StandardRed, StandardYellow, StandardBlue}]}]Graphics[{Triangle[{{0, 0}, {0, 1}, {1, 1}}, VertexColors -> {Red, Green, Blue}]}]Graphics[{Triangle[{{{0, 0}, {0, 1}, {1, 1}}, {{2, 0}, {2, 1}, {3, 1}}}, VertexColors -> {{Red, Green, Blue}, {Yellow, Cyan, Magenta}}]}]在 GraphicsComplex 中,可为共享顶点指定颜色:
Graphics[{GraphicsComplex[{{0, 0}, {1, 0}, {0, 1}, {1, 1}, {.5, .5}}, {Polygon[{1, 2, 5}], Polygon[{3, 4, 5}]}, VertexColors -> {LightRed, DarkRed, LightBlue, DarkBlue, Purple}]}]图形 3D 基元和形状 (5)
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {Red, Green, Blue}]]Graphics3D[Polygon[{{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, {{0, -1, 1}, {0, 1, 1}, {-1, 0, 2}}}, VertexColors -> {{Red, Green, Blue}, {Cyan, Magenta, Yellow}}]]Line:
Graphics3D[{Thick, Line[{{0, 0, 0}, {1, 1, 1}, {2, 2, 1}}, VertexColors -> {Red, Green, Yellow}]}]Graphics3D[{Thick, Line[{{{0, 0, 0}, {2, 1, 1}}, {{1, 0, 0}, {3, 1, 1}}}, VertexColors -> {{Red, Green}, {Blue, Yellow}}]}]Tube:
Graphics3D[{Tube[{{0, 0, 0}, {1, 1, 1}, {2, 2, 1}}, 0.1, VertexColors -> {Red, Green, Yellow}]}]Graphics3D[{Tube[{{{0, 0, 0}, {2, 1, 1}}, {{1, 0, 0}, {3, 1, 1}}}, .2, VertexColors -> {{Red, Green}, {Blue, Yellow}}]}]Graphics3D[{PointSize[0.1], Point[{{0, 0, 0}, {1, 1, 1}, {2, 1, 0}}, VertexColors -> {StandardRed, StandardGreen, StandardOrange}]}, PlotRangePadding -> .1]在 GraphicsComplex 中,可为共享顶点指定颜色:
v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}};Graphics3D[{GraphicsComplex[v, Polygon[i], VertexColors -> {Red, Green, Yellow, Blue, Opacity[.8, White]}]}]颜色规格 (5)
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {RGBColor[0, 1, 0, .1], RGBColor[0, 1, 0, .4], RGBColor[0, 1, 0, .9]}]]可使用 Directive 将颜色与 Opacity 组合:
Graphics3D[Polygon[{{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}}, VertexColors -> {Red, Green, Directive[Blue, Opacity[.5]]}]]Graphics[Polygon[{{0, -1}, {0, 1}, {-1, 0}}, VertexColors -> {RGBColor[0, 1, 0], GrayLevel[.2], LABColor[.6, .5, 1]}]]可使用 LightDarkSwitched 规格配置:
g = Graphics[{Thickness[.1], Line[{{0, 0}, {1, 1}}, VertexColors -> {LightDarkSwitched[LightRed, LightBlue], LightDarkSwitched[DarkRed, DarkBlue]}]}];
{Rasterize[g, LightDark -> "Light"], Rasterize[g, LightDark -> "Dark"]}使用原始数值列表直接指定 {red,green,blue} ,而非通过 RGBColor 函数指定:
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]}]类似地,指定 {red,green,blue,opacity}:
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{1, 0, 0, .1}, {0, 1, 0.9}, {0, 0, 1, .5}}]}]Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {.1, .9, .4}]}]带不透明度的灰度等级应指定为 {gray,opacity}:
Graphics[{Polygon[{{0, 0}, {0, 1}, {2, 0}}, VertexColors -> {{.5, 0}, {.5, 1}, {.5, .5}}]}]可视化功能 (2)
ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, VertexColors -> {Red, Green, Blue}, Lighting -> "Neutral"]ListDensityPlot[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, VertexColors -> {Red, Green, Blue}]可能存在的问题 (2)
在 FilledCurve 的分段内指定的顶点颜色将被忽略:
Graphics[{EdgeForm[Thick], Pink, FilledCurve[Line[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, VertexColors -> {Red, Green, Blue, Yellow}]]}]VertexColors 列表过短时,剩余点将使用默认颜色:
Graphics[{Polygon[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardOrange, StandardBlue}]}]Graphics[{StandardPurple, Polygon[{{0, 0}, {1, 1}, {2, 0}}, VertexColors -> {StandardOrange, StandardBlue}]}]巧妙范例 (2)
PolyhedronData["GreatRhombicosidodecahedron"] /. Polygon[x_] :> Polygon[x, VertexColors -> Map[Opacity[If[EvenQ[#], 0, 1], White]&, x, {-1}]]采用 ExampleData 中一个图形示例:
pic = Reverse[ExampleData[{"TestImage", "Sailboat"}, "Data"] / 255.];ListPlot3D[Table[x + Sin[x y], {x, -5, 5, .1}, {y, -5, 5, .1}], Mesh -> None, VertexColors -> {pic[[5 ;; -5 ;; 5, 5 ;; -5 ;; 5]]}, Lighting -> "Neutral"]文本
Wolfram Research (2007),VertexColors,Wolfram 语言函数,https://reference.wolfram.com/language/ref/VertexColors.html (更新于 2008 年).
CMS
Wolfram 语言. 2007. "VertexColors." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2008. https://reference.wolfram.com/language/ref/VertexColors.html.
APA
Wolfram 语言. (2007). VertexColors. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/VertexColors.html 年
BibTeX
@misc{reference.wolfram_2026_vertexcolors, author="Wolfram Research", title="{VertexColors}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/VertexColors.html}", note=[Accessed: 11-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexcolors, organization={Wolfram Research}, title={VertexColors}, year={2008}, url={https://reference.wolfram.com/language/ref/VertexColors.html}, note=[Accessed: 11-September-2026]}