Python bgl.glColor4f() Examples
The following are 30
code examples of bgl.glColor4f().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bgl
, or try the search function
.
Example #1
Source File: edit_mesh.py From coa_tools with GNU General Public License v3.0 | 7 votes |
def draw_callback_text(self): obj = bpy.context.active_object ### draw text for edge length detection if self.shift and self.point_type == "EDGE": p1 = obj.matrix_world * self.verts_edges_data[0] p2 = obj.matrix_world * self.verts_edges_data[1] length = (p1-p2).magnitude font_id = 0 line = str(round(length,2)) bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(1,1,1,1) blf.position(font_id, self.mouse_2d_x-15, self.mouse_2d_y+30, 0) blf.size(font_id, 20, 72) blf.draw(font_id, line) if self.mode == "EDIT_MESH": draw_edit_mode(self,bpy.context,color=[1.0, 0.39, 0.41, 1.0],text="Edit Mesh Mode",offset=-20) elif self.mode == "DRAW_BONE_SHAPE": draw_edit_mode(self,bpy.context,color=[1.0, 0.39, 0.41, 1.0],text="Draw Bone Shape",offset=-20)
Example #2
Source File: opengl.py From BlenderPro with GNU General Public License v3.0 | 6 votes |
def draw_outline_or_region(mode, points, color): ''' draws and outline or region mode: either bgl.GL_POLYGON or bgl.GL_LINE_LOOP color: will need to be set beforehand using theme colors. eg bgl.glColor4f(self.ri, self.gi, self.bi, self.ai) return: None ''' bgl.glColor4f(color[0],color[1],color[2],color[3]) if mode == 'GL_LINE_LOOP': bgl.glBegin(bgl.GL_LINE_LOOP) else: bgl.glEnable(bgl.GL_BLEND) bgl.glBegin(bgl.GL_POLYGON) # start with corner right-bottom for i in range(0,len(points)): bgl.glVertex2f(points[i][0],points[i][1]) bgl.glEnd()
Example #3
Source File: mi_widget_curve.py From mifthtools with BSD 3-Clause "New" or "Revised" License | 6 votes |
def draw_2d_point(point_x, point_y, p_size=4, p_col=(1.0,1.0,1.0,1.0)): bgl.glEnable(bgl.GL_BLEND) #bgl.glColor4f(1.0, 1.0, 1.0, 0.5) #bgl.glLineWidth(2) bgl.glPointSize(p_size) coords = ((point_x, point_y), (point_x, point_y)) batch = batch_for_shader(shader2d, 'POINTS', {"pos": coords}) shader2d.bind() shader2d.uniform_float("color", (p_col[0], p_col[1], p_col[2], p_col[3])) batch.draw(shader2d) # bgl.glBegin(bgl.GL_POINTS) # bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3]) # bgl.glVertex2f(point_x, point_y) # bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND)
Example #4
Source File: ui.py From addon_common with GNU General Public License v3.0 | 6 votes |
def _draw(self): l,t = self.pos w,h = self.size if debug_draw: bgl.glEnable(bgl.GL_BLEND) bgl.glBegin(bgl.GL_QUADS) bgl.glColor4f(0,1,1,0.5) bgl.glVertex2f(l, t) bgl.glVertex2f(l, t - h) bgl.glVertex2f(l + w, t - h) bgl.glVertex2f(l + w, t) bgl.glEnd() if self.background: bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(*self.background) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l, t) bgl.glVertex2f(l+w, t) bgl.glVertex2f(l+w, t-h) bgl.glVertex2f(l, t-h) bgl.glEnd()
Example #5
Source File: operator_modal_draw.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def draw_callback_px(self, context): print("mouse points", len(self.mouse_path)) font_id = 0 # XXX, need to find out how best to get this. # draw some text blf.position(font_id, 15, 30, 0) blf.size(font_id, 20, 72) blf.draw(font_id, "Hello Word " + str(len(self.mouse_path))) # 50% alpha, 2 pixel width line bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 0.5) bgl.glLineWidth(2) bgl.glBegin(bgl.GL_LINE_STRIP) for x, y in self.mouse_path: bgl.glVertex2i(x, y) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #6
Source File: archipack_gl.py From archipack with GNU General Public License v3.0 | 6 votes |
def draw(self, context, render=False): # print("draw_text %s %s" % (self.text, type(self).__name__)) self.render = render p = self.position_2d_from_coord(context, self.pts[0], render) # dirty fast assignment dpi, font_id = context.user_preferences.system.dpi, 0 bgl.glColor4f(*self.colour) if self.angle != 0: blf.enable(font_id, blf.ROTATION) blf.rotation(font_id, self.angle) blf.size(font_id, self.font_size, dpi) blf.position(font_id, p.x, p.y, 0) blf.draw(font_id, self.text) if self.angle != 0: blf.disable(font_id, blf.ROTATION)
Example #7
Source File: ops.py From Screencast-Keys with GNU General Public License v3.0 | 6 votes |
def draw_line(p1, p2, color, shadow=False, shadow_color=None): bgl.glEnable(bgl.GL_BLEND) bgl.glEnable(bgl.GL_LINE_SMOOTH) # Draw shadow. if shadow: bgl.glLineWidth(3.0) bgl.glColor4f(*shadow_color, 1.0) bgl.glBegin(bgl.GL_LINES) bgl.glVertex2f(*p1) bgl.glVertex2f(*p2) bgl.glEnd() # Draw line. bgl.glLineWidth(1.5 if shadow else 1.0) bgl.glColor3f(*color) bgl.glBegin(bgl.GL_LINES) bgl.glVertex2f(*p1) bgl.glVertex2f(*p2) bgl.glEnd() bgl.glLineWidth(1.0) bgl.glDisable(bgl.GL_LINE_SMOOTH)
Example #8
Source File: archipack_gl.py From archipack with GNU General Public License v3.0 | 6 votes |
def draw(self, context, render=False): """ render flag when rendering """ # print("draw_line %s" % (type(self).__name__)) bgl.glPushAttrib(bgl.GL_ENABLE_BIT) if self.style == bgl.GL_LINE_STIPPLE: bgl.glLineStipple(1, 0x9999) bgl.glEnable(self.style) bgl.glEnable(bgl.GL_BLEND) if render: # enable anti-alias on lines bgl.glEnable(bgl.GL_LINE_SMOOTH) bgl.glColor4f(*self.colour) bgl.glLineWidth(self.width) if self.closed: bgl.glBegin(bgl.GL_LINE_LOOP) else: bgl.glBegin(bgl.GL_LINE_STRIP) for pt in self.pts: p = self.position_2d_from_coord(context, pt, render) bgl.glVertex2f(p.x, p.y) self._end()
Example #9
Source File: archipack_gl.py From archipack with GNU General Public License v3.0 | 6 votes |
def draw(self, context, render=False): """ render flag when rendering """ # print("draw_polygon") self.render = render bgl.glPushAttrib(bgl.GL_ENABLE_BIT) bgl.glEnable(bgl.GL_BLEND) if render: # enable anti-alias on polygons bgl.glEnable(bgl.GL_POLYGON_SMOOTH) bgl.glColor4f(*self.colour) bgl.glBegin(bgl.GL_POLYGON) for pt in self.pts: p = self.position_2d_from_coord(context, pt, render) bgl.glVertex2f(p.x, p.y) self._end()
Example #10
Source File: archipack_gl.py From archipack with GNU General Public License v3.0 | 6 votes |
def draw(self, context, render=False): self.render = render bgl.glPushAttrib(bgl.GL_ENABLE_BIT) bgl.glEnable(bgl.GL_BLEND) if render: # enable anti-alias on polygons bgl.glEnable(bgl.GL_POLYGON_SMOOTH) bgl.glColor4f(*self.colour) pts = [ self.position_2d_from_coord(context, pt, render) for pt in self.pts_3d ] p0 = pts[0] p1 = pts[1] bgl.glRectf(p0.x, p0.y, p1.x, p1.y) self._end()
Example #11
Source File: operator_modal_draw.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def draw_callback_px(self, context): print("mouse points", len(self.mouse_path)) font_id = 0 # XXX, need to find out how best to get this. # draw some text blf.position(font_id, 15, 30, 0) blf.size(font_id, 20, 72) blf.draw(font_id, "Hello Word " + str(len(self.mouse_path))) # 50% alpha, 2 pixel width line bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 0.5) bgl.glLineWidth(2) bgl.glBegin(bgl.GL_LINE_STRIP) for x, y in self.mouse_path: bgl.glVertex2i(x, y) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #12
Source File: ui.py From addon_common with GNU General Public License v3.0 | 6 votes |
def _draw(self): self.buffer_image() if not self.buffered: return cx,cy = (self.pos.x + self.size.x / 2, self.pos.y - self.size.y / 2) iw,ih = self.get_image_width(),self.get_image_height() il,it = cx-iw/2, cy+ih/2 bgl.glColor4f(1,1,1,1) bgl.glEnable(bgl.GL_BLEND) bgl.glEnable(bgl.GL_TEXTURE_2D) bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.texture_id) bgl.glBegin(bgl.GL_QUADS) bgl.glTexCoord2f(0,0); bgl.glVertex2f(il,it) bgl.glTexCoord2f(0,1); bgl.glVertex2f(il,it-ih) bgl.glTexCoord2f(1,1); bgl.glVertex2f(il+iw,it-ih) bgl.glTexCoord2f(1,0); bgl.glVertex2f(il+iw,it) bgl.glEnd() bgl.glBindTexture(bgl.GL_TEXTURE_2D, 0)
Example #13
Source File: space_view3d_enhanced_3d_cursor.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def draw_offset(self, context): bgl.glShadeModel(bgl.GL_SMOOTH) tfm_operator = CursorDynamicSettings.active_transform_operator bgl.glBegin(bgl.GL_LINE_STRIP) if tfm_operator: p = tfm_operator.particles[0]. \ get_initial_matrix().to_translation() else: p = self.get_pos(self.last_id) bgl.glColor4f(1.0, 0.75, 0.5, 1.0) bgl.glVertex3f(p[0], p[1], p[2]) p = get_cursor_location(v3d=context.space_data) bgl.glColor4f(1.0, 1.0, 0.25, 1.0) bgl.glVertex3f(p[0], p[1], p[2]) bgl.glEnd() # ===== BOOKMARK ===== #
Example #14
Source File: skeleton_ui_draw.py From object_alignment with GNU General Public License v3.0 | 6 votes |
def draw3d_polyline(points, color, thickness, view_loc, view_ortho, stipple=False, zfar=0.997): if not points: return if stipple: bgl.glLineStipple(4, 0x5555) #play with this later bgl.glEnable(bgl.GL_LINE_STIPPLE) bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(*color) bgl.glLineWidth(thickness) set_depthrange(0.0, zfar, points, view_loc, view_ortho) bgl.glBegin(bgl.GL_LINE_STRIP) for coord in points: bgl.glVertex3f(*coord) bgl.glEnd() bgl.glLineWidth(1) if stipple: bgl.glDisable(bgl.GL_LINE_STIPPLE) bgl.glEnable(bgl.GL_BLEND) # back to uninterrupted lines
Example #15
Source File: mesh_carver.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def DrawLeftText(text, xt, yt, Size, Color, self): font_id = 0 # Decalage Ombre Sshadow_x = 2 Sshadow_y = -2 blf.size(font_id, Size, 72) blf.position(font_id, xt + Sshadow_x, yt + Sshadow_y, 0) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) blf.draw(font_id, text) blf.position(font_id, xt, yt, 0) if Color is not None: mColor = mathutils.Color((Color[0], Color[1], Color[2])) bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0) else: bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.draw(font_id, text) # Draw text (Right position)
Example #16
Source File: mesh_carver.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def DrawCenterText(text, xt, yt, Size, Color, self): font_id = 0 # Decalage Ombre Sshadow_x = 2 Sshadow_y = -2 blf.size(font_id, Size, 72) blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0] / 2, yt + Sshadow_y, 0) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) blf.draw(font_id, text) blf.position(font_id, xt - blf.dimensions(font_id, text)[0] / 2, yt, 0) if Color is not None: mColor = mathutils.Color((Color[0], Color[1], Color[2])) bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0) else: bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.draw(font_id, text) # Draw text (Left position)
Example #17
Source File: ui.py From addon_common with GNU General Public License v3.0 | 6 votes |
def draw_darken(self): bgl.glPushAttrib(bgl.GL_ALL_ATTRIB_BITS) bgl.glMatrixMode(bgl.GL_PROJECTION) bgl.glPushMatrix() bgl.glLoadIdentity() bgl.glColor4f(0,0,0,0.25) # TODO: use window background color?? bgl.glEnable(bgl.GL_BLEND) bgl.glDisable(bgl.GL_DEPTH_TEST) bgl.glBegin(bgl.GL_QUADS) # TODO: not use immediate mode bgl.glVertex2f(-1, -1) bgl.glVertex2f( 1, -1) bgl.glVertex2f( 1, 1) bgl.glVertex2f(-1, 1) bgl.glEnd() bgl.glPopMatrix() bgl.glPopAttrib()
Example #18
Source File: muv_uvbb_ops.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def __draw_ctrl_point(self, context, pos): """ Draw control point """ cp_size = context.scene.muv_uvbb_cp_size offset = cp_size / 2 verts = [ [pos.x - offset, pos.y - offset], [pos.x - offset, pos.y + offset], [pos.x + offset, pos.y + offset], [pos.x + offset, pos.y - offset] ] bgl.glEnable(bgl.GL_BLEND) bgl.glBegin(bgl.GL_QUADS) bgl.glColor4f(1.0, 1.0, 1.0, 1.0) for (x, y) in verts: bgl.glVertex2f(x, y) bgl.glEnd()
Example #19
Source File: mi_curve_test.py From mifthtools with BSD 3-Clause "New" or "Revised" License | 6 votes |
def mi_draw_2d_point(point_x, point_y, p_size=4, p_col=(1.0,1.0,1.0,1.0)): bgl.glEnable(bgl.GL_BLEND) #bgl.glColor4f(1.0, 1.0, 1.0, 0.5) #bgl.glLineWidth(2) bgl.glPointSize(p_size) # bgl.glBegin(bgl.GL_LINE_LOOP) bgl.glBegin(bgl.GL_POINTS) # bgl.glBegin(bgl.GL_POLYGON) bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3]) bgl.glVertex2f(point_x, point_y) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) # TODO MOVE TO UTILITIES
Example #20
Source File: mi_curve_test.py From mifthtools with BSD 3-Clause "New" or "Revised" License | 6 votes |
def mi_curve_draw_3d_polyline(points, p_size, p_col, x_ray): bgl.glEnable(bgl.GL_BLEND) bgl.glLineWidth(1) if x_ray is True: bgl.glDisable(bgl.GL_DEPTH_TEST) bgl.glPointSize(p_size) # bgl.glBegin(bgl.GL_LINE_LOOP) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3]) # bgl.glBegin(bgl.GL_POLYGON) for point in points: bgl.glVertex3f(point[0], point[1], point[2]) if x_ray is True: bgl.glEnable(bgl.GL_DEPTH_TEST) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #21
Source File: image_background_transform.py From image-background-transform with GNU General Public License v2.0 | 6 votes |
def draw_callback_px(self, context): """From blender's operator_modal_draw.py modal operator template""" if self.do_draw: bgl.glEnable(bgl.GL_BLEND) bgl.glEnable(bgl.GL_LINE_STIPPLE) bgl.glColor4f(0.0, 0.0, 0.0, 1.0) bgl.glLineWidth(1) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2i(int(self.draw_start.x), int(self.draw_start.y)) bgl.glVertex2i(int(self.draw_end.x), int(self.draw_end.y)) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glDisable(bgl.GL_LINE_STIPPLE) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #22
Source File: mi_widget_curve.py From mifthtools with BSD 3-Clause "New" or "Revised" License | 6 votes |
def draw_3d_polyline(points, p_size, p_col, x_ray): bgl.glEnable(bgl.GL_BLEND) bgl.glLineWidth(1) if x_ray is True: bgl.glDisable(bgl.GL_DEPTH_TEST) bgl.glPointSize(p_size) # bgl.glBegin(bgl.GL_LINE_LOOP) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3]) # bgl.glBegin(bgl.GL_POLYGON) for point in points: bgl.glVertex3f(point[0], point[1], point[2]) if x_ray is True: bgl.glEnable(bgl.GL_DEPTH_TEST) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #23
Source File: mi_curve_test.py From mifthtools with BSD 3-Clause "New" or "Revised" License | 6 votes |
def mi_curve_draw_3d_polyline(points, p_size, p_col, x_ray): bgl.glEnable(bgl.GL_BLEND) bgl.glLineWidth(1) if x_ray is True: bgl.glDisable(bgl.GL_DEPTH_TEST) bgl.glPointSize(p_size) # bgl.glBegin(bgl.GL_LINE_LOOP) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glColor4f(p_col[0], p_col[1], p_col[2], p_col[3]) # bgl.glBegin(bgl.GL_POLYGON) for point in points: bgl.glVertex3f(point[0], point[1], point[2]) if x_ray is True: bgl.glEnable(bgl.GL_DEPTH_TEST) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #24
Source File: ui.py From addon_common with GNU General Public License v3.0 | 5 votes |
def _draw(self): l,t = self.pos w,h = self.size bgl.glEnable(bgl.GL_BLEND) self.drawing.line_width(1) if self.hovering: bgcolor = self.hovercolor or self.bgcolor else: bgcolor = self.bgcolor if bgcolor: bgl.glColor4f(*bgcolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() if self.pressed and self.presscolor: bgl.glColor4f(*self.presscolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() if self.bordercolor: bgl.glColor4f(*self.bordercolor) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glVertex2f(l,t) bgl.glEnd() super()._draw()
Example #25
Source File: bmesh_render.py From addon_common with GNU General Public License v3.0 | 5 votes |
def glColor(color): if len(color) == 3: bgl.glColor3f(*color) else: bgl.glColor4f(*color)
Example #26
Source File: ui.py From addon_common with GNU General Public License v3.0 | 5 votes |
def _draw(self): l,t = self.pos w,h = self.size if self.bgcolor: bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(*self.bgcolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() if self.align < 0: loc_x = l elif self.align > 0: loc_x = l + w - self.text_width else: loc_x = l + (w - self.text_width) / 2 if self.valign < 0: loc_y = t elif self.valign > 0: loc_f = t - h + self.text_height else: loc_y = t - (h - self.text_height) / 2 size_prev = self.drawing.set_font_size(self.fontsize) if self.shadowcolor: self.drawing.text_draw2D(self.text, Point2D((loc_x+2, loc_y-2)), self.shadowcolor) self.drawing.text_draw2D(self.text, Point2D((loc_x, loc_y)), self.color) if self.cursor_pos is not None and self.cursor_symbol: pre = self.drawing.get_text_width(self.text[:self.cursor_pos]) cwid = self.drawing.get_text_width(self.cursor_symbol) cloc = Point2D((loc_x+pre-cwid/2, loc_y)) self.drawing.text_draw2D(self.cursor_symbol, cloc, self.cursor_color) self.drawing.set_font_size(size_prev)
Example #27
Source File: skeleton_ui_draw.py From object_alignment with GNU General Public License v3.0 | 5 votes |
def draw2d_polyline(points, color, thickness, stipple=False): if stipple: bgl.glLineStipple(4, 0x5555) #play with this later bgl.glEnable(bgl.GL_LINE_STIPPLE) bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(*color) bgl.glLineWidth(thickness) bgl.glBegin(bgl.GL_LINE_STRIP) for coord in points: bgl.glVertex2f(*coord) bgl.glEnd() bgl.glLineWidth(1) if stipple: bgl.glDisable(bgl.GL_LINE_STIPPLE) bgl.glEnable(bgl.GL_BLEND) # back to uninterupted lines
Example #28
Source File: ui.py From addon_common with GNU General Public License v3.0 | 5 votes |
def _draw(self): r,g,b,a = (0,0,0,0.1) if not (self.downed or self.captured) else (0.8,0.8,0.8,0.5) l,t = self.pos w,h = self.size bgl.glEnable(bgl.GL_BLEND) self.drawing.line_width(1) if self.hovering: bgcolor = self.hovercolor or self.bgcolor else: bgcolor = self.bgcolor if bgcolor: bgl.glColor4f(*bgcolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() bgl.glColor4f(r,g,b,a) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glVertex2f(l,t) bgl.glEnd() super()._draw()
Example #29
Source File: ui.py From addon_common with GNU General Public License v3.0 | 5 votes |
def draw_postpixel(self): if not self.visible: return self.drawing.set_font_size(12) pr = profiler.start('UI_Window: updating position') self.update_pos() pr.done() l,t = self.pos w,h = self.size bgl.glEnable(bgl.GL_BLEND) # draw background bgl.glColor4f(*self.bgcolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() self.drawing.line_width(1.0) bgl.glColor4f(0,0,0,0.5) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glVertex2f(l,t) bgl.glEnd() pr = profiler.start('UI_Window: drawing contents') self.draw(l, t, w, h) pr.done()
Example #30
Source File: ui.py From addon_common with GNU General Public License v3.0 | 5 votes |
def _draw(self): size_prev = self.drawing.set_font_size(self.fontsize) line_height = self.drawing.get_line_height() l,t = self.pos w,h = self.size twidth = self.drawing.get_text_width theight = self.drawing.get_text_height if self.bgcolor: bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(*self.bgcolor) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(l,t) bgl.glVertex2f(l,t-h) bgl.glVertex2f(l+w,t-h) bgl.glVertex2f(l+w,t) bgl.glEnd() y = t for line in self.wrapped_lines: lheight = theight(line) if self.shadowcolor: self.drawing.text_draw2D(line, Point2D((l+2, y-2)), self.shadowcolor) self.drawing.text_draw2D(line, Point2D((l, y)), self.color) y -= self.drawing.get_line_height(line) #line_height #lheight self.drawing.set_font_size(size_prev)