# -*- coding:utf-8 -*- from random import randint def make_shape_fun(text, x, y, boder_size, width, height, font_color, fill_color, font_size, boder_color, chinese_font, english_font, dash, shape_type='rect',rotate_angle=0,behindDoc=0): """ rotate_angle:角度,顺时针30,60,90等 behindDoc为0浮于文字上方,为1浮于文字下方""" if x > 600: x = 600 if y > 800: y = 800 font_size = font_size * 2 boder_size = boder_size * 12700 dash_elem = '' if dash else '' idid = randint(1, 99999) x, y, width, height = x * 10000, y * 10000, width * 10000, height * 10000 if fill_color: filled = f"""""" nofilled = '' else: filled = '' nofilled = """""" if boder_color: boder = f"""""" noboder = f"""{dash_elem}""" else: boder = """""" noboder = """""" if not text: text = f' ' else: text = f'{text}' if shape_type != 'line': insert_text_xml = f""" {text} """ else: insert_text_xml = '' shape_geom_map = { 'rect': '', 'circle': '', 'triangle': '', 'diamond': '', 'pie': '', 'heart': '', 'star': '', 'polygon': '', 'line': '', 'smileyFace': '', 'moon': '', 'cloud': '', 'bevel': '', 'invertedTriangle': '', 'arc': '', } shape_geom = shape_geom_map.get(shape_type, '') r = f""" {x} {y} {shape_geom} {filled} {nofilled} {noboder} {boder} {insert_text_xml} """ return r