本文整理汇总了Python中opengltk.OpenGL.GL.glColor3fv方法的典型用法代码示例。如果您正苦于以下问题:Python GL.glColor3fv方法的具体用法?Python GL.glColor3fv怎么用?Python GL.glColor3fv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opengltk.OpenGL.GL
的用法示例。
在下文中一共展示了GL.glColor3fv方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Draw
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glColor3fv [as 别名]
def Draw(self):
#print"Box.Draw"
self.oldFPM = self.frontPolyMode
if self.frontPolyMode == GL.GL_LINE:
GL.glDisable(GL.GL_LIGHTING)
#c is 8x3 array
c= self.vertexSet.vertices.array
#lines parallel to x-axis should be red, y->blue and z->green
col = ((1,0,0),(0,1,0),(0,0,1))
#these groups of 4 pairs of points define lines parallel to x, y, and z axes
alines=[[(c[0],c[1]),(c[2],c[3]),(c[4],c[5]),(c[6],c[7])],
[(c[0],c[3]),(c[1],c[2]),(c[4],c[7]),(c[5],c[6])],
[(c[0],c[4]),(c[1],c[5]),(c[3],c[7]),(c[2],c[6])]]
namectr=0
for i in range(3):
if not self.inheritMaterial:
GL.glColor3fv(col[i])
for vpairs in alines[i]:
GL.glPushName(namectr)
GL.glBegin(GL.GL_LINES)
GL.glVertex3dv(list(vpairs[0]))
GL.glVertex3dv(list(vpairs[1]))
GL.glEnd()
GL.glPopName()
namectr=namectr+1
self.viewer.enableOpenglLighting()
return 1
else:
return IndexedPolygons.Draw(self)
示例2: drawSticker
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glColor3fv [as 别名]
def drawSticker(self, lLabelbounds):
if self.framePolygonMode != GL.GL_NONE:
lenFrameColor = len(self.frameColor)
if lenFrameColor == 4:
GL.glColor4fv(self.frameColor)
elif lenFrameColor == 3:
GL.glColor3fv(self.frameColor)
GL.glPolygonMode(GL.GL_FRONT, self.framePolygonMode)
GL.glBegin(GL.GL_QUADS)
GL.glVertex2f(0, 0)
GL.glVertex2f(float(self.size[0]), 0)
GL.glVertex2f(float(self.size[0]), float(self.size[1]))
GL.glVertex2f(0, float(self.size[1]))
GL.glEnd()
GL.glScalef(float(self.fontScales[0]),
float(self.fontScales[1]),
0)
GL.glTranslatef(float(self.frameSpace[0]),
float(self.frameSpace[1]),
0)
# this corrects the glf draw function to start the label at the proper position
GL.glTranslatef(1, float(-lLabelbounds[1]), 0)
lenFontColor = len(self.fontColor)
if lenFontColor == 4:
GL.glColor4fv(self.fontColor)
elif lenFontColor == 3:
GL.glColor3fv(self.fontColor)
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
if self.wireFont in [0, False]:
glf.glfDrawSolidString(self.label)
else:
glf.glfDrawWiredString(self.label)
示例3: drawLegendOnly
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glColor3fv [as 别名]
def drawLegendOnly(
fullWidth,
fullHeight,
ramp,
verticalLegend=True,
roomLeftToLegend=0,
roomBelowLegend=50,
legendShortSide=10,
legendLongSide=150,
interpolate=True,
selected=False,
tile=None,
):
if ramp is None or len(ramp) == 0:
return
if tile is not None and selected is True:
selected = False
# deducted values
if verticalLegend is True:
lRoomToLegendCloseLongSide = roomLeftToLegend
lRoomToLegendCloseShortSide = roomBelowLegend
if legendShortSide < 1:
legendShortSide = 1
if legendLongSide < 1:
legendLongSide = 1
else:
lRoomToLegendCloseLongSide = roomBelowLegend
lRoomToLegendCloseShortSide = roomLeftToLegend
if legendShortSide < 1:
legendShortSide = 1
if legendLongSide < 1:
legendLongSide = 1
lRoomToLegendFarLongSide = lRoomToLegendCloseLongSide + legendShortSide
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
if tile is None:
GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
else:
GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable( GL.GL_LIGHTING )
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glDepthMask(GL.GL_FALSE)
if len(ramp[0]) == 4: # there are alpha values, draw checkered bg
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
#draw a bunch of quads as background
lCheckerSquareSize = legendShortSide * .5
if lCheckerSquareSize != 0:
nbquads = int(legendLongSide / lCheckerSquareSize)
else:
nbquads = 1
c1 = ( 0.1, 0.1, 0.1 )
c2 = ( 0.3, 0.3, 0.3 )
c = c1
x2 = None
for i in range(nbquads+1):
GL.glColor3fv(c)
if i==nbquads and nbquads != 0:
x1=x2
x2=legendLongSide
else:
x1 = i*lCheckerSquareSize
x2 = min (x1+lCheckerSquareSize, legendLongSide)
GL.glBegin(GL.GL_QUADS)
if verticalLegend is True:
GL.glVertex2f(float(lRoomToLegendCloseLongSide),
float(lRoomToLegendCloseShortSide + x1))
GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize),
float(lRoomToLegendCloseShortSide + x1))
GL.glVertex2f(float(lRoomToLegendCloseLongSide+lCheckerSquareSize),
float(lRoomToLegendCloseShortSide + x2))
GL.glVertex2f(float(lRoomToLegendCloseLongSide),
float(lRoomToLegendCloseShortSide + x2))
else:
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
float(lRoomToLegendCloseLongSide))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x2),
float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
float(lRoomToLegendCloseLongSide+lCheckerSquareSize))
GL.glVertex2f(float(lRoomToLegendCloseShortSide + x1),
float(lRoomToLegendCloseLongSide))
GL.glEnd()
if c==c1:
c=c2
else:
#.........这里部分代码省略.........
示例4: drawLegendLabelName
# 需要导入模块: from opengltk.OpenGL import GL [as 别名]
# 或者: from opengltk.OpenGL.GL import glColor3fv [as 别名]
#.........这里部分代码省略.........
lPt4 = (-fontScale+lRoomToLegendCloseShortSide-lNameWidth,
lRoomToLegendFarLongSide,0)
if selected is True:
labelColor2 = (.5, .5, .5)
else:
labelColor2 = labelColor
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glPushMatrix()
GL.glLoadIdentity()
if tile is None:
GL.glOrtho(0, float(fullWidth), 0, float(fullHeight), -1, 1)
else:
GL.glOrtho(float(tile[0]), float(tile[1]), float(tile[2]), float(tile[3]), -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glPushMatrix()
GL.glLoadIdentity()
GL.glDisable( GL.GL_LIGHTING )
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL )
if len(backgroundColor) == 4:
GL.glEnable(GL.GL_BLEND)
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
#because of an unexplained bug on michel's laptop,
#we don't draw the background when there is no frame
#(so michel has a way to manage the legend)
if frame is True:
#draw transparent background
GL.glDepthMask(GL.GL_FALSE)
if len(backgroundColor) == 3:
GL.glColor3fv(backgroundColor)
else:
GL.glColor4fv(backgroundColor)
GL.glBegin(GL.GL_QUADS)
GL.glVertex3fv(lPt1)
GL.glVertex3fv(lPt2)
GL.glVertex3fv(lPt3)
GL.glVertex3fv(lPt4)
GL.glEnd()
GL.glDepthMask(GL.GL_TRUE)
#draw frame
if frame is True:
GL.glPolygonMode(GL.GL_FRONT, GL.GL_LINE )
GL.glLineWidth(1)
GL.glColor3fv(labelColor2)
GL.glBegin(GL.GL_QUADS)
GL.glVertex3fv(lPt1)
GL.glVertex3fv(lPt2)
GL.glVertex3fv(lPt3)
GL.glVertex3fv(lPt4)
GL.glEnd()
GL.glPolygonMode(GL.GL_FRONT, GL.GL_FILL)
if mini is not None and maxi is not None and maxi > mini:
lUnitStep = legendLongSide/float(maxi-mini)
else:
lUnitStep = legendLongSide
GL.glDisable( GL.GL_LIGHTING )
if verticalLegend is True:
if leftOrBelowLabels is True: