def _draw_wirelesslink(self, url, labels): """ Draw a line with labels representing a WirelessLink. :param url: Hyperlink URL :param labels: Iterable of text labels """ group = Group(class_='connector') # Draw the wireless link start = (OFFSET + self.center, self.cursor) height = PADDING * 2 + LINE_HEIGHT * len(labels) + PADDING * 2 end = (start[0], start[1] + height) line = Line(start=start, end=end, class_='wireless-link') group.add(line) self.cursor += PADDING * 2 # Add link link = Hyperlink(href=f'{self.base_url}{url}', target='_blank') # Add text label(s) for i, label in enumerate(labels): self.cursor += LINE_HEIGHT text_coords = (self.center + PADDING * 2, self.cursor - LINE_HEIGHT / 2) text = Text(label, insert=text_coords, class_='bold' if not i else []) link.add(text) group.add(link) self.cursor += PADDING * 2 return group
def generate_design(): dwg = svgwrite.Drawing('shields/design.svg', size=(u'1014', u'150')) # for D Rect red_point = 798 design_width = 486 width = 1014 height = 150 shapes = dwg.add(dwg.g(id='shapes', fill='none')) a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) shapes.add(dwg.rect((phodal_width, 25.6), (design_width, 30), fill='#2196f3')) shapes.add(dwg.rect((phodal_width, 90), (design_width, 60), fill='#2196f3')) shapes.add(dwg.text('design', insert=(secondary_text_x + 6, 120), fill='#000', stroke_width=4, font_size=120, font_family='Helvetica')) shapes.add(dwg.rect((phodal_width, 0), (design_width, 90), fill='#03a9f4')) # shapes.add(dwg.rect((phodal_width, 88), (486, 3), fill='#e91e63')) shapes.add(dwg.rect((phodal_width, 90), (design_width, 0.2), fill='#000')) shapes.add(dwg.text('design', insert=(secondary_text_x + 4, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) def draw_red_point(): shapes.add(dwg.ellipse((red_point, 40), (9, 9), fill='#000')) shapes.add(dwg.ellipse((red_point + 1, 39), (9, 9), fill='#f44336')) def draw_d_arround(): shapes.add(dwg.line((secondary_text_x, 90), (secondary_text_x, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) shapes.add( dwg.line((secondary_text_x + 70, 90), (secondary_text_x + 70, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) # shapes.add(dwg.line((700, 25), (770, 25), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) shapes.add(dwg.line((secondary_text_x, 130), (secondary_text_x + 70, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) draw_red_point() draw_d_arround() slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add(dwg.text('phodal', insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) dwg.save()
def generate_design(): dwg = svgwrite.Drawing('shields/design.svg', size=(u'1014', u'150')) # for D Rect red_point = 798 design_width = 486 width = 1014 height = 150 shapes = dwg.add(dwg.g(id='shapes', fill='none')) a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) shapes.add(dwg.rect((phodal_width, 25.6), (design_width, 30), fill='#2196f3')) shapes.add(dwg.rect((phodal_width, 90), (design_width, 60), fill='#2196f3')) shapes.add(dwg.text('design', insert=(secondary_text_x + 6, 120), fill='#000', stroke_width=4, font_size=120, font_family='Helvetica')) shapes.add(dwg.rect((phodal_width, 0), (design_width, 90), fill='#03a9f4')) # shapes.add(dwg.rect((phodal_width, 88), (486, 3), fill='#e91e63')) shapes.add(dwg.rect((phodal_width, 90), (design_width, 0.2), fill='#000')) shapes.add(dwg.text('design', insert=(secondary_text_x + 4, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) def draw_red_point(): shapes.add(dwg.ellipse((red_point, 40), (9, 9), fill='#000')) shapes.add(dwg.ellipse((red_point + 1, 39), (9, 9), fill='#f44336')) def draw_d_arround(): shapes.add(dwg.line((secondary_text_x, 90), (secondary_text_x, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) shapes.add( dwg.line((secondary_text_x + 70, 90), (secondary_text_x + 70, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) # shapes.add(dwg.line((700, 25), (770, 25), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) shapes.add(dwg.line((secondary_text_x, 130), (secondary_text_x + 70, 130), stroke='#EEEEEE', stroke_width='1', stroke_opacity=1, stroke_dasharray="2,2")) draw_red_point() draw_d_arround() slogan_link = Hyperlink('https://vikbert.github.io/#/', target='_blank') shapes.add(dwg.text(author, insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text(author, insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) dwg.save()
def draw(self, builder): pos = builder.position(self.pos[0], builder.y + self.pos[1]) size = (builder.image_size, builder.image_size) image = Image("paper.png", pos, size) image.add(Title(self.reference)) obj = Hyperlink(self.link) obj.add(image) return [obj]
def generate_article(): dwg = svgwrite.Drawing('shields/article-small.svg', size=(u'323', u'50')) height = 50 width = 323 rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#ffeb3b')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add(dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) def create_text(): g.add(dwg.text(insert=(phodal_width, 6), fill='#34495e', opacity=0.2, font_size=4, text='Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, fe-')) g.add(dwg.text(insert=(phodal_width, 12), fill='#34495e', opacity=0.2, font_size=4, text='ugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi')) g.add(dwg.text(insert=(phodal_width, 18), fill='#34495e', opacity=0.2, font_size=4, text='vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, ')) g.add(dwg.text(insert=(phodal_width, 24), fill='#34495e', opacity=0.2, font_size=4, text='condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum ')) g.add(dwg.text(insert=(phodal_width, 30), fill='#34495e', opacity=0.2, font_size=4, text='rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus,')) g.add(dwg.text(insert=(phodal_width, 36), fill='#34495e', opacity=0.2, font_size=4, text=' neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,')) g.add(dwg.text(insert=(phodal_width, 42), fill='#34495e', opacity=0.2, font_size=4, text=' tincidunt quis, accumsan porttitor, facilisis luctus, metus')) g.add(dwg.text(insert=(phodal_width, 48), fill='#34495e', opacity=0.2, font_size=4, text='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ')) g.add(dwg.text(insert=(phodal_width, 54), fill='#34495e', opacity=0.2, font_size=4, text='ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus ')) g.add(dwg.text(insert=(phodal_width, 60), fill='#34495e', opacity=0.2, font_size=4, text='turpis elit sit amet quam. Vivamus pretium ornare est.')) create_text() g.add(dwg.text('article', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) g.add(dwg.text('article', insert=(secondary_text_x, basic_text_y), fill='#34495e', font_size=40, font_family='Helvetica')) dwg.save()
def _draw_box(self, width, color, url, labels, y_indent=0, padding_multiplier=1, radius=10): """ Return an SVG Link element containing a Rect and one or more text labels representing a parent object or cable termination point. :param width: Box width :param color: Box fill color :param url: Hyperlink URL :param labels: Iterable of text labels :param y_indent: Vertical indent (for overlapping other boxes) (default: 0) :param padding_multiplier: Add extra vertical padding (default: 1) :param radius: Box corner radius (default: 10) """ self.cursor -= y_indent # Create a hyperlink link = Hyperlink(href=f'{self.base_url}{url}', target='_blank') # Add the box position = (OFFSET + (self.width - width) / 2, self.cursor) height = PADDING * padding_multiplier \ + LINE_HEIGHT * len(labels) \ + PADDING * padding_multiplier box = Rect(position, (width - 2, height), rx=radius, class_='parent-object', style=f'fill: #{color}') link.add(box) self.cursor += PADDING * padding_multiplier # Add text label(s) for i, label in enumerate(labels): self.cursor += LINE_HEIGHT text_coords = (self.center, self.cursor - LINE_HEIGHT / 2) text_color = f'#{foreground_color(color, dark="303030")}' text = Text(label, insert=text_coords, fill=text_color, class_='bold' if not i else []) link.add(text) self.cursor += PADDING * padding_multiplier return link
def generate_book(): dwg = svgwrite.Drawing('shields/book-small.svg', size=(u'323', u'50')) height = 50 width = 308 rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add( dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add( dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2ECC71')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add( dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) def draw_for_bg_plus(): for y in range(0, 50, 5): shapes.add( dwg.line((180, y), (304, y), stroke='#EEEEEE', stroke_width='0.2', stroke_opacity=0.5)) draw_for_bg_plus() shapes.add( dwg.text('book', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.save()
def generate_idea(): y_text_split = phodal_width + 1 height = 150 rect_length = 10 width = 868 max_rect_length = 40 dwg = svgwrite.Drawing('shields/idea.svg', profile='full', size=(u'868', u'150')) a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2196F3')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://vikbert.github.io/#/', target='_blank') shapes.add(dwg.text(author, insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text(author, insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) def draw_for_bg_plus(): for x in range(y_text_split + rect_length, width, rect_length): shapes.add(dwg.line((x, 0), (x, height), stroke='#EEEEEE', stroke_opacity=0.3)) for y in range(rect_length, height, rect_length): shapes.add(dwg.line((y_text_split, y), (width, y), stroke='#EEEEEE', stroke_opacity=0.3)) for x in range(y_text_split + max_rect_length, width, max_rect_length): for y in range(0, height, max_rect_length): shapes.add(dwg.line((x, y - 4), (x, y + 4), stroke='#EEEEEE', stroke_width='2', stroke_opacity=0.4)) for y in range(0, height, max_rect_length): for x in range(y_text_split + max_rect_length, width, max_rect_length): shapes.add(dwg.line((x - 4, y), (x + 4, y), stroke='#EEEEEE', stroke_width='2', stroke_opacity=0.4)) draw_for_bg_plus() shapes.add( dwg.text('idea', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) shapes.add(dwg.text('idea', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.save()
def generate_idea(): y_text_split = phodal_width + 1 height = 150 rect_length = 10 width = 868 max_rect_length = 40 dwg = svgwrite.Drawing('shields/idea.svg', profile='full', size=(u'868', u'150')) a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2196F3')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add(dwg.text('phodal', insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) def draw_for_bg_plus(): for x in range(y_text_split + rect_length, width, rect_length): shapes.add(dwg.line((x, 0), (x, height), stroke='#EEEEEE', stroke_opacity=0.3)) for y in range(rect_length, height, rect_length): shapes.add(dwg.line((y_text_split, y), (width, y), stroke='#EEEEEE', stroke_opacity=0.3)) for x in range(y_text_split + max_rect_length, width, max_rect_length): for y in range(0, height, max_rect_length): shapes.add(dwg.line((x, y - 4), (x, y + 4), stroke='#EEEEEE', stroke_width='2', stroke_opacity=0.4)) for y in range(0, height, max_rect_length): for x in range(y_text_split + max_rect_length, width, max_rect_length): shapes.add(dwg.line((x - 4, y), (x + 4, y), stroke='#EEEEEE', stroke_width='2', stroke_opacity=0.4)) draw_for_bg_plus() shapes.add( dwg.text('idea', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) shapes.add(dwg.text('idea', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.save()
def generate_article(): dwg = svgwrite.Drawing('shields/article.svg', size=(u'970', u'150')) width = 970 height = 150 a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#ffeb3b')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://vikbert.github.io/#/', target='_blank') shapes.add(dwg.text(author, insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text(author, insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) g.add(dwg.text(insert=(phodal_width, 16), fill='#34495e', opacity=0.2, font_size=12, text='Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, fe-')) g.add(dwg.text(insert=(phodal_width, 32), fill='#34495e', opacity=0.2, font_size=12, text='ugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi')) g.add(dwg.text(insert=(phodal_width, 48), fill='#34495e', opacity=0.2, font_size=12, text='vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, ')) g.add(dwg.text(insert=(phodal_width, 64), fill='#34495e', opacity=0.2, font_size=12, text='condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum ')) g.add(dwg.text(insert=(phodal_width, 80), fill='#34495e', opacity=0.2, font_size=12, text='rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus,')) g.add(dwg.text(insert=(phodal_width, 96), fill='#34495e', opacity=0.2, font_size=12, text=' neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi,')) g.add(dwg.text(insert=(phodal_width, 112), fill='#34495e', opacity=0.2, font_size=12, text=' tincidunt quis, accumsan porttitor, facilisis luctus, metus')) g.add(dwg.text(insert=(phodal_width, 128), fill='#34495e', opacity=0.2, font_size=12, text='Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ')) g.add(dwg.text(insert=(phodal_width, 144), fill='#34495e', opacity=0.2, font_size=12, text='ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus ')) g.add(dwg.text(insert=(phodal_width, 160), fill='#34495e', opacity=0.2, font_size=12, text='turpis elit sit amet quam. Vivamus pretium ornare est.')) shapes.add(dwg.text('article', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) shapes.add(dwg.text('article', insert=(secondary_text_x, basic_text_y), fill='#34495e', font_size=120, font_family='Helvetica')) dwg.save()
def decorate_rect_with_class(rect: shapes.Rect, day_date: date, _): """ Decorator for day squares for SVG calendar view Args: rect: day_date: _: Returns: """ day_string = day_date.strftime('%Y-%m-%d') outer = Hyperlink('/byday/' + day_string, '_self') rect.update({'class_': 'dateTrigger'}) rect.update({'id': 'calday-' + day_string}) outer.add(rect) return outer
def generate_design(): # for D Rect red_point = 272 design_width = 162 width = 338 height = 50 dwg = svgwrite.Drawing('shields/design-small.svg', size=(u'338', u'50')) rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((0, 0), (phodal_width, 50), fill='#5E6772')) shapes.add(dwg.rect((phodal_width, 25.6), (design_width, 30), fill='#2196f3')) shapes.add(dwg.text('design', insert=(secondary_text_x + 5, 36), fill='#000', stroke_width=4, font_size=40, font_family='Helvetica')) shapes.add(dwg.rect((phodal_width, 0), (design_width, 26), fill='#03a9f4')) shapes.add(dwg.rect((phodal_width, 25.6), (design_width, 0.6), fill='#000')) shapes.add(dwg.text('design', insert=(secondary_text_x + 4, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) def draw_red_point(): shapes.add(dwg.ellipse((red_point, 8), (3, 3), fill='#000')) shapes.add(dwg.ellipse((red_point + 1, 8), (3, 3), fill='#f44336')) draw_red_point() slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add(dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) dwg.save()
def generate_slogan(): width = 600 height = 50 dwg = svgwrite.Drawing('slogan.svg', profile='full', size=(u'540', u'50')) mask = dwg.mask((0, 0), (540, height), id='a') mask.add(dwg.rect((0, 0), (540, height), fill='#eee', rx=5)) dwg.add(mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (width / 3, height), fill='#03a9f4')) g.add(dwg.rect((width / 3, 0), (width / 3, height), fill='#e91e63')) g.add(dwg.rect((width * 2 / 3, 0), (width * 2 / 3, height), fill='#ecf0f1')) slogan_link = Hyperlink('http://www.xuntayizhan.com/person/ji-ke-ai-qing-zhi-er-shi-dai-wo-dai-ma-bian-cheng-qu-ni-wei-qi-ke-hao-wan/', target='_blank') slogan_link.add(dwg.text('待我代码编成', insert=(10, 35), fill='#fff', font_size=30, font_family='STFangSong')) slogan_link.add(dwg.text('娶你为妻可好', insert=(210, 35), fill='#fff', font_size=30, font_family='STFangSong')) dwg.add(slogan_link) link = Hyperlink('http://www.hug8217.com/', target='_blank') link.add(dwg.text('@花仲马', insert=(410, 35), fill='#34495e', font_size=30, font_family='STFangSong')) dwg.add(link) dwg.save()
def _draw_cable(self, color, url, labels): """ Return an SVG group containing a line element and text labels representing a Cable. :param color: Cable (line) color :param url: Hyperlink URL :param labels: Iterable of text labels """ group = Group(class_='connector') # Draw a "shadow" line to give the cable a border start = (OFFSET + self.center, self.cursor) height = PADDING * 2 + LINE_HEIGHT * len(labels) + PADDING * 2 end = (start[0], start[1] + height) cable_shadow = Line(start=start, end=end, class_='cable-shadow') group.add(cable_shadow) # Draw the cable cable = Line(start=start, end=end, style=f'stroke: #{color}') group.add(cable) self.cursor += PADDING * 2 # Add link link = Hyperlink(href=f'{self.base_url}{url}', target='_blank') # Add text label(s) for i, label in enumerate(labels): self.cursor += LINE_HEIGHT text_coords = (self.center + PADDING * 2, self.cursor - LINE_HEIGHT / 2) text = Text(label, insert=text_coords, class_='bold' if not i else []) link.add(text) group.add(link) self.cursor += PADDING * 2 return group
def generate_works(): dwg = svgwrite.Drawing('shields/works.svg', size=(u'950', u'150')) width = 950 height = 150 a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2c3e50')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((phodal_width, 0), (426, 150), fill='#2c3e50')) for x in range(0, 300, 10): text = get_some_random10(100) g.add( dwg.text(text, insert=(phodal_width + 1, x), fill='#27ae60', font_size=12, font_family='Inconsolata for Powerline', opacity=0.3, transform="rotate(15 1000, 0)")) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) slogan_link = Hyperlink('https://vikbert.github.io/#/', target='_blank') shapes.add(dwg.text(author, insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text(author, insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) shapes.add(dwg.text('works', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#FFFFFF', font_size=120, font_family='Helvetica')) shapes.add(dwg.text('works', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.save()
def generate_works(): dwg = svgwrite.Drawing('shields/works.svg', size=(u'950', u'150')) width = 950 height = 150 a_mask = dwg.mask((0, 0), (width, height), id='a') a_mask.add(dwg.rect((0, 0), (width, height), fill='#eee', rx=15)) dwg.add(a_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2c3e50')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((phodal_width, 0), (426, 150), fill='#2c3e50')) for x in range(0, 300, 10): text = get_some_random10(100) g.add( dwg.text(text, insert=(phodal_width + 1, x), fill='#27ae60', font_size=12, font_family='Inconsolata for Powerline', opacity=0.3, transform="rotate(15 1000, 0)")) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add(dwg.text('phodal', insert=(84, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=120, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(83, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.add(slogan_link) shapes.add(dwg.text('works', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#FFFFFF', font_size=120, font_family='Helvetica')) shapes.add(dwg.text('works', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=120, font_family='Helvetica')) dwg.save()
def get_tree(self, is_admin=True): #print("hey you pony pony") #print(self.first_name) #print(self.id) size_font = 5 #svg_tag = format_html('<svg viewBox="0 0 512 512" class="icon">' '<use xlink:href="#{id}" class="sym"></use>' '</svg>', name=self.first_name, id=self.id) #print(svg_tag) #return mark_safe(svg_tag) dwg = svgwrite.Drawing('test.svg', profile='full', text_anchor='middle') parents = self.get_parents() print(parents.count()) spouses = self.get_spouses() print(spouses.count()) children = self.get_children() print(children.count()) x_individu = 50 y_individu = 60 space_name = 8 space_between_x = 50 space_between_y = space_name + 30 max_width = max(2, 100 + 50 * children.count() + 40 * (spouses.count())) max_heigth = (x_individu + space_name) * 3 dwg.viewbox(width=max_width, height=max_heigth) #dwg.fit(scale='slice') #dwg.stretch() #dwg.scale(2) print(max_width, max_heigth) link = Hyperlink(str(self.id), target='_top') #link = dwg.add(svgwrite.container.Hyperlink('http://stackoverflow.com')) link.add( dwg.text("".join(self.get_first_name(is_admin)), insert=(x_individu, y_individu), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(self.get_last_name(is_admin)), insert=(x_individu, y_individu + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) for parent in parents: #print(parent.parent1) #print(parent.parent2.last_name) link = Hyperlink(str(parent.parent1.id), target='_top') link.add( dwg.text("".join(parent.parent1.get_first_name(is_admin)), insert=(x_individu - (space_between_x / 2), y_individu - space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(parent.parent1.get_last_name(is_admin)), insert=(x_individu - (space_between_x / 2), y_individu - space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font), (x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) #dwg.add(dwg.line((x_individu-20, y_individu-20+size_font), (x_individu, y_individu-size_font), stroke='grey')) link = Hyperlink(str(parent.parent2.id), target='_top') link.add( dwg.text("".join(parent.parent2.get_first_name(is_admin)), insert=(x_individu + (space_between_x / 2), y_individu - space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(parent.parent2.get_last_name(is_admin)), insert=(x_individu + (space_between_x / 2), y_individu - space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font), (x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) dwg.add( dwg.line((x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), (x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) dwg.add( dwg.line((x_individu, y_individu - space_between_y + space_name + size_font + 5), (x_individu, y_individu - size_font), stroke='grey')) #dwg.add(dwg.line((x_individu+20, y_individu-20+size_font), (x_individu, y_individu-size_font), stroke='grey')) #dwg = svgwrite.Drawing('test.svg') nb_child = 0 nb_spouse = 0 for spouse in spouses: if spouse.parent1 != self: real_spouse = spouse.parent1 else: real_spouse = spouse.parent2 if is_admin or not real_spouse.private: nb_spouse += 1 nb_child_for_spouse = 0 x_spouse = x_individu + 50 * nb_spouse + 50 * nb_child y_spouse = y_individu link = Hyperlink(str(real_spouse.id), target='_top') link.add( dwg.text("".join(real_spouse.get_first_name(is_admin)), insert=(x_spouse, y_spouse), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(real_spouse.get_last_name(is_admin)), insert=(x_spouse, y_spouse + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (x_individu, y_individu + space_name + size_font), (x_individu, y_individu + space_name + 2 * nb_spouse + size_font), stroke='grey')) dwg.add( dwg.line( (x_spouse, y_spouse + space_name + size_font), (x_spouse, y_spouse + space_name + 2 * nb_spouse + size_font), stroke='grey')) dwg.add( dwg.line( (x_individu, y_individu + space_name + 2 * nb_spouse + size_font), (x_spouse, y_spouse + space_name + 2 * nb_spouse + size_font), stroke='grey')) for child in children: if child.parent1 == real_spouse or child.parent2 == real_spouse and ( is_admin or not child.child.private): nb_child += 1 link = Hyperlink(str(child.child.id), target='_top') link.add( dwg.text("".join( child.child.get_first_name(is_admin)), insert=(space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join( child.child.get_last_name(is_admin)), insert=(space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - size_font), (space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) if nb_child_for_spouse > 0: dwg.add( dwg.line((space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), (space_between_x * (nb_child - 1) + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) nb_child_for_spouse += 1 if nb_child_for_spouse > 0: dwg.add( dwg.line( ((x_spouse + x_individu) / 2, y_spouse + space_name + 2 * nb_spouse + size_font), (space_between_x * (nb_child - (nb_child_for_spouse - 1) / 2) + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) #dwg.add(dwg.line((x_individu, y_individu+10+size_font), (50*nb_child+40*(nb_spouse-1), y_individu+30-size_font), stroke='blue')) #dwg.add(dwg.line((x_spouse, y_spouse+10+size_font), (50*nb_child+40*(nb_spouse-1), y_individu+30-size_font), stroke='red')) #dwg.add(dwg.line(start=(0, 0), end=(450, 400), stroke='blue')) #print(dwg) #dwg.save() #print(dwg.tostring()) #print(dwg.get_id()) #template = Template(dwg.tostring()) #print(template) #svg_data = generate_some_svg_data() return dwg.tostring()
def get_tree(self, is_admin=True): size_font = 5 dwg = svgwrite.Drawing('test.svg', profile='full', text_anchor='middle') parents = self.get_parents() spouses = self.get_spouses() children = self.get_children() x_individu = 50 y_individu = 60 space_name = 8 space_between_x = 50 space_between_y = space_name + 30 max_width = max(2, 100 + 50 * children.count() + 40 * (spouses.count())) max_heigth = (x_individu + space_name) * 3 dwg.viewbox(width=max_width, height=max_heigth) link = Hyperlink(str(self.id), target='_top') link.add( dwg.text("".join(self.get_first_name(is_admin)), insert=(x_individu, y_individu), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(self.get_last_name(is_admin)), insert=(x_individu, y_individu + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) for parent in parents: if parent.relation.parent1: link = Hyperlink(str(parent.relation.parent1.id), target='_top') link.add( dwg.text("".join( parent.relation.parent1.get_first_name(is_admin)), insert=(x_individu - (space_between_x / 2), y_individu - space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join( parent.relation.parent1.get_last_name(is_admin)), insert=(x_individu - (space_between_x / 2), y_individu - space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line((x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font), (x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) if parent.relation.parent2: link = Hyperlink(str(parent.relation.parent2.id), target='_top') link.add( dwg.text("".join( parent.relation.parent2.get_first_name(is_admin)), insert=(x_individu + (space_between_x / 2), y_individu - space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join( parent.relation.parent2.get_last_name(is_admin)), insert=(x_individu + (space_between_x / 2), y_individu - space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line((x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font), (x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) if parent.relation.parent1 and parent.relation.parent2: dwg.add( dwg.line((x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), (x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), stroke='grey')) dwg.add( dwg.line((x_individu, y_individu - space_between_y + space_name + size_font + 5), (x_individu, y_individu - size_font), stroke='grey')) elif parent.relation.parent1: dwg.add( dwg.line((x_individu - (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), (x_individu, y_individu - size_font), stroke='grey')) elif parent.relation.parent2: dwg.add( dwg.line((x_individu + (space_between_x / 2), y_individu - space_between_y + space_name + size_font + 5), (x_individu, y_individu - size_font), stroke='grey')) nb_child = 0 nb_spouse = 0 for spouse in spouses: if spouse.parent1 != self: real_spouse = spouse.parent1 else: real_spouse = spouse.parent2 if is_admin or real_spouse is None or not real_spouse.private: nb_spouse += 1 nb_child_for_spouse = 0 x_spouse = x_individu + 50 * nb_spouse + 50 * nb_child y_spouse = y_individu if real_spouse: link = Hyperlink(str(real_spouse.id), target='_top') link.add( dwg.text("".join(real_spouse.get_first_name(is_admin)), insert=(x_spouse, y_spouse), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join(real_spouse.get_last_name(is_admin)), insert=(x_spouse, y_spouse + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (x_individu, y_individu + space_name + size_font), (x_individu, y_individu + space_name + 2 * nb_spouse + size_font), stroke='grey')) dwg.add( dwg.line((x_spouse, y_spouse + space_name + size_font), (x_spouse, y_spouse + space_name + 2 * nb_spouse + size_font), stroke='grey')) dwg.add( dwg.line((x_individu, y_individu + space_name + 2 * nb_spouse + size_font), (x_spouse, y_spouse + space_name + 2 * nb_spouse + size_font), stroke='grey')) for child in children: if child.relation.parent1 == real_spouse or child.relation.parent2 == real_spouse and ( is_admin or not child.child.private): nb_child += 1 link = Hyperlink(str(child.child.id), target='_top') link.add( dwg.text("".join( child.child.get_first_name(is_admin)), insert=(space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y), fill='black', text_anchor='middle', font_size=str(size_font - 1) + "px")) link.add( dwg.text("".join( child.child.get_last_name(is_admin)), insert=(space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y + space_name), fill='black', text_anchor='middle', font_size=str(size_font) + "px")) dwg.add(link) dwg.add( dwg.line( (space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - size_font), (space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) if nb_child_for_spouse > 0: dwg.add( dwg.line((space_between_x * nb_child + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), (space_between_x * (nb_child - 1) + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) nb_child_for_spouse += 1 if nb_child_for_spouse > 0: if real_spouse: dwg.add( dwg.line( ((x_spouse + x_individu) / 2, y_spouse + space_name + 2 * nb_spouse + size_font), (space_between_x * (nb_child - (nb_child_for_spouse - 1) / 2) + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) else: dwg.add( dwg.line( (x_individu, y_individu + space_name + 2 * nb_spouse + size_font), (space_between_x * (nb_child - (nb_child_for_spouse - 1) / 2) + space_between_x * (nb_spouse - 1), y_individu + space_between_y - 2 - size_font), stroke='grey')) return dwg.tostring()
def generate_design(): # for D Rect red_point = 272 design_width = 162 width = 338 height = 50 dwg = svgwrite.Drawing('shields/design-small.svg', size=(u'338', u'50')) rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add( dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) g.add(dwg.rect((0, 0), (phodal_width, 50), fill='#5E6772')) shapes.add( dwg.rect((phodal_width, 25.6), (design_width, 30), fill='#2196f3')) shapes.add( dwg.text('design', insert=(secondary_text_x + 5, 36), fill='#000', stroke_width=4, font_size=40, font_family='Helvetica')) shapes.add(dwg.rect((phodal_width, 0), (design_width, 26), fill='#03a9f4')) shapes.add(dwg.rect((phodal_width, 25.6), (design_width, 0.6), fill='#000')) shapes.add( dwg.text('design', insert=(secondary_text_x + 4, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) def draw_red_point(): shapes.add(dwg.ellipse((red_point, 8), (3, 3), fill='#000')) shapes.add(dwg.ellipse((red_point + 1, 8), (3, 3), fill='#f44336')) draw_red_point() slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add( dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) dwg.save()
def generate_works(): width = 316 height = 50 dwg = svgwrite.Drawing('shields/works-small.svg', size=(u'316', u'50')) rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add( dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add( dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2c3e50')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) for x in range(0, 100, 5): text = get_some_random10(100) g.add( dwg.text(text, insert=(phodal_width + 1, x), fill='#27ae60', font_size=4, font_family='Inconsolata for Powerline', opacity=0.3, transform="rotate(15 300, 0)")) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add( dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) shapes.add( dwg.text('works', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) shapes.add( dwg.text('works', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.save()
def generate_idea(): y_text_split = phodal_width + 1 height = 50 rect_length = 2 width = 290 max_rect_length = 10 dwg = svgwrite.Drawing('shields/idea-small.svg', profile='full', size=(u'290', u'50')) rect_with_radius_mask = dwg.mask((0, 0), (width, height), id='a') rect_with_radius_mask.add( dwg.rect((0, 0), (width, height), fill='#eee', rx=3)) dwg.add(rect_with_radius_mask) g = dwg.add(dwg.g(id='g', fill='none', mask='url(#a)')) g.add(dwg.rect((0, 0), (phodal_width, height), fill='#5E6772')) g.add( dwg.rect((phodal_width, 0), (width - phodal_width, height), fill='#2196F3')) shapes = dwg.add(dwg.g(id='shapes', fill='none')) slogan_link = Hyperlink('https://www.phodal.com/', target='_blank') shapes.add( dwg.text('phodal', insert=(28, basic_text_y + 1), fill='#000', fill_opacity=0.3, font_size=40, font_family='Helvetica')) slogan_link.add( dwg.text('phodal', insert=(27, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.add(slogan_link) def draw_for_bg_plus(): for x in range(y_text_split + rect_length, width, rect_length): shapes.add( dwg.line((x, 0), (x, height), stroke='#EEEEEE', stroke_width='0.5', stroke_opacity=0.1)) for y in range(rect_length, height, rect_length): shapes.add( dwg.line((y_text_split, y), (width, y), stroke='#EEEEEE', stroke_width='0.5', stroke_opacity=0.1)) for x in range(y_text_split + max_rect_length, width, max_rect_length): for y in range(0, height, max_rect_length): shapes.add( dwg.line((x, y - 2), (x, y + 2), stroke='#EEEEEE', stroke_width='0.8', stroke_opacity=0.15)) for y in range(0, height, max_rect_length): for x in range(y_text_split + max_rect_length, width, max_rect_length): shapes.add( dwg.line((x - 2, y), (x + 2, y), stroke='#EEEEEE', stroke_width='0.8', stroke_opacity=0.15)) draw_for_bg_plus() shapes.add( dwg.text('idea', insert=(secondary_text_x + 1, basic_text_y + 1), fill='#000', font_size=40, fill_opacity=0.3, font_family='Helvetica')) shapes.add( dwg.text('idea', insert=(secondary_text_x, basic_text_y), fill='#FFFFFF', font_size=40, font_family='Helvetica')) dwg.save()