def draw_all(self):
        canvas = self.canvas
        self.cw = canvas.get_width()
        self.ch = canvas.get_height()
        cw = self.cw
        ch = self.ch
        xu = self.xu
        ball = self.ball

        draw.reset2(canvas, xu)
        draw.clear_canvas(canvas, "#fff")

        canvas.fill_style = "#000"
        canvas.fill_rect(0, 0, cw, self.floor_height)

        draw.circle(canvas, ball.radius, ball.pos.x, ball.pos.y)
        canvas.fill_style = "#3683f3"
        canvas.fill()

        #arrow
        if not self.running:
            ball = self.ball
            #velocity vector
            canvas.translate(ball.pos.x, ball.pos.y)
            canvas.rotate(ball.vel.phi())
            draw.arrow(canvas,
                       ball.vel.mag() * self.arrow_scale, 4 * self.linewidth)
            canvas.fill_style = "#49902a"
            canvas.fill()
            draw.reset2(canvas, xu)

        #dashes
        if not self.running:
            draw.paths(canvas, self.paths, self.linewidth, "#000")
예제 #2
0
    def draw_all(self):
        canvas = self.canvas
        xu = self.xu
        canvas.xu  = xu
        ball = self.ball
        draw.reset2(canvas, xu)
        draw.clear_canvas(canvas, "#fff")

        #ball
        drawrad = ball.radius*(1/(1+ball.pos.z/3))
        if 0.01>drawrad or drawrad>10:
            self.running = False
            self.btn_run.text = "Run"
        else:
            draw.circle(canvas, drawrad, ball.pos.x, ball.pos.y)
        canvas.fill_style = "rgb(30, 96, 139)"
        canvas.fill()

        if self.running and self.check_trail.checked:
            b = len(self.trail)
            canvas.begin_path()
            canvas.move_to(self.trail[0].x, self.trail[0].y)
            canvas.quadratic_curve_to(self.trail[int(b/2)].x, self.trail[int(b/2)].y, self.trail[-1].x, self.trail[-1].y)
            canvas.line_width = 0.03
            canvas.stroke()

        #paths
        if not self.running and self.check_paths.checked:
            draw.paths(canvas,self.paths, self.line_width, "#000")

        #arrows
        if not self.running:
            draw.vel_arrows(canvas, self.ball, self.line_width, self.arrow_scale)
            draw.reset2(canvas, xu)

        #field arrows
        canvas.scale(1.0/self.xu, 1.0/self.xu)
        draw.cart_arrows(canvas, self.E, 3, 100/((self.E.mag()+1)), x = 30, y = 50)
        B2 = self.B*10e3
        draw.cart_arrows(canvas, B2, 3, 100/((B2.mag()+1)), x = (self.cw - 80), y = 50)
        canvas.scale(1,-1)
        canvas.font= "20px sans-serif"
        canvas.fill_text("E",50, -30 )
        canvas.fill_text("B",(self.cw - 60), -30 )
        canvas.scale(self.xu, -self.xu)


        #frame
        draw.border(canvas,5, "#000", xu)
    def draw_all(self):
        canvas = self.canvas
        self.cw  = canvas.get_width()
        self.ch = canvas.get_height()
        cw= self.cw
        ch = self.ch
        xu = self.xu
        ball= self.ball

        draw.reset2(canvas, xu)
        draw.clear_canvas(canvas, "#fff")

        canvas.fill_style = "#000"
        canvas.fill_rect(0, 0, cw, self.floor_height)

        draw.circle(canvas, ball.radius, ball.pos.x, ball.pos.y)
        canvas.fill_style= "#3683f3"
        canvas.fill()

        #arrow
        if not self.running:
            ball = self.ball
            #velocity vector
            canvas.translate(ball.pos.x, ball.pos.y)
            if ball.vel.y>0:
                canvas.rotate(ball.vel.phi())
            else:
                canvas.rotate(-ball.vel.phi())
            draw.arrow(canvas, ball.vel.mag()*self.arrow_scale, 4*self.linewidth)
            canvas.fill_style = "#49902a"
            canvas.fill()
            draw.reset2(canvas, xu)

        #dashes
        if not self.running:
            draw.paths(canvas,self.paths, self.linewidth, "#000")
예제 #4
0
    def draw_all(self):
        canvas = self.canvas
        xu = self.xu
        canvas.xu = xu
        ball = self.ball
        draw.reset2(canvas, xu)
        draw.clear_canvas(canvas, "#fff")

        #ball
        drawrad = ball.radius * (1 / (1 + ball.pos.z / 3))
        if 0.01 > drawrad or drawrad > 10:
            self.running = False
            self.btn_run.text = "Run"
        else:
            draw.circle(canvas, drawrad, ball.pos.x, ball.pos.y)
        canvas.fill_style = "rgb(30, 96, 139)"
        canvas.fill()

        if self.running and self.check_trail.checked:
            b = len(self.trail)
            canvas.begin_path()
            canvas.move_to(self.trail[0].x, self.trail[0].y)
            canvas.quadratic_curve_to(self.trail[int(b / 2)].x,
                                      self.trail[int(b / 2)].y,
                                      self.trail[-1].x, self.trail[-1].y)
            canvas.line_width = 0.03
            canvas.stroke()

        #paths
        if not self.running and self.check_paths.checked:
            draw.paths(canvas, self.paths, self.line_width, "#000")

        #arrows
        if not self.running:
            draw.vel_arrows(canvas, self.ball, self.line_width,
                            self.arrow_scale)
            draw.reset2(canvas, xu)

        #field arrows
        canvas.scale(1.0 / self.xu, 1.0 / self.xu)
        draw.cart_arrows(canvas,
                         self.E,
                         3,
                         100 / ((self.E.mag() + 1)),
                         x=30,
                         y=50)
        B2 = self.B * 10e3
        draw.cart_arrows(canvas,
                         B2,
                         3,
                         100 / ((B2.mag() + 1)),
                         x=(self.cw - 80),
                         y=50)
        canvas.scale(1, -1)
        canvas.font = "20px sans-serif"
        canvas.fill_text("E", 50, -30)
        canvas.fill_text("B", (self.cw - 60), -30)
        canvas.scale(self.xu, -self.xu)

        #frame
        draw.border(canvas, 5, "#000", xu)