本文整理汇总了Python中vtk.vtkNamedColors函数的典型用法代码示例。如果您正苦于以下问题:Python vtkNamedColors函数的具体用法?Python vtkNamedColors怎么用?Python vtkNamedColors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkNamedColors函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: GetRGBColor
def GetRGBColor(colorName):
'''
Return the red, green and blue components for a
color as doubles.
'''
rgb = [0.0, 0.0, 0.0] # black
vtk.vtkNamedColors().GetColorRGB(colorName, rgb)
return rgb
开发者ID:0004c,项目名称:VTK,代码行数:8,代码来源:cutLoop.py
示例2: MakeLUT
def MakeLUT(tableSize):
'''
Make a lookup table from a set of named colors.
:param: tableSize - The table size
:return: The lookup table.
'''
nc = vtk.vtkNamedColors()
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(tableSize)
lut.Build()
# Fill in a few known colors, the rest will be generated if needed
lut.SetTableValue(0,nc.GetColor4d("Black"))
lut.SetTableValue(1,nc.GetColor4d("Banana"))
lut.SetTableValue(2,nc.GetColor4d("Tomato"))
lut.SetTableValue(3,nc.GetColor4d("Wheat"))
lut.SetTableValue(4,nc.GetColor4d("Lavender"))
lut.SetTableValue(5,nc.GetColor4d("Flesh"))
lut.SetTableValue(6,nc.GetColor4d("Raspberry"))
lut.SetTableValue(7,nc.GetColor4d("Salmon"))
lut.SetTableValue(8,nc.GetColor4d("Mint"))
lut.SetTableValue(9,nc.GetColor4d("Peacock"))
return lut
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:25,代码来源:AssignCellColorsFromLUT.py
示例3: main
def main():
nc = vtk.vtkNamedColors()
colorNames = nc.GetColorNames().split('\n')
print("There are", len(colorNames), "colors:")
print(colorNames)
syn = nc.GetSynonyms().split('\n\n')
synonyms = []
for ele in syn:
synonyms.append(ele.split('\n'))
print("There are", len(synonyms), "synonyms:")
print(synonyms)
iren = DisplayCone(nc)
iren.Start()
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:13,代码来源:NamedColors.py
示例4: create_color
def create_color(color):
""" Creates VTK-compatible RGB color from a color string.
:param color: color
:type color: str
:return: RGB color values
:rtype: list
"""
if color[0] == "#":
# Convert hex string to RGB
return [int(color[i:i + 2], 16) / 255 for i in range(1, 7, 2)]
else:
# Create a named colors instance
nc = vtk.vtkNamedColors()
return nc.GetColor3d(color)
开发者ID:orbingol,项目名称:NURBS-Python,代码行数:15,代码来源:vtk_helpers.py
示例5: __init__
def __init__(self):
'''
Define a single instance of the NamedColors class here.
'''
self.namedColors = vtk.vtkNamedColors()
开发者ID:151706061,项目名称:VTK,代码行数:5,代码来源:imageMCAll.py
示例6: __init__
#.........这里部分代码省略.........
'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', 'gold',\
'goldenrod', 'goldenrod_dark', 'goldenrod_light',\
'goldenrod_pale', 'light_goldenrod', 'melon',\
'naples_yellow_deep', 'yellow', 'yellow_light'],
'Greens':['chartreuse', 'chrome_oxide_green', 'cinnabar_green',\
'cobalt_green', 'emerald_green', 'forest_green', 'green',\
'green_dark', 'green_pale', 'green_yellow', 'lawn_green',\
'lime_green', 'mint', 'olive', 'olive_drab',\
'olive_green_dark', 'permanent_green', 'sap_green',\
'sea_green', 'sea_green_dark', 'sea_green_medium',\
'sea_green_light', 'spring_green', 'spring_green_medium',\
'terre_verte', 'viridian_light', 'yellow_green'],
'Cyans':['aquamarine', 'aquamarine_medium', 'cyan', 'cyan_white',\
'turquoise', 'turquoise_dark', 'turquoise_medium',\
'turquoise_pale'],
'Blues':['alice_blue', 'blue', 'blue_light', 'blue_medium',\
'cadet', 'cobalt', 'cornflower', 'cerulean', 'dodger_blue',\
'indigo', 'manganese_blue', 'midnight_blue', 'navy',\
'peacock', 'powder_blue', 'royal_blue', 'slate_blue',\
'slate_blue_dark', 'slate_blue_light',\
'slate_blue_medium', 'sky_blue', 'sky_blue_deep',\
'sky_blue_light', 'steel_blue', 'steel_blue_light',\
'turquoise_blue', 'ultramarine'],
'Magentas':['blue_violet', 'cobalt_violet_deep', 'magenta',\
'orchid', 'orchid_dark', 'orchid_medium',\
'permanent_red_violet', 'plum', 'purple',\
'purple_medium', 'ultramarine_violet', 'violet',\
'violet_dark', 'violet_red', 'violet_red_medium',\
'violet_red_pale']
}
# Ordering of the tables and when to start and end a column of tables
# in the layout.
self.vtkcnOrder = ['Whites', 'Greys', 'Blacks', 'Reds', 'Oranges',\
'Browns', 'Yellows', 'Greens', 'Cyans', 'Blues',\
'Magentas']
self.vtkcnStartTable = ['Whites', 'Browns', 'Cyans']
self.vtkcnEndTable = ['Oranges', 'Greens', 'Magentas']
# The vtkNamedColors class.
self.nc = vtk.vtkNamedColors()
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:101,代码来源:NamedColorPatches.py
示例7: test
def test(self):
'''
Create a cone, contour it using the banded contour filter and
color it with the primary additive and subtractive colors.
'''
namedColors = vtk.vtkNamedColors()
# Test printing of the object
# Uncomment if desired
#print namedColors
# How to get a list of colors
colors = namedColors.GetColorNames()
colors = colors.split('\n')
# Uncomment if desired
#print 'Number of colors:', len(colors)
#print colors
# How to get a list of a list of synonyms.
syn = namedColors.GetSynonyms()
syn = syn.split('\n\n')
synonyms = []
for ele in syn:
synonyms.append(ele.split('\n'))
# Uncomment if desired
#print 'Number of synonyms:', len(synonyms)
#print synonyms
# Create a cone
coneSource = vtk.vtkConeSource()
coneSource.SetCenter(0.0, 0.0, 0.0)
coneSource.SetRadius(5.0)
coneSource.SetHeight(10)
coneSource.SetDirection(0,1,0)
coneSource.Update();
bounds = [1.0,-1.0,1.0,-1.0,1.0,-1.0]
coneSource.GetOutput().GetBounds(bounds)
elevation = vtk.vtkElevationFilter()
elevation.SetInputConnection(coneSource.GetOutputPort());
elevation.SetLowPoint(0,bounds[2],0);
elevation.SetHighPoint(0,bounds[3],0);
bcf = vtk.vtkBandedPolyDataContourFilter()
bcf.SetInputConnection(elevation.GetOutputPort());
bcf.SetScalarModeToValue();
bcf.GenerateContourEdgesOn();
bcf.GenerateValues(7,elevation.GetScalarRange());
# Build a simple lookup table of
# primary additive and subtractive colors.
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(7);
rgba = [0.0,0.0,0.0,1.0]
# Test setting and getting a color here.
namedColors.GetColor("Red",rgba);
namedColors.SetColor("My Red",rgba)
namedColors.GetColor("My Red",rgba);
lut.SetTableValue(0,rgba);
namedColors.GetColor("DarkGreen",rgba);
lut.SetTableValue(1,rgba);
namedColors.GetColor("Blue",rgba);
lut.SetTableValue(2,rgba);
namedColors.GetColor("Cyan",rgba);
lut.SetTableValue(3,rgba);
namedColors.GetColor("Magenta",rgba);
lut.SetTableValue(4,rgba);
namedColors.GetColor("Yellow",rgba);
lut.SetTableValue(5,rgba);
namedColors.GetColor("White",rgba);
lut.SetTableValue(6,rgba);
lut.SetTableRange(elevation.GetScalarRange());
lut.Build();
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(bcf.GetOutputPort());
mapper.SetLookupTable(lut);
mapper.SetScalarModeToUseCellData();
contourLineMapper = vtk.vtkPolyDataMapper()
contourLineMapper.SetInputData(bcf.GetContourEdgesOutput());
contourLineMapper.SetScalarRange(elevation.GetScalarRange());
contourLineMapper.SetResolveCoincidentTopologyToPolygonOffset();
actor = vtk.vtkActor()
actor.SetMapper(mapper);
contourLineActor = vtk.vtkActor()
contourLineActor.SetMapper(contourLineMapper);
rgb = [0.0,0.0,0.0]
namedColors.GetColorRGB("black",rgb)
contourLineActor.GetProperty().SetColor(rgb);
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer);
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renderWindow);
renderer.AddActor(actor);
#.........这里部分代码省略.........
开发者ID:0004c,项目名称:VTK,代码行数:101,代码来源:TestNamedColorsIntegration.py
示例8: main
def main():
'''
:return: The render window interactor.
'''
nc = vtk.vtkNamedColors()
# Provide some geometry
resolution = 3
plane11 = vtk.vtkPlaneSource()
plane11.SetXResolution(resolution)
plane11.SetYResolution(resolution)
plane12 = vtk.vtkPlaneSource()
plane12.SetXResolution(resolution)
plane12.SetYResolution(resolution)
tableSize = max(resolution * resolution + 1, 10)
# Force an update so we can set cell data
plane11.Update()
plane12.Update()
# Get the lookup tables mapping cell data to colors
lut1 = MakeLUT(tableSize)
lut2 = MakeLUTFromCTF(tableSize)
colorData1 = vtk.vtkUnsignedCharArray()
colorData1.SetName('colors') # Any name will work here.
colorData1.SetNumberOfComponents(3)
print('Using a lookup table from a set of named colors.')
MakeCellData(tableSize, lut1, colorData1)
# Then use SetScalars() to add it to the vtkPolyData structure,
# this will then be interpreted as a color table.
plane11.GetOutput().GetCellData().SetScalars(colorData1)
colorData2 = vtk.vtkUnsignedCharArray()
colorData2.SetName('colors') # Any name will work here.
colorData2.SetNumberOfComponents(3)
print('Using a lookup table created from a color transfer function.')
MakeCellData(tableSize, lut2, colorData2)
plane12.GetOutput().GetCellData().SetScalars(colorData2)
# Set up actor and mapper
mapper11 = vtk.vtkPolyDataMapper()
mapper11.SetInputConnection(plane11.GetOutputPort())
# Now, instead of doing this:
# mapper11.SetScalarRange(0, tableSize - 1)
# mapper11.SetLookupTable(lut1)
# We can just use the color data that we created from the lookup table and
# assigned to the cells:
mapper11.SetScalarModeToUseCellData()
mapper11.Update()
mapper12 = vtk.vtkPolyDataMapper()
mapper12.SetInputConnection(plane12.GetOutputPort())
mapper12.SetScalarModeToUseCellData()
mapper12.Update()
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName('pdlut.vtp')
writer.SetInputData(mapper11.GetInput())
# This is set so we can see the data in a text editor.
writer.SetDataModeToAscii()
writer.Write()
writer.SetFileName('pdctf.vtp')
writer.SetInputData(mapper12.GetInput())
writer.Write()
actor11 = vtk.vtkActor()
actor11.SetMapper(mapper11)
actor12 = vtk.vtkActor()
actor12.SetMapper(mapper12)
# Let's read in the data we wrote out.
reader1 = vtk.vtkXMLPolyDataReader()
reader1.SetFileName("pdlut.vtp")
reader2 = vtk.vtkXMLPolyDataReader()
reader2.SetFileName("pdctf.vtp")
mapper21 = vtk.vtkPolyDataMapper()
mapper21.SetInputConnection(reader1.GetOutputPort())
mapper21.SetScalarModeToUseCellData()
mapper21.Update()
actor21 = vtk.vtkActor()
actor21.SetMapper(mapper11)
mapper22 = vtk.vtkPolyDataMapper()
mapper22.SetInputConnection(reader2.GetOutputPort())
mapper22.SetScalarModeToUseCellData()
mapper22.Update()
actor22 = vtk.vtkActor()
actor22.SetMapper(mapper22)
# Define viewport ranges.
# (xmin, ymin, xmax, ymax)
viewport11 = [0.0, 0.0, 0.5, 0.5]
viewport12 = [0.0, 0.5, 0.5, 1.0]
#.........这里部分代码省略.........
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:101,代码来源:AssignCellColorsFromLUT.py
注:本文中的vtk.vtkNamedColors函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论