From: Antonio Ospite Date: Thu, 18 Jun 2015 10:08:53 +0000 (+0200) Subject: Diagram.py: simplify setting bounding box fill and stroke when drawing text X-Git-Url: https://git.ao2.it/experiments/RadialSymmetry.git/commitdiff_plain/5f190f9a0cbdbe7335c5e50a611fe4d9460c1de2?ds=inline Diagram.py: simplify setting bounding box fill and stroke when drawing text --- diff --git a/Diagram.py b/Diagram.py index b6de388..4e14b1c 100755 --- a/Diagram.py +++ b/Diagram.py @@ -202,8 +202,8 @@ class Diagram(object): def draw_centered_text(self, cx, cy, text, theta=0, color=[0, 0, 0], align_baseline=False, - bb_fill=True, bb_fill_color=[1, 1, 1, 0.8], - bb_stroke=False, bb_stroke_color=[0, 0, 0, 0.5]): + bb_fill_color=[1, 1, 1, 0.8], + bb_stroke_color=None): cr = self.cr x_bearing, y_bearing, width, height, x_advance = cr.text_extents(text)[:5] @@ -259,28 +259,28 @@ if __name__ == "__main__": theta = 0 - advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance - advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4, align_baseline=True, bb_stroke=True) + advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5]) x_offset += advance diagram.draw_line(0, y, 400, y, [0, 0, 1, 0.2])