Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bgl
- import blf
- import bpy
- '''
- Copyright (c) 2019
- Jorge Hernández - Meléndez Saiz
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- '''
- font_info = {
- "font_id": 0,
- "handler": None,
- }
- def init():
- font_info["font_id"] = 0
- # set the font drawing routine to run every frame
- font_info["handler"] = bpy.types.SpaceView3D.draw_handler_add(
- draw_callback_px, (None, None), 'WINDOW', 'POST_PIXEL')
- def draw_callback_px(self, context):
- """Draw on the viewports"""
- # BLF drawing routine
- font_id = font_info["font_id"]
- offsetTextInTop = 86
- height = bpy.context.area.height - offsetTextInTop
- toolbarWidth = bpy.context.area.regions[1].width
- blf.position(font_id, 20+toolbarWidth, height, 0)
- fontSize = 11
- blf.size(font_id, fontSize, 72)
- # sombra:
- # el level tiene que ser 3, 5 o 0
- level = 0
- r = 0.0
- g = 0.0
- b = 0.0
- a = 1.0
- blf.shadow(font_id, level, r, g, b, a)
- blf.shadow_offset(font_id, 2, 1)
- # esto se calcula cada pasada de dibujado del viewport:
- motor = bpy.context.scene.render.engine
- if motor == 'BLENDER_EEVEE':
- blf.draw(font_id, "Eevee")
- elif motor == 'BLENDER_WORKBENCH':
- blf.draw(font_id, "Workbench")
- elif motor == 'CYCLES':
- blf.draw(font_id, "Cycles")
- else:
- blf.draw(font_id, "")
- if __name__ == '__main__':
- init()
Advertisement
Add Comment
Please, Sign In to add comment