| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/inkscape/extensions/ |
Upload File : |
#!/usr/bin/env python
"""Randomise the case of the letters."""
import random
import inkex
class RandomCase(inkex.TextExtension):
"""Randomise the case of the text (with bias)"""
previous_case = 1
def map_char(self, char):
# bias the randomness towards inversion of the previous case:
# We use this weird way to get from a random set because
# python2 and python3 have different ways of seeding
if self.previous_case > 0:
case = [-2, -1, 1][int(random.random() * 3)]
else:
case = [-1, 1, 2][int(random.random() * 3)]
if char.isalpha():
self.previous_case = case
if case > 0:
return char.upper()
elif case < 0:
return char.lower()
return char
if __name__ == '__main__':
RandomCase().run()