Guest User

Untitled

a guest
Jan 29th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. import bgl
  2. import blf
  3. import bpy
  4.  
  5.  
  6. '''
  7. Copyright (c) 2019
  8.  
  9. Jorge Hernández - Meléndez Saiz
  10.  
  11. This program is free software: you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation, either version 3 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program. If not, see <http://www.gnu.org/licenses/>.
  23.  
  24. '''
  25.  
  26.  
  27. font_info = {
  28.     "font_id": 0,
  29.     "handler": None,
  30. }
  31.  
  32.  
  33. def init():
  34.     font_info["font_id"] = 0
  35.  
  36.     # set the font drawing routine to run every frame
  37.     font_info["handler"] = bpy.types.SpaceView3D.draw_handler_add(
  38.         draw_callback_px, (None, None), 'WINDOW', 'POST_PIXEL')
  39.  
  40.  
  41. def draw_callback_px(self, context):
  42.     """Draw on the viewports"""
  43.     # BLF drawing routine
  44.     font_id = font_info["font_id"]
  45.    
  46.     offsetTextInTop = 86
  47.     height = bpy.context.area.height - offsetTextInTop
  48.    
  49.     toolbarWidth = bpy.context.area.regions[1].width
  50.  
  51.     blf.position(font_id, 20+toolbarWidth, height, 0)
  52.  
  53.     fontSize = 11
  54.     blf.size(font_id, fontSize, 72)
  55.    
  56.     # sombra:
  57.     # el level tiene que ser 3, 5 o 0
  58.     level = 0
  59.     r = 0.0
  60.     g = 0.0
  61.     b = 0.0
  62.     a = 1.0
  63.  
  64.     blf.shadow(font_id, level, r, g, b, a)
  65.     blf.shadow_offset(font_id, 2, 1)
  66.  
  67.     # esto se calcula cada pasada de dibujado del viewport:
  68.     motor = bpy.context.scene.render.engine
  69.     if motor == 'BLENDER_EEVEE':
  70.         blf.draw(font_id, "Eevee")
  71.     elif motor == 'BLENDER_WORKBENCH':
  72.         blf.draw(font_id, "Workbench")
  73.     elif motor == 'CYCLES':
  74.         blf.draw(font_id, "Cycles")
  75.     else:
  76.         blf.draw(font_id, "")
  77.  
  78.  
  79. if __name__ == '__main__':
  80.     init()
Advertisement
Add Comment
Please, Sign In to add comment