def draw_clipped(self): blf.size(self.textData.font_id, self.textData.fontSize, 72) blf.enable(self.textData.font_id, blf.CLIPPING) blf.clipping(self.textData.font_id, *self.clipRect._clipRect) if self.textData.color: blf.color(self.textData.font_id, *self.textData.color) blf.position(self.textData.font_id, self.xPos, self.yPos, 0) blf.draw(self.textData.font_id, self.text) blf.disable(self.textData.font_id, blf.CLIPPING)
def draw_callback_px_optimized(op:Boss_OT_base_ui): uip:uiParams.uiParams = op.uip bgl.glEnable(bgl.GL_BLEND) try: _shader = None for panel in uip.ui_drawable: geo = panel.geo if not geo: continue batch = geo._batched if geo._batched else geo.newbatch() if _shader == geo.shader: pass else: _shader = geo.shader _shader.bind() if geo.geoData.image_path == '': pass else: bgl.glActiveTexture(bgl.GL_TEXTURE0) bgl.glBindTexture(bgl.GL_TEXTURE_2D, geo.imageData.bindcode) geo.shader.uniform_int("image", 0) if geo.clipRect: geo.shader.uniform_float( 'clipRect', panel.clipRect._clipRect ) batch.draw(geo.shader) _shader = None blf.size(g_font_id, g_font_size, g_dpi) blf.color(g_font_id, *g_font_color) is_clipping_enabled = False for panel in uip.ui_drawable_texts: t = panel._text blf.position(g_font_id, t.xPos, t.yPos, 0) if t.clipRect: if is_clipping_enabled: pass else: blf.enable(g_font_id, blf.CLIPPING) is_clipping_enabled = True blf.clipping(g_font_id, *t.clipRect._clipRect) else: if is_clipping_enabled: blf.disable(g_font_id, blf.CLIPPING) is_clipping_enabled = False blf.draw(g_font_id, t.text) if is_clipping_enabled: blf.disable(g_font_id, blf.CLIPPING) except Exception as e: print('*' * 25, 'Drawing failed: ', '*' * 25) op.msg(f'{e} ... Drawing Failed, check console for details', 2) print(str(e)) print(traceback.format_exc()) print('*' * 25, 'drawing failed: ', '*' * 25) op.quit() if op.display_text: for dt in op.display_text: dt.draw() if uip.globalToolTipImagePath: showGlobalImageToolTip(uip) if uip.globalToolTip: showGlobalTextToolTip(uip) if uip._canDrawCursor: uip.cursor.draw() bgl.glDisable(bgl.GL_BLEND)
def clipping(xymin, xymax, fontid=None): return blf.clipping(FontManager.load(fontid), *xymin, *xymax)
def clipping(self, fontid, xmin, ymin, xmax, ymax): return blf.clipping(fontid, xmin, ymin, xmax, ymax)
def set_clipping(self, xmin, ymin, xmax, ymax): blf.clipping(self.font_id, xmin, ymin, xmax, ymax) self.enable_clipping()