Example #1
0
def write_logo(width=450.,
               height=350,
               dpi=100,
               text_size=3.,
               line_width=2.5,
               margin=-0.01):
    """Create the logo for the package.
    """
    body = MusicManAxis()
    offset = Point(-200., 0.)
    width, height, dpi = setup_page((width, height), dpi, text_size,
                                    line_width)
    plt.figure('metalute logo')
    plt.gca().set_aspect('equal')
    hmargin = margin
    vmargin = hmargin * width / height
    plt.subplots_adjust(left=hmargin,
                        right=1. - hmargin,
                        top=1. - vmargin,
                        bottom=vmargin)
    plt.xticks([])
    plt.yticks([])
    w = 0.5 * width * (1. - 2. * hmargin)
    h = 0.5 * height * (1. - 2. * vmargin)
    plt.gca().axis([-w, w, -h, h])
    body.draw(offset)
    kwargs = dict(ha='center', va='center', family='DejaVu Sans Mono')
    plt.text(-75., 40., 'M', **kwargs, size=450)
    plt.text(20., 18., 'eta', **kwargs, size=150, color='orange')
    plt.text(-51., -50., 'L', **kwargs, size=450)
    plt.text(-8., -55., 'ute', **kwargs, size=150, color='orange')
    plt.tight_layout(pad=-1.)
    file_path = os.path.join(METALUTE_DOCS, '_static', 'metalute_logo.png')
    plt.savefig(file_path)
Example #2
0
 def _draw(self, offset, **kwargs):
     """Overloaded method.
     """
     xy = (self.center + offset).xy()
     d = 2. * self.radius
     _arc = matplotlib.patches.Arc(xy, d, d, 0., 0., 360., **kwargs)
     plt.gca().add_patch(_arc)
     return self
Example #3
0
 def draw(self, offset, **kwargs):
     """Draw method.
     """
     x = [point.x + offset.x for point in self.points]
     y = [point.y + offset.y for point in self.points]
     line = matplotlib.lines.Line2D(x, y, **kwargs)
     plt.gca().add_line(line)
     return self
Example #4
0
 def draw(self, offset, **kwargs):
     """Draw method.
     """
     xy = (self.center + offset).xy()
     circle = matplotlib.patches.Circle(xy,
                                        self.radius,
                                        fill=False,
                                        **kwargs)
     plt.gca().add_patch(circle)
     return self
Example #5
0
 def __init__(self, fields):
     """
     """
     lines = []
     for key, value in fields.items():
         lines.append(
             TextArea(key.upper(), textprops={'color': 'lightgray'}))
         lines.append(
             TextArea('    {}                       '.format(value)))
     pack = VPacker(children=lines, pad=0., sep=2.)
     super().__init__(4, child=pack, borderpad=0.)
     plt.gca().add_artist(self)
Example #6
0
 def _draw(self, offset, **kwargs):
     """Draw the circular arc.
     """
     xy = (self.center + offset).xy()
     d = 2. * self.radius
     # Mind that matplotlib is always drawing arcs counterclockwise, so we
     # do have to swap the extremes if the arc measure is negative.
     theta1 = self.start_angle
     theta2 = self.end_angle()
     if self.span_angle < 0.:
         theta1, theta2 = theta2, theta1
     _arc = matplotlib.patches.Arc(xy, d, d, 0., theta1, theta2, **kwargs)
     plt.gca().add_patch(_arc)
     return self
Example #7
0
 def draw(self, offset, **kwargs):
     """Draw the circular arc.
     """
     xy = (self.center + offset).xy()
     d = self.diameter()
     theta1 = self.start_phi
     theta2 = self.end_phi
     # Mind that matplotlib is always drawing arcs counterclockwise, so we
     # do have to swap the extremes if the arc measure is negative.
     if self.span < 0.:
         theta1, theta2 = theta2, theta1
     arc = matplotlib.patches.Arc(xy, d, d, 0., theta1, theta2, **kwargs)
     plt.gca().add_patch(arc)
     return self
Example #8
0
def blueprint(name: str,
              size: str,
              author=None,
              orientation: str = 'Landscape',
              dpi: float = 100.,
              text_size: float = 3.,
              line_width: float = 0.25,
              margin: float = 0.05,
              pitch: float = 50.,
              tick_size: float = 7.5):
    """Create a custom figure for techical drawings.
    """
    assert orientation in PAPER_ORIENTATIONS
    width, height = PAPER_SIZE_DICT[size]
    if orientation == 'Landscape':
        width, height = height, width
    # Setup the page.
    width, height, dpi = setup_page((width, height), dpi, text_size,
                                    line_width)
    # Create an empty figure.
    plt.figure(name)
    # Setup the axes.
    plt.gca().set_aspect('equal')
    hmargin = margin
    vmargin = hmargin * width / height
    plt.subplots_adjust(left=hmargin,
                        right=1. - hmargin,
                        top=1. - vmargin,
                        bottom=vmargin)
    plt.xticks([])
    plt.yticks([])
    w = 0.5 * width * (1. - 2. * hmargin)
    h = 0.5 * height * (1. - 2. * vmargin)
    plt.gca().axis([-w, w, -h, h])
    # Add the reference grid on the borders.
    nx = int(width / pitch + 0.5)
    ny = int(height / pitch + 0.5)
    x = np.linspace(-w, w, nx + 1)
    y = np.linspace(-h, h, ny + 1)
    plt.hlines(y, -w, -w - tick_size, clip_on=False)
    plt.hlines(y, w, w + tick_size, clip_on=False)
    plt.vlines(x, -h, -h - tick_size, clip_on=False)
    plt.vlines(x, h, h + tick_size, clip_on=False)
    # Add the letters and numbers to the reference grid.
    dx = w / nx
    dy = h / ny
    fmt = dict(size='large', ha='center', va='center')
    for i, _x in enumerate(np.flip((x + dx)[:-1])):
        plt.text(_x, -h - tick_size, '{}'.format(i + 1), **fmt)
        plt.text(_x, h + tick_size, '{}'.format(i + 1), rotation=90., **fmt)
    for i, _y in enumerate((y + dy)[:-1]):
        plt.text(-w - tick_size, _y, '{}'.format(ascii_uppercase[i]), **fmt)
        plt.text(w + tick_size,
                 _y,
                 '{}'.format(ascii_uppercase[i]),
                 rotation=90.,
                 **fmt)
    # Add the reference rulers.
    delta = 5.
    span = 0.75
    l = 10 * int((span * w) / 10.)
    hruler(h - delta, -l, l)
    l = 10 * int((span * h) / 10.)
    vruler(-w + delta, -l, l)
    box = BlueprintBox(name, author)