#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
=========================================================================
Program: Visualization Toolkit
Module: NamedColorPatches.py
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================
Produce a HTML page called VTKNamedColorPatches.html showing the available
colors in vtkNamedColors.
It also shows how to select the text color based on luminance.
In this case Digital CCIR601 is used which gives less weight to the
red and blue components of a color.
"""
from __future__ import print_function
import vtk
def RGBToHTMLColor(rgb):
"""
Convert an [R, G, B] list to #RRGGBB.
:param: rgb - The elements of the array rgb are unsigned chars (0..255).
:return: The html color.
"""
hexcolor = "#" + ''.join(['{:02x}'.format(x) for x in rgb])
return hexcolor
def HTMLColorToRGB(colorString):
"""
Convert #RRGGBB to a [R, G, B] list.
:param: colorString a string in the form: #RRGGBB where RR, GG, BB are hexadecimal.
The elements of the array rgb are unsigned chars (0..255).
:return: The red, green and blue components as a list.
"""
colorString = colorString.strip()
if colorString[0] == '#':
colorString = colorString[1:]
if len(colorString) != 6:
raise ValueError("Input #%s is not in #RRGGBB format" % colorString)
r, g, b = colorString[:2], colorString[2:4], colorString[4:]
r, g, b = [int(n, 16) for n in (r, g, b)]
return [r, g, b]
def RGBToLumaCCIR601(rgb):
"""
RGB -> Luma conversion
Digital CCIR601 (gives less weight to the R and B components)
:param: rgb - The elements of the array rgb are unsigned chars (0..255).
:return: The luminance.
"""
Y = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]
return Y
def FormatRGBForHTML(rgb):
"""
Format the rgb colors for display on a html table.
:param: rgb - The elements of the array rgb are unsigned chars (0..255).
:return: A formatted string for the html table.
"""
s = ','.join(['{:3d}'.format(x) for x in rgb])
s = s.replace(' ', ' ')
s = s.replace(',', '  ')
return s
class HTMLTableMaker(object):
"""
This class creates HTML Tables displaying all the colors in
the class vtkNamedColors grouped by various categories.
"""
def __init__(self):
self.cn = {
'Red': ['IndianRed', 'LightCoral', 'Salmon', 'DarkSalmon',
'LightSalmon', 'Red', 'Crimson', 'FireBrick', 'DarkRed'],
'Pink': ['Pink', 'LightPink', 'HotPink', 'DeepPink',
'MediumVioletRed', 'PaleVioletRed'],
'Orange': ['LightSalmon', 'Coral', 'Tomato', 'OrangeRed',
'DarkOrange', 'Orange'],
'Yellow': ['Gold', 'Yellow', 'LightYellow', 'LemonChiffon',
'LightGoldenrodYellow', 'PapayaWhip', 'Moccasin',
'PeachPuff', 'PaleGoldenrod', 'Khaki', 'DarkKhaki'],
'Purple': ['Lavender', 'Thistle', 'Plum', 'Violet', 'Orchid',
'Fuchsia', 'Magenta', 'MediumOrchid', 'MediumPurple',
'BlueViolet', 'DarkViolet', 'DarkOrchid', 'DarkMagenta',
'Purple', 'Indigo', 'DarkSlateBlue', 'SlateBlue',
'MediumSlateBlue'],
'Green': ['GreenYellow', 'Chartreuse', 'LawnGreen', 'Lime',
'LimeGreen', 'PaleGreen', 'LightGreen',
'MediumSpringGreen', 'SpringGreen', 'MediumSeaGreen',
'SeaGreen', 'ForestGreen', 'Green', 'DarkGreen',
'YellowGreen', 'OliveDrab', 'Olive', 'DarkOliveGreen',
'MediumAquamarine', 'DarkSeaGreen', 'LightSeaGreen',
'DarkCyan', 'Teal'],
'Blue/Cyan': ['Aqua', 'Cyan', 'LightCyan', 'PaleTurquoise',
'Aquamarine', 'Turquoise', 'MediumTurquoise',
'DarkTurquoise', 'CadetBlue', 'SteelBlue',
'LightSteelBlue', 'PowderBlue', 'LightBlue',
'SkyBlue', 'LightSkyBlue', 'DeepSkyBlue',
'DodgerBlue', 'CornflowerBlue', 'RoyalBlue', 'Blue',
'MediumBlue', 'DarkBlue', 'Navy', 'MidnightBlue'],
'Brown': ['Cornsilk', 'BlanchedAlmond', 'Bisque', 'NavajoWhite',
'Wheat', 'BurlyWood', 'Tan', 'RosyBrown', 'SandyBrown',
'Goldenrod', 'DarkGoldenrod', 'Peru', 'Chocolate',
'SaddleBrown', 'Sienna', 'Brown', 'Maroon'],
'White': ['White', 'Snow', 'Honeydew', 'MintCream', 'Azure',
'AliceBlue', 'GhostWhite', 'WhiteSmoke', 'Seashell',
'Beige', 'OldLace', 'FloralWhite', 'Ivory',
'AntiqueWhite', 'Linen',
'LavenderBlush', 'MistyRose'],
'Gray': ['Gainsboro', 'LightGrey', 'Silver', 'DarkGray', 'Gray',
'DimGray', 'LightSlateGray', 'SlateGray', 'DarkSlateGray',
'Black']
}
# Ordering of the tables and when to start and end a column of tables
# in the layout.
self.cnOrder = ['Red', 'Pink', 'Orange', 'Yellow', 'Purple', 'Green',
'Blue/Cyan', 'Brown', 'White', 'Gray']
self.cnStartTable = ['Red', 'Green', 'Brown']
self.cnEndTable = ['Purple', 'Blue/Cyan', 'Gray']
self.vtkcn = {
'Whites': ['antique_white', 'azure', 'bisque', 'blanched_almond',
'cornsilk', 'eggshell', 'floral_white', 'gainsboro',
'ghost_white', 'honeydew', 'ivory', 'lavender',
'lavender_blush', 'lemon_chiffon', 'linen', 'mint_cream',
'misty_rose', 'moccasin', 'navajo_white', 'old_lace',
'papaya_whip', 'peach_puff', 'seashell', 'snow',
'thistle', 'titanium_white', 'wheat', 'white',
'white_smoke', 'zinc_white'],
'Greys': ['cold_grey', 'dim_grey', 'grey', 'light_grey',
'slate_grey', 'slate_grey_dark', 'slate_grey_light',
'warm_grey'],
'Blacks': ['black', 'ivory_black', 'lamp_black'],
'Reds': ['alizarin_crimson', 'brick', 'cadmium_red_deep', 'coral',
'coral_light', 'deep_pink', 'english_red', 'firebrick',
'geranium_lake', 'hot_pink', 'indian_red', 'light_salmon',
'madder_lake_deep', 'maroon', 'pink', 'pink_light',
'raspberry', 'red', 'rose_madder', 'salmon', 'tomato',
'venetian_red'],
'Browns': ['beige', 'brown', 'brown_madder', 'brown_ochre',
'burlywood', 'burnt_sienna', 'burnt_umber', 'chocolate',
'deep_ochre', 'flesh', 'flesh_ochre', 'gold_ochre',
'greenish_umber', 'khaki', 'khaki_dark', 'light_beige',
'peru', 'rosy_brown', 'raw_sienna', 'raw_umber', 'sepia',
'sienna', 'saddle_brown', 'sandy_brown', 'tan',
'van_dyke_brown'],
'Oranges': ['cadmium_orange', 'cadmium_red_light', 'carrot',
'dark_orange', 'mars_orange', 'mars_yellow', 'orange',
'orange_red', 'yellow_ochre'],
'Yellows': ['aureoline_yellow', 'banana', 'cadmium_lemon',
'cadmium_yellow', 'cadmium_yellow_light', '
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Python的VTK Demo,比较全。 (462个子文件)
VTKNamedColorPatches.html 75KB
VTKNamedColorPatches.html 75KB
CurvatureBandsWithGlyphs.md 4KB
ElevationBandsWithGlyphs.md 3KB
Finance.md 2KB
MorphologyComparison.md 2KB
WriteImage.md 2KB
AnatomicalOrientation.md 2KB
CallBack.md 2KB
Blow.md 2KB
IsoSubsample.md 2KB
CurvaturesDemo.md 1KB
ReadPolyData.md 1KB
PointDataSubdivision.md 1KB
CarotidFlow.md 1KB
ReadLegacyUnstructuredGrid.md 1KB
Hanoi.md 1KB
Pad.md 1KB
NamedColorPatches.md 1KB
Motor.md 1KB
ProbeCombustor.md 1KB
StreamlinesWithLineWidget.md 983B
ClipSphereCylinder.md 957B
OrientedArrow.md 935B
OrientedCylinder.md 931B
ColoredSphere.md 919B
IsoparametricCellsDemo.md 915B
Office.md 823B
GetProgramParameters.md 819B
FrogSlice.md 817B
Kitchen.md 815B
ExtractData.md 799B
TransformSphere.md 787B
PolyDataContourToImageData.md 758B
AssignCellColorsFromLUT.md 757B
EnhanceEdges.md 742B
CreateColorSeriesDemo.md 738B
ClipDataSetWithPolydata.md 737B
FlyingHeadSlice.md 710B
PlatonicSolids.md 710B
FlyingFrogSkinAndTissue.md 707B
CellTypeSource.md 701B
AnimateVectors.md 670B
Rainbow.md 660B
Snippets.md 600B
MarchingCases.md 578B
NormalsDemo.md 571B
SaveSceneToFieldData.md 553B
IdealHighPass.md 545B
SaveSceneToFile.md 534B
Cell3DDemonstration.md 517B
WarpCombustor.md 498B
EllipticalCylinder.md 476B
PineRootDecimation.md 472B
BluntStreamlines.md 466B
TriangleStrip.md 466B
FlatVersusGouraud.md 463B
TextureThreshold.md 461B
DisplacementPlot.md 459B
ComplexV.md 440B
LUTUtilities.md 432B
Polygon.md 427B
NamedColors.md 423B
PineRootConnectivity.md 414B
Cube.md 414B
BlobbyLogo.md 408B
MouseEventsObserver.md 405B
LineOnMesh.md 399B
TextureCutQuadric.md 395B
MouseEvents.md 394B
WriteLegacyLinearCells.md 389B
WriteXMLLinearCells.md 387B
Rotations.md 382B
ImageWriter.md 376B
HyperStreamline.md 371B
FinanceFieldData.md 365B
CameraModel2.md 358B
CameraModel1.md 358B
SmoothMeshGrid.md 356B
MeshLabelImageColor.md 343B
KochSnowflake.md 340B
EllipticalCylinderDemo.md 339B
ParametricObjects.md 331B
ParametricObjectsDemo.md 319B
Hawaii.md 289B
GeoAssignCoordinates.md 289B
TensorEllipsoids.md 268B
VTKSpectrum.md 266B
BackgroundImage.md 260B
PolyLine.md 259B
TessellatedBoxSource.md 259B
UnstructuredGridReader.md 258B
MedicalDemo3.md 254B
MedicalDemo1.md 250B
Axes.md 244B
Triangle.md 237B
TensorAxes.md 236B
SphereTexture.md 232B
MedicalDemo2.md 227B
WalkCow.md 226B
共 462 条
- 1
- 2
- 3
- 4
- 5
资源评论
- qq_423501572021-12-28根本就不好用。
e-pi
- 粉丝: 21
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功