コード例 #1
0
ファイル: paren.py プロジェクト: tybor/Plots
 def draw(self, ctx, cursor, widget_transform):
     super().draw(ctx, cursor, widget_transform)
     if self.stretch:
         with saved(ctx):
             ctx.translate(0, -self.ascent - self.top.ink_rect.y*self.shrink)
             ctx.move_to(0,0)
             ctx.scale(self.shrink,self.shrink)
             self.top.draw(ctx)
         with saved(ctx):
             ctx.translate(0, self.descent)
             ctx.move_to(0,0)
             ctx.scale(self.shrink,self.shrink)
             ctx.translate(0, -self.bot.ink_rect.y - self.bot.ink_rect.height)
             ctx.move_to(0,0)
             self.bot.draw(ctx)
         with saved(ctx):
             scale_factor = max(1, (self.ascent + self.descent)/self.mid.ink_rect.height)
             ctx.translate(0, -self.ascent)
             ctx.scale(1, self.scale_factor)
             ctx.translate(0, -self.mid.ink_rect.y)
             ctx.scale(self.shrink,1)
             ctx.move_to(0, 0)
             self.mid.draw(ctx)
     else:
         with saved(ctx):
             ctx.scale(1, self.scale_factor)
             ctx.translate(0, -self.ascent/self.scale_factor-self.text.ink_rect.y)
             ctx.move_to(0, 0)
             self.text.draw(ctx)
コード例 #2
0
ファイル: radical.py プロジェクト: tybor/Plots
    def draw(self, ctx, cursor, widget_transform):
        super().draw(ctx, cursor, widget_transform)

        if self.index is not None:
            with saved(ctx):
                ctx.translate(
                    0, -self.main_ascent + self.index_y_shift -
                    self.index.descent)
                ctx.scale(self.index_scale, self.index_scale)
                ctx.move_to(0, 0)
                self.index.draw(ctx, cursor, widget_transform)
            ctx.translate(
                self.index.width * self.index_scale - self.index_x_shift, 0)

        symbol_size = self.symbol.ink_rect.height
        scale_factor = max(1, (self.main_ascent + self.descent) / symbol_size)
        with saved(ctx):
            ctx.translate(0, -self.main_ascent)
            ctx.scale(1, scale_factor)
            ctx.translate(0, -self.symbol.ink_rect.y)
            ctx.move_to(0, 0)
            self.symbol.draw(ctx)

        ctx.translate(self.symbol.width, 0)
        ctx.set_source_rgb(0, 0, 0)
        ctx.set_line_width(1)
        ctx.move_to(0, -self.main_ascent + ctx.get_line_width())
        ctx.rel_line_to(self.radicand.width, 0)
        ctx.stroke()
        ctx.move_to(0, 0)
        self.radicand.draw(ctx, cursor, widget_transform)
コード例 #3
0
 def draw(self, ctx, cursor, widget_transform):
     super().draw(ctx, cursor, widget_transform)
     if self.exponent is not None:
         with saved(ctx):
             ctx.translate(0, self.superscript_shift)
             ctx.scale(self.exponent_scale, self.exponent_scale)
             self.exponent.draw(ctx, cursor, widget_transform)
     if self.subscript is not None:
         with saved(ctx):
             ctx.translate(0, self.subscript_shift)
             ctx.scale(self.subscript_scale, self.subscript_scale)
             self.subscript.draw(ctx, cursor, widget_transform)
コード例 #4
0
ファイル: sum.py プロジェクト: tybor/Plots
 def draw(self, ctx, cursor, widget_transform):
     super().draw(ctx, cursor, widget_transform)
     with saved(ctx):
         ctx.translate(self.width / 2 - self.symbol.width / 2, 0)
         self.symbol.draw_at_baseline(ctx)
     with saved(ctx):
         ctx.translate(self.width / 2, -self.symbol.ascent)
         ctx.scale(self.child_scale, self.child_scale)
         ctx.translate(-self.top.width / 2, -self.top.descent)
         self.top.draw(ctx, cursor, widget_transform)
     with saved(ctx):
         ctx.translate(self.width / 2,
                       self.symbol.descent + self.bottom_padding)
         ctx.scale(self.child_scale, self.child_scale)
         ctx.translate(-self.bottom.width / 2, self.bottom.ascent)
         self.bottom.draw(ctx, cursor, widget_transform)
コード例 #5
0
ファイル: abstractwrapped.py プロジェクト: tybor/Plots
 def draw_bar(self, ctx, bar):
     bar_height = bar.ink_rect.height
     scale_factor = max(1, (self.ascent + self.descent) / bar_height)
     with saved(ctx):
         ctx.translate(0, -self.ascent)
         ctx.scale(1, scale_factor)
         ctx.translate(0, -bar.ink_rect.y)
         ctx.move_to(0, 0)
         bar.draw(ctx)
コード例 #6
0
ファイル: frac.py プロジェクト: tybor/Plots
 def draw(self, ctx, cursor, widget_transform):
     super().draw(ctx, cursor, widget_transform)
     with saved(ctx):
         ctx.translate(0, -self.bar_height)
         ctx.move_to(0, 0)
         ctx.set_line_width(1)
         ctx.line_to(self.width, 0)
         ctx.stroke()
         ctx.move_to(0, 0)
         with saved(ctx):
             ctx.translate(
                 self.width // 2 - self.numerator.width // 2,
                 -self.vertical_separation // 2 - self.numerator.descent)
             self.numerator.draw(ctx, cursor, widget_transform)
         with saved(ctx):
             ctx.translate(
                 self.width // 2 - self.denominator.width // 2,
                 self.vertical_separation // 2 + self.denominator.ascent)
             self.denominator.draw(ctx, cursor, widget_transform)
コード例 #7
0
ファイル: elements.py プロジェクト: apandada1/Plots
 def draw(self, ctx, cursor, widget_transform):
     super().draw(ctx, cursor, widget_transform)
     with saved(ctx):
         for i, e in enumerate(self.elements):
             ctx.move_to(0,0)
             if i == cursor.pos:
                 ascent, descent = e.ascent, e.descent
                 if cursor.pos > 0:
                     ascent = max(ascent, self.elements[i-1].ascent)
                     descent = max(descent, self.elements[i-1].descent)
                 self.draw_cursor(ctx, ascent, descent, cursor, widget_transform)
             ctx.move_to(0, 0)
             ctx.translate(e.h_spacing, 0)
             with saved(ctx):
                 e.draw(ctx, cursor, widget_transform)
             ctx.move_to(0,0)
             ctx.translate(e.width + e.h_spacing, 0)
         if cursor.pos == len(self.elements) > 0:
             self.draw_cursor(ctx, self.elements[-1].ascent, self.elements[-1].descent, cursor, widget_transform)
         elif not self.elements:
             self.draw_cursor(ctx, self.ascent, self.descent, cursor, widget_transform)
             ctx.set_source_rgba(0.5, 0.5, 0.5, 0.2)
             ctx.rectangle(0, -self.ascent, self.width, self.ascent + self.descent)
             ctx.fill()