[Bf-extensions-cvs] [8f97a1ca] master: animation_text_types: removed, unsupported
meta-androcto
noreply at git.blender.org
Sun Sep 8 13:45:36 CEST 2019
Commit: 8f97a1ca91707f8c41e0152fe4fbf59ac568607e
Author: meta-androcto
Date: Sun Sep 8 21:45:22 2019 +1000
Branches: master
https://developer.blender.org/rBAC8f97a1ca91707f8c41e0152fe4fbf59ac568607e
animation_text_types: removed, unsupported
===================================================================
D animation_text_types.py
===================================================================
diff --git a/animation_text_types.py b/animation_text_types.py
deleted file mode 100644
index 48bbfe73..00000000
--- a/animation_text_types.py
+++ /dev/null
@@ -1,743 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# 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 2
-# 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, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-# by LeoMoon Studios, Marcin Zielinski, Martin Wacker,
-# Bassam Kurdali, Jared Felsman, meta-androcto #
-
-bl_info = {
- "name": "Animated Text",
- "author": "LeoMoon Studios, Marcin Zielinski, Martin Wacker, "
- "Bassam Kurdali, Jared Felsman, meta-androcto",
- "version": (0, 3, 1),
- "blender": (2, 74, 5),
- "location": "Properties Editor > Font",
- "description": "Typing & Counting Animated Text",
- "warning": "",
- "wiki_url": "",
- "category": "Animation"
-}
-
-import bpy
-import random
-from bpy.types import (
- Operator,
- Panel,
- PropertyGroup,
- )
-from bpy.props import (
- FloatProperty,
- PointerProperty,
- BoolProperty,
- IntProperty,
- EnumProperty,
- StringProperty,
- )
-from bpy.app.handlers import persistent
-
-
-# In case of error set it to true so it can be used for console runes
-DEBUG = False
-
-
-# Use just as a regular print (switchable as the UI will be constantly updated
-def debug_print_vars(*args, **kwargs):
- global DEBUG
- if DEBUG:
- print(*args, **kwargs)
-
-
-def formatCounter(inputs, timeSeparators, timeLeadZeroes, timeTrailZeroes, timeModulo):
- f = 0
- s = 0
- m = 0
- h = 0
- out = ''
- neg = ''
- if inputs < 0:
- neg = '-'
- inputs = abs(inputs)
-
- if timeSeparators >= 0:
- if timeSeparators == 0:
- out = int(inputs)
- out = format(out, '0' + str(timeLeadZeroes) + 'd')
- else:
- s, f = divmod(int(inputs), timeModulo)
- out = format(f, '0' + str(timeLeadZeroes) + 'd')
-
- if timeSeparators >= 1:
- if timeSeparators == 1:
- out = format(s, '0' + str(timeTrailZeroes) + 'd') + ":" + out
- else:
- m, s = divmod(s, 60)
- out = format(s, '02d') + ":" + out
-
- if timeSeparators >= 2:
- if timeSeparators == 2:
- out = format(m, '0' + str(timeTrailZeroes) + 'd') + ":" + out
- else:
- h, m = divmod(m, 60)
- out = format(m, '02d') + ":" + out
-
- if timeSeparators >= 3:
- out = format(h, '0' + str(timeTrailZeroes) + 'd') + ":" + out
-
- return neg + out
-
-
-class TextCounter_Props(PropertyGroup):
-
- # A placeholder for the text box
- default_string = 'Enter a number or an expression'
-
- def val_up(self, context):
- textcounter_update_val(context.object, context.scene)
-
- ifAnimated: BoolProperty(
- name='Counter Active',
- default=False,
- update=val_up
- )
- counter: FloatProperty(
- name='Counter',
- update=val_up
- )
- padding: IntProperty(
- name='Padding',
- update=val_up,
- min=1
- )
- ifDecimal: BoolProperty(
- name='Decimal',
- default=False,
- update=val_up
- )
- decimals: IntProperty(
- name='Decimal',
- update=val_up,
- min=0
- )
- typeEnum: EnumProperty(
- items=[
- ('ANIMATED', 'Animated', 'Counter values from f-curves'),
- ('DYNAMIC', 'Dynamic', 'Counter values from expression')
- ],
- name='Type',
- update=val_up,
- default='ANIMATED'
- )
- formattingEnum: EnumProperty(
- items=[
- ('NUMBER', 'Number', 'Counter values as numbers'),
- ('TIME', 'Time', 'Counter values as time')
- ],
- name='Formatting Type',
- update=val_up,
- default='NUMBER'
- )
- # set to 0 as eval will crash in it's default state
- expr: StringProperty(
- name='Expression',
- description="Enter a number or a numeric expression",
- update=val_up,
- default=default_string
- )
- prefix: StringProperty(
- name='Prefix',
- update=val_up,
- default=''
- )
- sufix: StringProperty(
- name='Sufix',
- update=val_up,
- default=''
- )
- ifTextFile: BoolProperty(
- name='Override with Text File',
- default=False,
- update=val_up
- )
- textFile: StringProperty(
- name='Text File',
- update=val_up,
- default=''
- )
- ifTextFormatting: BoolProperty(
- name='Numerical Formatting',
- default=False,
- update=val_up
- )
- timeSeparators: IntProperty(
- name='Separators',
- update=val_up,
- min=0, max=3
- )
- timeModulo: IntProperty(
- name='Last Separator Modulo',
- update=val_up,
- min=1,
- default=24
- )
- timeLeadZeroes: IntProperty(
- name='Leading Zeroes',
- update=val_up,
- min=1,
- default=2
- )
- timeTrailZeroes: IntProperty(
- name='Trailing Zeroes',
- update=val_up,
- min=1,
- default=2
- )
-
- str_error = False
-
- def dyn_get(self):
- try:
- TextCounter_Props.str_error = False
- if self.expr in [TextCounter_Props.default_string, None, ""]:
- return '0'
- return str(eval(self.expr))
- except Exception as e:
- TextCounter_Props.str_error = True
- debug_print_vars('Expr Error: ' + str(e.args))
- return '0'
-
- dynamicCounter: StringProperty(
- name='Dynamic Counter',
- get=dyn_get,
- default=''
- )
-
- def form_up(self, context):
- textcounter_update_val(context.object, context.scene)
-
- def form_get(self):
- inputs = 0
-
- if self.typeEnum == 'ANIMATED':
- inputs = float(self.counter)
- elif self.typeEnum == 'DYNAMIC':
- inputs = float(self.dynamicCounter)
- return formatCounter(inputs, self.timeSeparators, self.timeLeadZeroes,
- self.timeTrailZeroes, self.timeModulo)
-
- def form_set(self, value):
- counter = 0
- separators = value.split(':')
- for idx, i in enumerate(separators[:-1]):
- counter += int(i) * 60**(len(separators) - 2 - idx) * self.timeModulo
- counter += int(separators[-1])
- self.counter = float(counter)
-
- formattedCounter: StringProperty(
- name='Formatted Counter',
- get=form_get,
- set=form_set,
- default=''
- )
-
-
-def textcounter_update_val(text, scene):
- text.update_tag(refresh={'DATA'})
- props = text.data.text_counter_props
- counter = 0
- line = ''
- out = ''
- neg = ''
-
- if props.typeEnum == 'ANIMATED':
- counter = props.counter
- elif props.typeEnum == 'DYNAMIC':
- if props.expr in [props.default_string, None, ""]:
- return 0
- try:
- counter = eval(props.expr)
- except Exception as e:
- debug_print_vars('Expr Error: ' + str(e.args))
-
- isNumeric = True # always true for counter not overrided
- if props.ifTextFile:
- txt = bpy.data.texts[props.textFile] if \
- props.textFile in bpy.data.texts.keys() else None
- if txt:
- clampedCounter = max(0, min(int(counter), len(txt.lines) - 1))
- line = txt.lines[clampedCounter].body
- if props.ifTextFormatting:
- try:
- line = float(line)
- except Exception as ex:
- debug_print_vars('Expr Error: ' + str(ex.args))
- isNumeric = False
- out = line
- else:
- isNumeric = False
- out = line
- else:
- line = counter
- else:
- line = counter
-
- if isNumeric:
- if props.formattingEnum == 'NUMBER':
- # add minus before padding zeroes
- neg = '-' if line < 0 else ''
- line = abs(line)
- # int / decimal
- if not props.ifDecimal:
- line = int(line)
- out = ('{:.' + str(props.decimals) + 'f}').format(line)
-
- # padding
- arr = out.split('.')
- arr[0] = arr[0].zfill(props.padding)
- out = arr[0]
- if len(arr) > 1:
- out += '.' + arr[1]
- elif props.formattingEnum == 'TIME':
- out = formatCounter(
- line, props.timeSeparators, props.timeLeadZeroes,
- props.timeTrailZeroes, props.timeModulo
- )
-
- # prefix/sufix
- if props.ifTextFile:
- text.data.body = out
- if props.ifTextFormatting and isNumeric:
- text.data.body = props.prefix + neg + out + props.sufix
- else:
- text.data.body = props.prefix + neg + out + props.sufix
-
-
- at persistent
-def textcounter_text_update_frame(scene):
- for text in scene.objects:
- if text.type == 'FONT' and text.data.text_counter_props.ifAnimated:
- textcounter_update_val(text, scene)
-
-
-# text scrambler #
-
- at persistent
-def textscrambler_update_frame(scene):
- for text in scene.objects:
- if text.type == 'FONT' and text.data.use_text_scrambler:
- uptext(text.data)
-
-
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list