r = corner_ruler(scale=scale, length=100, major_interval=10, minor_per_major=10) translate_inch(r, tool_size - diag_shift, diag_shift) utm_tool.add(r) # Small map ruler scale = 8000 diag_shift = 0.85 r = corner_ruler(scale=scale, length=200, major_interval=50, minor_per_major=5) translate_inch(r, tool_size - diag_shift, diag_shift) utm_tool.add(r) #------------------------------------------------------------------------------- # Repliacte onto printout #------------------------------------------------------------------------------- dwg = Drawing(size=(8.5 * inch, 11 * inch)) defs = Defs() defs.add(utm_tool) dwg.add(defs) for xi in range(3): for yi in range(4): dwg.add(UseInch( utm_tool, (0.5 + xi * 2.5, 0.5 + yi * 2.5), )) write_to_pdf(dwg, "UTM-roamer-ruler-VT.pdf")
def test_add_group(self): defs = Defs(id='defs') group = defs.add(Group(id='group')) # implicit call of add self.assertEqual(defs.tostring(), '<defs id="defs"><g id="group" /></defs>')
y_avg = int(y_sum / len(points)) img_col_ref = img[y_avg][x_avg] hsv = rgb2hsv((img_col_ref[0], img_col_ref[1], img_col_ref[2])) label = int(hsv[2] / (1 / pattern_labels_cnt)) try: return random.sample(colors[using_color][label], 1)[0] except KeyError: return random.sample(colors[using_color][label - 1], 1)[0] else: return random.sample(colors[using_color], 1)[0] if have_gradient: defs = Defs(id='gradients') colors_gradient = [] gradient_direction = [(1, 1), (0, 1), (1, 0)] for gradient_index in range(gradient_cnt): l_g = LinearGradient((0, 0), random.choice(gradient_direction), id='gradient_%d' % gradient_index) l_g.add_colors(random.sample(colors[using_color], 2)) defs.add(l_g) colors_gradient.append('url(#gradient_%d)' % gradient_index) colors[using_color] += colors_gradient dwg.add(defs) # start
def test_add_subelement(self): defs = Defs(id='defs') group = Group(id='group') defs.add(group) self.assertEqual(defs.tostring(), '<defs id="defs"><g id="group" /></defs>')
def test_constructor(self): defs = Defs() self.assertEqual(defs.tostring(), "<defs />")