Python bgl.glVertex2i() Examples
The following are 10
code examples of bgl.glVertex2i().
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: 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 #2
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 #3
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 #4
Source File: BakeLab_1_2.py From Bakelab-Blender-addon with GNU General Public License v3.0 | 5 votes |
def BakeLab_DrawProgressBar(y_shift,progress,text): bgl.glColor4f(0,0,0,1.0) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2i(19, y_shift-1) bgl.glVertex2i(161, y_shift-1) bgl.glVertex2i(161, y_shift+31) bgl.glVertex2i(19, y_shift+31) bgl.glEnd() bgl.glColor4f(0.7,0.5,0.3, 1.0) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2i(20, y_shift) bgl.glVertex2i(160, y_shift) bgl.glVertex2i(160, y_shift+30) bgl.glVertex2i(20, y_shift+30) bgl.glEnd() bgl.glColor4f(0.05,0.1,0.15, 1.0) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2i(21, y_shift+1) bgl.glVertex2i(159, y_shift+1) bgl.glVertex2i(159, y_shift+29) bgl.glVertex2i(21, y_shift+29) bgl.glEnd() bgl.glColor4f(0.7,0.5,0.3, 1.0) bgl.glBegin(bgl.GL_QUADS) x_loc = (157-23)*progress+23 bgl.glVertex2i(23, y_shift+3) bgl.glVertex2i(int(x_loc), y_shift+3) bgl.glVertex2i(int(x_loc), y_shift+27) bgl.glVertex2i(23, y_shift+27) bgl.glEnd() blf.position(0, 170, y_shift+10, 0) blf.draw(0, text)
Example #5
Source File: utils.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def draw_callback_px(self, context): font_id = 0 # XXX, need to find out how best to get this. offset = 10 text_height = 10 text_length = int(len(self.mouse_text) * 7.3) if self.header_text != "": blf.size(font_id, 17, 72) text_w, text_h = blf.dimensions(font_id,self.header_text) blf.position(font_id, context.area.width/2 - text_w/2, context.area.height - 50, 0) blf.draw(font_id, self.header_text) # 50% alpha, 2 pixel width line if self.mouse_text != "": bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 0.5) bgl.glLineWidth(10) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2i(self.mouse_loc[0]-offset-5, self.mouse_loc[1]+offset) bgl.glVertex2i(self.mouse_loc[0]+text_length-offset, self.mouse_loc[1]+offset) bgl.glVertex2i(self.mouse_loc[0]+text_length-offset, self.mouse_loc[1]+offset+text_height) bgl.glVertex2i(self.mouse_loc[0]-offset-5, self.mouse_loc[1]+offset+text_height) bgl.glEnd() bgl.glColor4f(1.0, 1.0, 1.0, 1.0) blf.position(font_id, self.mouse_loc[0]-offset, self.mouse_loc[1]+offset, 0) blf.size(font_id, 15, 72) blf.draw(font_id, self.mouse_text) # 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: download.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def draw_callback(self, context): mid = int(360 * self.recv / self.fsize) cx = 200 cy = 30 blf.position(0, 230, 23, 0) blf.size(0, 20, 72) blf.draw(0, "{0:2d}% of {1}".format( 100 * self.recv // self.fsize, self.hfsize)) bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(.7, .7, .7, 0.8) bgl.glBegin(bgl.GL_TRIANGLE_FAN) bgl.glVertex2i(cx, cy) for i in range(mid): x = cx + 20 * math.sin(math.radians(float(i))) y = cy + 20 * math.cos(math.radians(float(i))) bgl.glVertex2f(x, y) bgl.glEnd() bgl.glColor4f(.0, .0, .0, 0.6) bgl.glBegin(bgl.GL_TRIANGLE_FAN) bgl.glVertex2i(cx, cy) for i in range(mid, 360): x = cx + 20 * math.sin(math.radians(float(i))) y = cy + 20 * math.cos(math.radians(float(i))) bgl.glVertex2f(x, y) bgl.glEnd() bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #7
Source File: node_colorramp_dropper.py From BAddons with GNU General Public License v3.0 | 5 votes |
def drawPoint(x, y, main=True): r = 6 if main else 3 bgl.glBegin(bgl.GL_LINES) bgl.glColor3f(1.0, 1.0, 1.0) bgl.glVertex2i(x - r, y) bgl.glVertex2i(x - r, y + r) bgl.glVertex2i(x - r, y + r) bgl.glVertex2i(x, y + r) bgl.glVertex2i(x + r, y) bgl.glVertex2i(x + r, y - r) bgl.glVertex2i(x + r, y - r) bgl.glVertex2i(x, y - r) bgl.glColor3f(0.0, 0.0, 0.0) bgl.glVertex2i(x, y + r) bgl.glVertex2i(x + r, y + r) bgl.glVertex2i(x + r, y + r) bgl.glVertex2i(x + r, y) bgl.glVertex2i(x, y - r) bgl.glVertex2i(x - r, y - r) bgl.glVertex2i(x - r, y - r) bgl.glVertex2i(x - r, y) bgl.glEnd()
Example #8
Source File: functions_draw.py From coa_tools with GNU General Public License v3.0 | 4 votes |
def draw_edit_mode(self,context,color=[0.41, 0.38, 1.0, 1.0],text="Edit Shapekey Mode",offset=0): region = context.region x = region.width y = region.height scale = x / 1200 scale = clamp(scale,.5,1.5) r_offset = 0 if context.user_preferences.system.use_region_overlap: r_offset = context.area.regions[1].width ### draw box behind text b_width = int(240*scale) b_height = int(36*scale) bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(color[0],color[1],color[2],color[3]) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2i(x-b_width, 0) bgl.glVertex2i(x, 0) bgl.glVertex2i(x, b_height) bgl.glVertex2i(x-b_width, b_height) bgl.glVertex2i(x-b_width, 0) bgl.glEnd() ### draw edit type font_id = 0 # XXX, need to find out how best to get this. bgl.glColor4f(0.041613, 0.041613, 0.041613, 1.000000) text_offset = int((220+offset)*scale) text_y_offset = int(11 * scale) blf.position(font_id, x-text_offset, text_y_offset, 0) blf.size(font_id, 20, int(72*scale)) blf.draw(font_id, text) ### draw viewport outline bgl.glEnable(bgl.GL_BLEND) bgl.glColor4f(color[0],color[1],color[2],color[3]) bgl.glLineWidth(4) bgl.glBegin(bgl.GL_LINE_STRIP) bgl.glVertex2i(r_offset, 0) bgl.glVertex2i(r_offset+x, 0) bgl.glVertex2i(r_offset+x, y) bgl.glVertex2i(r_offset+0, y) bgl.glVertex2i(r_offset, 0) bgl.glEnd() # restore opengl defaults bgl.glLineWidth(1) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #9
Source File: BakeLab_1_2.py From Bakelab-Blender-addon with GNU General Public License v3.0 | 4 votes |
def BakeLab_DrawCallback(self, context): props = context.scene.BakeLabProps ww = context.area.width wh = context.area.height bgl.glEnable(bgl.GL_BLEND) blf.enable(0,blf.SHADOW) blf.shadow(0,5,0,0.0,0.0,1) ######### Title { bgl.glBegin(bgl.GL_QUADS) bgl.glColor4f(0.88, 0.87, 0.85, 0.1) for i in range(0,20): bgl.glVertex2i(0, wh) bgl.glVertex2i(120+i*3, wh) bgl.glVertex2i(120+i*3, wh-70) bgl.glVertex2i(0, wh-70) bgl.glColor4f(0.7,0.1,0.3, 0.1) for i in range(0,20): bgl.glVertex2i(0, wh-70) bgl.glVertex2i(140+i*3, wh-70) bgl.glVertex2i(140+i*3, wh-75) bgl.glVertex2i(0, wh-75) bgl.glEnd() blf.size(0, 30, 72) bgl.glColor4f(0.7,0.1,0.3, 1.0) blf.position(0, 15, context.area.height-58, 0) blf.draw(0, 'BakeLab') ######### } ######### Progress { blf.size(0, 15, 72) y_shift = 15 ####################################################################### cur = self.bake_item_id max = len(context.scene.BakeLabMapColl) BakeLab_DrawProgressBar(y_shift,cur/max,'Map: '+ str(cur)+' of '+str(max)) y_shift += 30 ####################################################################### if not props.s_to_a and not props.all_in_one: cur = self.bake_obj_id max = len(self.bake_objs) BakeLab_DrawProgressBar(y_shift,cur/max,'Object: '+ str(cur)+' of '+str(max)) y_shift += 30 ####################################################################### if props.use_list: cur = self.ObjListIndex max = len(context.scene.BakeLabObjColl) BakeLab_DrawProgressBar(y_shift,cur/max,'List: '+ str(cur)+' of '+str(max)) y_shift += 30 ####################################################################### ######### } blf.disable(0,blf.SHADOW) bgl.glDisable(bgl.GL_BLEND) bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Example #10
Source File: space_view3d_enhanced_3d_cursor.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def draw_bookmark(self, context): r = context.region rv3d = context.region_data bookmark = self.bookmarks.get_item() if not bookmark: return pos = self.convert_to_abs(context.space_data, bookmark.pos) if pos is None: return projected = location_3d_to_region_2d(r, rv3d, pos) if projected: # Store previous OpenGL settings smooth_prev = gl_get(bgl.GL_SMOOTH) pixelsize = 1 dpi = context.user_preferences.system.dpi widget_unit = (pixelsize * dpi * 20.0 + 36.0) / 72.0 bgl.glShadeModel(bgl.GL_SMOOTH) bgl.glLineWidth(2) bgl.glColor4f(0.0, 1.0, 0.0, 1.0) bgl.glBegin(bgl.GL_LINE_STRIP) radius = widget_unit * 0.3 #6 n = 8 da = 2 * math.pi / n x, y = projected x, y = int(x), int(y) for i in range(n + 1): a = i * da dx = math.sin(a) * radius dy = math.cos(a) * radius if (i % 2) == 0: bgl.glColor4f(0.0, 1.0, 0.0, 1.0) else: bgl.glColor4f(0.0, 0.0, 0.0, 1.0) bgl.glVertex2i(x + int(dx), y + int(dy)) bgl.glEnd() # Restore previous OpenGL settings gl_enable(bgl.GL_SMOOTH, smooth_prev)