Example #1
0
    def draw_text(self):
        bgl.glColor3f(0, 0, 0)

        blf.position(FONT_ID, self.offset_x, self.offset_y + NODE_HIGHT / 4, 0)
        blf.blur(FONT_ID, 0)
        blf.size(FONT_ID, 30, 30)
        blf.draw(FONT_ID, self.text)
Example #2
0
def write():
    """write on screen"""
    width = render.getWindowWidth()
    height = render.getWindowHeight()

    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, width, 0, height)
    #bgl.glColor(1,1,1,1)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    # BLF drawing routine
    font_id = logic.font_id
    RED = (1, 0, 0, 1)
    pcol = ("Blue ", RED)
    #blf.color(font_id, 1, 1, 0, 0.5)
    blf.blur(font_id, 500)
    blf.rotation(font_id, 90)
    blf.position(font_id, (width * 0.5), (height * 0.5), 0.5)
    blf.size(font_id, 20, 100)
    blf.draw(font_id, "Hello World1")
    blf.size(font_id, 50, 72)
    blf.position(font_id, (width * 0.0), (height * 0.5), 0.5)
    blf.draw(font_id, "Hello World2")
Example #3
0
        def draw_text(text):
            col = prefs.color_shadow
            bgl.glColor4f(*col[:3], col[3] * 20)
            blf.blur(font_id, 5)
            blf.draw(font_id, text)
            blf.blur(font_id, 0)

            bgl.glColor3f(*prefs.color)
            blf.draw(font_id, text)
Example #4
0
        def draw_text(text):
            col = prefs.color_shadow
            bgl.glColor4f(*col[:3], col[3] * 20)
            blf.blur(font_id, 5)
            blf.draw(font_id, text)
            blf.blur(font_id, 0)

            bgl.glColor3f(*prefs.color)
            blf.draw(font_id, text)
Example #5
0
    def __render_each_data(context, data):
        sc = context.scene
        # setup rendering region
        for area in bpy.context.screen.areas:
            if area.type == "VIEW_3D":
                break
        else:
            return
        for region in area.regions:
            if region.type == "WINDOW":
                break
        else:
            return
        for space in area.spaces:
            if space.type == "VIEW_3D":
                break
        else:
            return
        loc_on_screen = view3d_utils.location_3d_to_region_2d(
            region,
            space.region_3d,
            data[1])

        rect = get_canvas(context, loc_on_screen, len(str(data[0])), sc.iv_font_size)
        positions = [
            [rect.x0, rect.y0],
            [rect.x0, rect.y1],
            [rect.x1, rect.y1],
            [rect.x1, rect.y0]
        ]

        # render box
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_QUADS)
        box_color_r, box_color_g, box_color_b, box_color_a = sc.iv_box_color
        bgl.glColor4f(box_color_r, box_color_g, box_color_b, box_color_a)
        for (v1, v2) in positions:
            bgl.glVertex2f(v1, v2)
        bgl.glEnd()

        # render index
        font_size = sc.iv_font_size
        blf.size(0, font_size, 72)
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.0)
        blf.position(0, rect.x0 + (rect.x1 - rect.x0) * 0.18, rect.y0 + (rect.y1 - rect.y0) * 0.24, 0)
        text_color_r, text_color_g, text_color_b, text_color_a = sc.iv_text_color
        bgl.glColor4f(text_color_r, text_color_g, text_color_b, text_color_a)
        blf.draw(0, str(data[0]))
        blf.blur(0, 0)
        blf.disable(0, blf.SHADOW)
    def __render_each_data(context, data):
        sc = context.scene
        # setup rendering region
        for area in bpy.context.screen.areas:
            if area.type == "VIEW_3D":
                break
        else:
            return
        for region in area.regions:
            if region.type == "WINDOW":
                break
        else:
            return
        for space in area.spaces:
            if space.type == "VIEW_3D":
                break
        else:
            return
        loc_on_screen = view3d_utils.location_3d_to_region_2d(
            region,
            space.region_3d,
            data[1])

        rect = get_canvas(context, loc_on_screen, len(str(data[0])), sc.iv_font_size)
        positions = [
            [rect.x0, rect.y0],
            [rect.x0, rect.y1],
            [rect.x1, rect.y1],
            [rect.x1, rect.y0]
            ]

        # render box
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_QUADS)
        box_color_r, box_color_g, box_color_b, box_color_a = sc.iv_box_color
        bgl.glColor4f(box_color_r, box_color_g, box_color_b, box_color_a)
        for (v1, v2) in positions:
            bgl.glVertex2f(v1, v2)
        bgl.glEnd()

        # render index
        font_size = sc.iv_font_size
        blf.size(0, font_size, 72)
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.0)
        blf.position(0, rect.x0 + (rect.x1 - rect.x0) * 0.18, rect.y0 + (rect.y1 - rect.y0) * 0.24, 0)
        text_color_r, text_color_g, text_color_b, text_color_a = sc.iv_text_color
        bgl.glColor4f(text_color_r, text_color_g, text_color_b, text_color_a)
        blf.draw(0, str(data[0]))
        blf.blur(0, 0)
        blf.disable(0, blf.SHADOW)
Example #7
0
def draw_text(mouse, text, color):
    dpi = int(bpy.context.user_preferences.system.pixel_size)

    bgl.glEnable(bgl.GL_BLEND)
    font_id = 0  # XXX, need to find out how best to get this.
    # draw some text
    bgl.glColor4f(0, 0, 0, 0.75)
    blf.blur(font_id, 5)
    blf.position(font_id, mouse[0] + 10 * dpi, mouse[1] - 20 * dpi, 0)
    blf.size(font_id, 8 * dpi, 96)
    blf.draw(font_id, text)

    bgl.glEnd()
    bgl.glColor4f(*color)
    blf.blur(font_id, 0)
    blf.draw(font_id, text)
    bgl.glDisable(bgl.GL_BLEND)
def draw_callback_px(self, context):
    wm = context.window_manager
    r = 0.8
    g = 0.1
    b = 0.2

    if (context.window_manager.leap_nui_keyboardless_active):
        #print("Draw Callback True")
        # draw text in the 3D View
        bgl.glPushClientAttrib(bgl.GL_CURRENT_BIT | bgl.GL_ENABLE_BIT)

        blf.size(0, 12, 72)
        blf.position(0, 10, 10, 0)
        bgl.glColor4f(r, g, b, 0.7)
        blf.blur(0, 1)
        # shadow?
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)

        blf.draw(0, "Leap Active!")

        bgl.glPopClientAttrib()
    else:
        #print("Draw Callback False")
        pass

    #
    # Draw the LeapInfo log messages
    font_size = 24
    messages = wm.leap_info.log_messages
    n_messages = len(messages)
    log_y_size = LeapInfo.MAX_LOG_MESSAGES * font_size
    #pos_y = context.region.height - ((context.region.height - log_y_size) / 2)
    pos_y = ((context.region.height - log_y_size) / 2)
    pos_x = 0
    bgl.glPushClientAttrib(bgl.GL_CURRENT_BIT | bgl.GL_ENABLE_BIT)
    blf.size(0, font_size, 72)
    bgl.glColor4f(r, g, b, 0.7)

    for time, msg in reversed(messages):
        blf.position(0, pos_x, pos_y, 0)
        blf.draw(0, msg)
        pos_y += font_size

    bgl.glPopClientAttrib()

    #
    # Draw icon if the hand is visible to the Leap
    if (wm.leap_info.leap_listener.getHandId() == None):  # NO HAND
        pass
    else:
        pos_x = context.region.width - (Icons.ICON_SIZE * 1.5)
        pos_y = (Icons.ICON_SIZE / 2)

        if (wm.leap_info.isTracking()):  # GREEN HAND
            Icons.drawIcon("5-spreadfingers-icon-green.png", pos_x, pos_y)
            pass
        else:  # RED HAND
            Icons.drawIcon("5-spreadfingers-icon-red.png", pos_x, pos_y)
            pass
 def blur(radius, fontid=None):
     return blf.blur(FontManager.load(fontid), radius)
def draw_callback_px_text(self, context):
    wm = context.window_manager
    sc = context.scene
    if not wm.screencast_keys_keys:
        return

    font_size  = sc.screencast_keys_font_size
    mouse_size = sc.screencast_keys_mouse_size
    box_draw   = sc.screencast_keys_box_draw
    pos_x, pos_y = getDisplayLocation(context)
    label_time_max = sc.screencast_keys_fade_time

    # draw text in the 3D View
    blf.size(0, sc.screencast_keys_font_size, 72)
    blf.enable(0, blf.SHADOW)
    blf.shadow_offset(0, 1, -1)
    blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)

    font_color_r, font_color_g, font_color_b, font_color_alpha = sc.screencast_keys_text_color
    final = 0
    row_count = len(self.key)

    keypos_x = pos_x

    if sc.screencast_keys_mouse_position == 'left':
        keypos_x += mouse_size * MOUSE_RATIO * 1.7
    if sc.screencast_keys_mouse != 'icon':
        keypos_x -= mouse_size * MOUSE_RATIO
    if sc.screencast_keys_mouse_position == 'right' and sc.screencast_keys_mouse != 'icon':
        keypos_x = pos_x

    shift = 0

    # we want to make sure we can shift vertically the text if the mouse is big,
    # but don't care if aligned to right 
    if mouse_size > font_size*row_count and not sc.screencast_keys_mouse_position == 'right':
        shift = (mouse_size - font_size*row_count) / 2

    text_width, text_height = 0,0
    row_count = 0
    alpha = 1.0

    for i in range(len(self.key)):
        label_time = time.time() - self.time[i]
        if label_time < label_time_max: # only display key-presses of last 2 seconds
            if label_time > (label_time_max / 1.2):
                blf.blur(0, 1)
            if label_time > (label_time_max / 1.1):
                blf.blur(0, 3)
            keypos_y = pos_y + shift + font_size*(i+0.1)

            blf.position(0, keypos_x, keypos_y , 0)
            alpha = min(1.0, max(0.0, label_time_max * (label_time_max - label_time)))
            bgl.glColor4f(font_color_r, font_color_g, font_color_b, font_color_alpha * alpha)
            blf.draw(0, self.key[i])
            text_width, text_height = getBoundingBox(text_width, text_height,
                self.key[i])
            row_count += 1
            final = i + 1
        else:
            break

    # remove blurriness 

    # disable shadows so they don't appear all over blender
    blf.blur(0,0)
    blf.disable(0, blf.SHADOW)

    # get rid of status texts that aren't displayed anymore
    self.key = self.key[:final]
    self.time = self.time[:final]

    # draw graphical representation of the mouse
    if sc.screencast_keys_mouse == 'icon':
        for shape in ["mouse", "left_button", "middle_button", "right_button"]:
            draw_mouse(context, shape, "outline", font_color_alpha * 0.4)
        final = 0

        for i in range(len(self.mouse)):
            click_time = time.time() - self.mouse_time[i]
            if click_time < 2:
                shape = map_mouse_event(self.mouse[i])
                if shape:
                    alpha = min(1.0, max(0.0, 2 * (2 - click_time)))
                    draw_mouse(context, shape, "filled", alpha)
                final = i + 1
            else:
                break

    # get rid of mouse clicks that aren't displayed anymore
    self.mouse = self.mouse[:final]
    self.mouse_time = self.mouse_time[:final]
Example #11
0
	def draw(self):
		if self.visible == False: return
		module.post_draw_step += 1
		
		cam = self.scene.active_camera
		orth = cam.ortho_scale
		
		height = render.getWindowHeight()
		width = render.getWindowWidth()
		near = cam.near
		far = cam.far
		h = cam.worldPosition.z
		font_id = Label._fontname_id[self._font]
		unit = width/orth
		self._glunit = unit
		rpos = self._position - cam.worldPosition
		
		bgl.glMatrixMode(bgl.GL_PROJECTION)
		bgl.glLoadIdentity()
		bgl.gluOrtho2D(0, width, 0, height)
		bgl.glMatrixMode(bgl.GL_MODELVIEW)
		bgl.glLoadIdentity()
		
		bgl.glEnable(bgl.GL_BLEND)
		bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
		bgl.glAlphaFunc(bgl.GL_SRC_ALPHA, 1)
		
		#Z AXIS
		oh = (far-near)/2
		ortho_unit = 1/oh
		dh = oh

		pos = list([width/2+rpos[0]*unit, height/2+rpos[1]*unit, dh*ortho_unit + rpos[2]*ortho_unit])
		if self._lastscale != self.scale or True:
			blf.size(font_id, int(self.scale.x*unit), 72)
		else:
			if self._lastorth != orth:
				sc = (float(self._lastorth) / float(orth)) * self.scale.x
				bgl.glScalef(sc,sc,1)
				print(str(self._lastorth) + " " + str(orth))
				pos[0] /= sc
				pos[1] /= sc
				
			else:
				self._lastorth = orth
		
		x, y = blf.dimensions(font_id, self._text) #NOTE: Always after blf.size()
		
		if self.align == ALIGN_CENTER:
			pos[0] -= (x)/2 * math.cos(self._rotation.z)
			pos[1] -= x/2 * math.sin(self._rotation.z)
		if self.align == ALIGN_RIGHT:
			pos[0] -= x * math.cos(self._rotation.z)
			pos[1] -= x * math.sin(self._rotation.z)
			
		if self.middle_height == True:
			pos[0] -= y/4 * math.sin(self._rotation.z)
			pos[1] -= y/4 * math.cos(self._rotation.z)
		
		blf.position(font_id, pos[0], pos[1], pos[2])
		blf.enable(font_id, blf.ROTATION)
		if self.rotation.z > 0.01 or self.rotation.z < -0.01:
			blf.rotation(font_id, self._rotation.z)
		else:
			blf.rotation(font_id, 0)
		
		if self.shadow == True:
			blf.position(font_id, pos[0]+self.shadow_offset[0], pos[1]+self.shadow_offset[1], pos[2])
			bgl.glColor4f(*self.shadow_color)
			blf.blur(font_id, self.shadow_blur)
			blf.draw(font_id, self._text)
			blf.position(font_id, pos[0], pos[1], pos[2])
			
		bgl.glColor4f(*self._color)
		blf.blur(font_id, self.blur)
		blf.draw(font_id, self._text)
		
		blf.disable(font_id, blf.ROTATION)
		
		self._lastscale = self.scale
    def drawIcons(self):
        global s_registration_active_space

        #print("Callback drawIcons")

        context = bpy.context

        #print("Drawing Icons in active space "+str(context.area.spaces.active.as_pointer()))
        if (s_registration_active_space != None):
            if (not (s_registration_active_space.as_pointer()
                     == context.area.spaces.active.as_pointer())):
                #print("Skipping...")
                return

        #print("Drawing icons on context " + str(context) + "\tarea is " + str(context.area) + "(" + context.area.type +")")

        #glDrawPixels(width, height, format, type, pixels)
        #Write a block of pixels to the frame buffer
        #
        #height (width,) – Specify the dimensions of the pixel rectangle to be written into the frame buffer.
        #format (Enumerated constant) – Specifies the format of the pixel data.
        #type (Enumerated constant) – Specifies the data type for pixels.
        #pixels (bgl.Buffer object) – Specifies a pointer to the pixel data.

        bgl.glPushClientAttrib(bgl.GL_CURRENT_BIT | bgl.GL_ENABLE_BIT)

        # transparence
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)

        ICON_SIZE = 64
        GRID_SIZE = 3
        BORDER_SIZE = 5

        blf.size(0, self.FONT_SIZE, 72)
        #bgl.glColor4f(*self.FONT_RGBA)
        blf.blur(0, 1)

        #bgl.glScalef(0.5,0.5,0.5)

        # Cycle to draw all the cells
        cell_num = 0
        pos_y = context.region.height - ICON_SIZE - BORDER_SIZE
        for buffers_line in self.buffers:
            #pos_x = (context.region.width - (ICON_SIZE * GRID_SIZE) - (BORDER_SIZE * (GRID_SIZE-1)) ) / 2
            pos_x = context.region.width - (
                (ICON_SIZE + BORDER_SIZE) * GRID_SIZE)

            for buf in buffers_line:
                #print("Drawing icon for pos "+ str(cell_num))
                bgl.glRasterPos2f(pos_x, pos_y)
                bgl.glDrawPixels(ICON_SIZE, ICON_SIZE, bgl.GL_RGBA,
                                 bgl.GL_FLOAT, buf)

                # Print the char
                blf.position(0, pos_x, pos_y, 0)
                #bgl.glPushClientAttrib(bgl.GL_CLIENT_ALL_ATTRIB_BITS) #CURRENT_BIT|bgl.GL_ENABLE_BIT)
                bgl.glPushAttrib(bgl.GL_CLIENT_ALL_ATTRIB_BITS)
                blf.size(0, self.FONT_SIZE, 72)
                #blf.blur(0, 10)
                #blf.shadow(0, 3, 0.5, 0.5, 0.5, 0.2)
                #blf.shadow_offset(0, int(self.FONT_SIZE/10), int(self.FONT_SIZE/10))
                bgl.glColor4f(*self.FONT_RGBA)
                blf.draw(0, self.shortcut_keys[cell_num])
                bgl.glPopAttrib()
                #bgl.glPopClientAttrib()

                pos_x += ICON_SIZE + BORDER_SIZE
                cell_num += 1

            pos_y -= ICON_SIZE + BORDER_SIZE

        bgl.glPopClientAttrib()

        pass
Example #13
0
    def draw(self):
        if self.visible == False: return
        module.post_draw_step += 1

        cam = self.scene.active_camera
        orth = cam.ortho_scale

        height = render.getWindowHeight()
        width = render.getWindowWidth()
        near = cam.near
        far = cam.far
        h = cam.worldPosition.z
        font_id = Label._fontname_id[self._font]
        unit = width / orth
        self._glunit = unit
        rpos = self._position - cam.worldPosition

        bgl.glMatrixMode(bgl.GL_PROJECTION)
        bgl.glLoadIdentity()
        bgl.gluOrtho2D(0, width, 0, height)
        bgl.glMatrixMode(bgl.GL_MODELVIEW)
        bgl.glLoadIdentity()

        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
        bgl.glAlphaFunc(bgl.GL_SRC_ALPHA, 1)

        #Z AXIS
        oh = (far - near) / 2
        ortho_unit = 1 / oh
        dh = oh

        pos = list([
            width / 2 + rpos[0] * unit, height / 2 + rpos[1] * unit,
            dh * ortho_unit + rpos[2] * ortho_unit
        ])
        if self._lastscale != self.scale or True:
            blf.size(font_id, int(self.scale.x * unit), 72)
        else:
            if self._lastorth != orth:
                sc = (float(self._lastorth) / float(orth)) * self.scale.x
                bgl.glScalef(sc, sc, 1)
                print(str(self._lastorth) + " " + str(orth))
                pos[0] /= sc
                pos[1] /= sc

            else:
                self._lastorth = orth

        x, y = blf.dimensions(font_id,
                              self._text)  #NOTE: Always after blf.size()

        if self.align == ALIGN_CENTER:
            pos[0] -= (x) / 2 * math.cos(self._rotation.z)
            pos[1] -= x / 2 * math.sin(self._rotation.z)
        if self.align == ALIGN_RIGHT:
            pos[0] -= x * math.cos(self._rotation.z)
            pos[1] -= x * math.sin(self._rotation.z)

        if self.middle_height == True:
            pos[0] -= y / 4 * math.sin(self._rotation.z)
            pos[1] -= y / 4 * math.cos(self._rotation.z)

        blf.position(font_id, pos[0], pos[1], pos[2])
        blf.enable(font_id, blf.ROTATION)
        if self.rotation.z > 0.01 or self.rotation.z < -0.01:
            blf.rotation(font_id, self._rotation.z)
        else:
            blf.rotation(font_id, 0)

        if self.shadow == True:
            blf.position(font_id, pos[0] + self.shadow_offset[0],
                         pos[1] + self.shadow_offset[1], pos[2])
            bgl.glColor4f(*self.shadow_color)
            blf.blur(font_id, self.shadow_blur)
            blf.draw(font_id, self._text)
            blf.position(font_id, pos[0], pos[1], pos[2])

        bgl.glColor4f(*self._color)
        blf.blur(font_id, self.blur)
        blf.draw(font_id, self._text)

        blf.disable(font_id, blf.ROTATION)

        self._lastscale = self.scale
Example #14
0
def set_blf_blur(font_id, radius):
    if check_version(2, 80, 0) < 0:
        blf.blur(font_id, radius)
Example #15
0
def set_blf_blur(font_id, radius):
    if check_version(2, 80, 0) < 0:
        blf.blur(font_id, radius)
def draw_callback_px_text(self, context):
    wm = context.window_manager
    sc = context.scene
    if not wm.screencast_keys_keys:
        return

    font_size = sc.screencast_keys_font_size
    mouse_size = sc.screencast_keys_mouse_size
    box_draw = sc.screencast_keys_box_draw
    pos_x, pos_y = getDisplayLocation(context)
    label_time_max = sc.screencast_keys_fade_time

    # draw text in the 3D View
    blf.size(0, sc.screencast_keys_font_size, 72)
    blf.enable(0, blf.SHADOW)
    blf.shadow_offset(0, 1, -1)
    blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)

    font_color_r, font_color_g, font_color_b, font_color_alpha = sc.screencast_keys_text_color
    final = 0
    row_count = len(self.key)

    keypos_x = pos_x

    if sc.screencast_keys_mouse_position == 'left':
        keypos_x += mouse_size * MOUSE_RATIO * 1.7
    if sc.screencast_keys_mouse != 'icon':
        keypos_x -= mouse_size * MOUSE_RATIO
    if sc.screencast_keys_mouse_position == 'right' and sc.screencast_keys_mouse != 'icon':
        keypos_x = pos_x

    shift = 0

    # we want to make sure we can shift vertically the text if the mouse is big,
    # but don't care if aligned to right
    if mouse_size > font_size * row_count and not sc.screencast_keys_mouse_position == 'right':
        shift = (mouse_size - font_size * row_count) / 2

    text_width, text_height = 0, 0
    row_count = 0
    alpha = 1.0

    for i in range(len(self.key)):
        label_time = time.time() - self.time[i]
        if label_time < label_time_max:  # only display key-presses of last 2 seconds
            if label_time > (label_time_max / 1.2):
                blf.blur(0, 1)
            if label_time > (label_time_max / 1.1):
                blf.blur(0, 3)
            keypos_y = pos_y + shift + font_size * (i + 0.1)

            blf.position(0, keypos_x, keypos_y, 0)
            alpha = min(
                1.0, max(0.0, label_time_max * (label_time_max - label_time)))
            bgl.glColor4f(font_color_r, font_color_g, font_color_b,
                          font_color_alpha * alpha)
            blf.draw(0, self.key[i])
            text_width, text_height = getBoundingBox(text_width, text_height,
                                                     self.key[i])
            row_count += 1
            final = i + 1
        else:
            break

    # remove blurriness

    # disable shadows so they don't appear all over blender
    blf.blur(0, 0)
    blf.disable(0, blf.SHADOW)

    # get rid of status texts that aren't displayed anymore
    self.key = self.key[:final]
    self.time = self.time[:final]

    # draw graphical representation of the mouse
    if sc.screencast_keys_mouse == 'icon':
        for shape in ["mouse", "left_button", "middle_button", "right_button"]:
            draw_mouse(context, shape, "outline", font_color_alpha * 0.4)
        final = 0

        for i in range(len(self.mouse)):
            click_time = time.time() - self.mouse_time[i]
            if click_time < 2:
                shape = map_mouse_event(self.mouse[i])
                if shape:
                    alpha = min(1.0, max(0.0, 2 * (2 - click_time)))
                    draw_mouse(context, shape, "filled", alpha)
                final = i + 1
            else:
                break

    # get rid of mouse clicks that aren't displayed anymore
    self.mouse = self.mouse[:final]
    self.mouse_time = self.mouse_time[:final]
Example #17
0
 def blur(radius, fontid=None):
     return blf.blur(FontManager.load(fontid), radius)