Example #1
0
	def __init__(self, *args, **kws):
		x = kws.pop('x', 0)
		y = kws.pop('y', 0)
		radius = kws.pop('radius', 0)
		Ellipse.__init__(self, *args, **kws)
		self.x = x
		self.y = y
		self.radius = radius
Example #2
0
    def __get_dbg_origin_gfx(self):
        if self.__dbg_origin is None:
            c1 = Color(1, 0, 0, 0.5)
            r1 = Rectangle()
            c2 = Color(0, 1, 0, 0.5)
            r2 = Rectangle()
            c3 = Color(0, 0, 1, 0.5)
            e = Ellipse()
            group = InstructionGroup()
            for instruction in (c1, r1, c2, r2, c3, e):
                group.add(instruction)

            def update_geom(_, (w, h)):
                r1.size = (w, 0.1 * h)
                r2.size = (0.1 * w, h)
                e.size = (0.5 * w, 0.5 * h)
                e.pos = (0.25 * w, 0.25 * h)

            self.bind(viewport_size=update_geom)
            update_geom(None, self.size)
            self.__dbg_origin = group
 def lay_canvas_instructions(self):
     with self.canvas.after:
         StencilPush()
         Rectangle(pos=self.pos, size=self.size)
         StencilUse()
         self.col_instruction = Color(rgba=self.ripple_color)
         self.ellipse =\
             Ellipse(size=(self.ripple_rad, self.ripple_rad),
                     pos=(self.ripple_pos[0] - self.ripple_rad / 2.,
                          self.ripple_pos[1] - self.ripple_rad / 2.))
         StencilUnUse()
         Rectangle(pos=self.pos, size=self.size)
         StencilPop()
     self.bind(ripple_color=self._set_color,
               ripple_rad=self._set_ellipse)
    def draw_measures(self):
        """
        Draws points representing measures in the main UI
        """

        with self.p_rectangle.canvas:
            scale = self.zoom/self.experiment.dx

            #Measuring screen
            Color(0, 1., 0, 0.25)
            Rectangle(pos = (self.xh + self.wh - self.experiment.mp*self.zoom, self.yh), size = (self.experiment.mw*self.zoom, self.hh))

            Color(0, 1., 0)
            for measure in self.experiment.measurements:
                Ellipse(pos = (self.xh + self.wh - 2*self.experiment.mp*self.zoom + measure[0]*self.zoom , self.yh + measure[1]*self.zoom), size = (self.zoom, self.zoom))
Example #5
0
 def on_touch_down(self, touch, *args):
     super(FloatButton, self).on_touch_down(touch)
     if self.collide_point(touch.x, touch.y):
         if self.shape_down == None:
             self.shape_down = InstructionGroup(grup="shape_down")
         else:
             self.shape.canvas.before.remove(self.shape_down)
             self.shape_down.clear()
         color = Color(0, 0, 0, .4)
         self.shape_down.add(color)
         self.shape_down.add(
             Ellipse(pos=self.shape.pos, size=self.shape.size))
         self.shape.canvas.before.add(self.shape_down)
         Clock.schedule_once(self.remove_shape_down, .05)
         return True
Example #6
0
	def paint_monkey(self, body_part):
		'Paints the parts of the monkey'
		with self.canvas.before:
			if body_part == 1: #head
				Ellipse(pos =(self.positionX / 2, (self.positionY / 2) + 100), size =(50, 50), color = Color(0, 0, 0))
			elif body_part == 2: #body
				Line(points=[self.positionX / 2 + 25, self.positionY / 2, self.positionX / 2 + 25, self.positionY / 2 + 120], width=6)
			elif body_part == 3: #left arm
				Line(points=[self.positionX / 2 - 50, self.positionY / 2 + 50, self.positionX / 2 + 25, self.positionY / 2 + 100], width=6)
			elif body_part == 4: #right arm
				Line(points=[self.positionX / 2 + 100, self.positionY / 2 + 50, self.positionX / 2 + 25, self.positionY / 2 + 100], width=6)
			elif body_part == 5: #left legg
				Line(points=[self.positionX / 2 - 50, self.positionY / 2 - 50, self.positionX / 2 + 25, self.positionY / 2 ], width=6)
			elif body_part == 6: #right legg
				Line(points=[self.positionX / 2 + 100, self.positionY / 2 - 50, self.positionX / 2 + 25, self.positionY / 2 ], width=6)
 def __init__(self, **kwargs):
     super(TimerLables, self).__init__(**kwargs)
     self.img1 = img1 = Image(
         size_hint=(.5, .5), color=(0, 1, 1, 1), mipmap=1
     )  #<-----------------Место для функции смены пассивного цвета кнопки
     self.btn1 = btn1 = Button(background_color=(0, 0, 0, 0))
     self.add_widget(img1, index=-1)
     self.add_widget(self.btn1)
     btn1.bind(on_press=self.ButtonON, on_release=self.ButtonOFF)
     with self.canvas.before:
         Color(
             .1, .1, .1, 1
         )  #<-----------------Место для функции смены цвета бэка тулбара в пасивном состоянии
         self.rect = Ellipse(size=self.size, pos=self.pos)
         self.bind(size=self._update_rect, pos=self._update_rect)
Example #8
0
    def __init__(self, **kwargs):
        super(PointPlotCircEX, self).__init__(**kwargs)

        self.background_normal = ' '
        self.size_hint = None, None
        self.border = [0, 0, 0, 0]
        self.height = 6
        self.width = 6

        self.canvas.clear()
        self.canvas.before.clear()

        with self.canvas.before:
            Color(rgba=self.cor_no)
            Ellipse(size=self.size, pos=self.pos)
Example #9
0
	def update_flakes(self,time):
		for f in self.flakes:
			f[0] += random.choice([-1,1])
			f[1] -= random.randint(0,self.FLAKE_SIZE)
			if f[1] <= 0:
				f[1] = random.randint(0,int(self.height))
			self.canvas.before.clear()
			with self.canvas.before:
				widget_x = self.center_x - self.FLAKE_AREA / 2
				widget_y = self.pos[1]
				for x_flake, y_flake in self.flakes:
					x = widget_x + x_flake
					y = widget_y + y_flake
					Color(0.9, 0.9, 1.0)
					Ellipse(pos=(x,y), size=(self.FLAKE_SIZE, self.FLAKE_SIZE))
Example #10
0
    def draw_o(self):

        origin = self.origin
        stroke_size = 18
        width = self.size[0] - origin
        height = self.size[1] - origin

        pos_temp = [self.center_x - width / 2, self.center_y - height / 2]
        circ = Ellipse(size=[width, height],
                       pos=pos_temp,
                       angle_start=0,
                       angle_end=1)

        width2 = width - stroke_size
        height2 = height - stroke_size
        pos_temp2 = [self.center_x - width2 / 2, self.center_y - height2 / 2]

        inner = InstructionGroup()
        inner.add(Color(0, 210 / 255, 210 / 255))
        inner.add(Ellipse(size=[width2, height2], pos=pos_temp2))
        self.canvas.add(circ)
        self.canvas.add(inner)
        circ_anim = Animation(angle_end=360, d=self.d, t=self.t)
        circ_anim.start(circ)
Example #11
0
    def atualizar(self, *args):
        global rotation
        self.canvas.before.clear()
        self.canvas.clear()
        self.canvas.after.clear()

        with self.canvas.before:
            PushMatrix()
            Rotate(angle=rotation, origin=(self.screen[0]/2, self.screen[1]))

        with self.canvas:
            Color(rgba=(1, 1, 1, 1))
            Ellipse(size=self.tamanho, source=self.imagem, pos=self.Pos)

        with self.canvas.after:
            PopMatrix()
Example #12
0
    def draw(self):
        with self.canvas:
            d = random.randrange(1., 100.)
            #Color(random.randrange(0,2), random.randrange(0,2), random.randrange(0,2))
            Color(0, 1, 0)
            Ellipse(pos=(random.randrange(0, self.width),
                         random.randrange(0, self.height)),
                    size=(d, d))

        def save(self):
            widgetshot(self, filename=juts_gsd() + 'mycharts.png')
            #self.ids.score_all.text = '%d/%d' % (self.succ_count,self.try_count)

        def load(self):
            with self.canvas:
                Image(source='mycharts.png')
Example #13
0
    def __init__(self, path, screen, radius, midpoint, font_size, word, **kwargs):
        super(CircleButton, self).__init__(**kwargs)
        self.texture = Image(source=path, mipmap=True).texture
        self.font_size = font_size
        self.radius = radius
        self.screen = screen
        self.midpoint = midpoint
        self.x = self.midpoint[0]
        self.y = self.midpoint[1]
        self.corner_pos = (self.x - self.radius, self.y - self.radius)
        self.word = word
        self.label = Label(center_x=self.x, center_y=self.y, font_size=self.font_size, text=self.word)

        with self.canvas:
            Ellipse(texture=self.texture, pos=self.corner_pos, size=(self.radius * 2, self.radius * 2))
        self.add_widget(self.label)
Example #14
0
 def on_touch_down(self, touch):
     """log touches"""
     color = (random(), 1., 1.)  # so that colors are bright
     #  only work with this canvas
     with self.canvas:
         # color of the line
         Color(*color, mode='hsv')  # choosing HSV color space, as in, smaller number of colors
         # diameter of circle
         d = 30.
         # an ellipse with equal width and height is a circle
         # -d/2 means the circle will be centered right at the tip of pointer
         Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
         # setting up a line for drawing. canvas knows how to do it coz 'with'
         # we are just storing the reference of it in touch.ud dict using
         # the name 'Line'..
         touch.ud['line'] = Line(points=(touch.x, touch.y))  # passing initial touch point
Example #15
0
    def __init__(self, y, m, **kwargs):
        super(Bob, self).__init__(*kwargs)
        self.m = m
        self.R = np.zeros(2)
        self.V = np.zeros(2)
        self.T = np.zeros(2)
        self.W = np.array([0.0, 9.8 * self.m])
        self.R[0], self.R[1] = (x0 - (Window.width * 0.25)), (y0 -
                                                              (Window.height *
                                                               (1 - y)))

        with self.canvas:
            Color(.234, .456, .678, .8)
            self.circle = Ellipse(pos=(self.R[0], self.R[1]), size=(50, 50))

        Clock.schedule_interval(self.update, 1.0 / (60.0))
Example #16
0
 def animate(self,interval):
     w = self.plotbox.size[0]
     h = self.plotbox.size[1]
     b = min(w,h)
     scalew = b/200.
     scaleh = b/200.
     self.plotbox.canvas.clear()
     self.update_texture()
     with self.plotbox.canvas:
         for p in self.particles: 
             Color(1.0,0.0,0.0)
             Ellipse(pos=(p.trax(self.time)*scalew+w/2.-5.,p.tray(self.time)*scaleh+h/2.-5.),size=(10,10))
     
     self.time += interval*self.speed
     if(self.time >= self.T):
         self.time = 0.
Example #17
0
    def __init__(self, **kwargs):
        self.aBackGroundColor: List[float] = kwargs['background_color']
        Widget.__init__(self,
                        **RemoveNoClassArgs(dInArgs=kwargs, oObject=Widget))
        cOrcaButtonBehaviour.__init__(self, **kwargs)
        # create the graphics
        with self.canvas:
            Color(self.aBackGroundColor[0], self.aBackGroundColor[1],
                  self.aBackGroundColor[2], self.aBackGroundColor[3])
            self.rect_bg = Ellipse(pos=self.pos,
                                   size=self.size,
                                   angle_end=kwargs['angle_end'],
                                   angle_start=kwargs['angle_start'],
                                   source=kwargs['source'])

        self.bind(pos=self.update_graphics_pos, size=self.update_graphics_size)
Example #18
0
def insert_color_ellipse(state, texture_w, texture_h, texture_name, c_r, c_g,
                         c_b):
    """
        TODO
        """
    tile_size = screen.get_tile_size(state)
    texture_w *= tile_size
    texture_h *= tile_size

    texture = Texture.create(size=(texture_w, texture_h), colorfmt='rgba')
    fbo = Fbo(size=(texture_w, texture_h), texture=texture)
    with fbo:
        Color(c_r, c_g, c_b)
        Ellipse(pos=(0, 0), size=(texture_w, texture_h))
    fbo.draw()
    insert(state, texture_name, texture)
Example #19
0
    def on_touch_down(self, touch):
        with self.canvas:

            if touch.x > self.x_bounds:
                self.out_of_bounds = True
            else:
                self.canvas.clear()
                self.out_of_bounds = False

                self.x_initial = touch.x
                self.y_initial = touch.y

                Ellipse(pos=(self.x_initial - self.d / 2,
                             self.y_initial - self.d / 2),
                        size=(self.d, self.d))
                touch.ud['line'] = Line(points=(touch.x, touch.y))
Example #20
0
 def createOther(self, lista, color=None):
     if color == None:
         color = generarColor()
         d = randint(70, 150)
     else:
         color = 1, 1, 1
         d = 50
     shape = RegularShape(color=color)
     shape.pos = self.NewPosicion()
     lista.append(shape)
     self.add_widget(shape)
     cx, cy = shape.center
     shape.size = d, d
     with shape.canvas:
         Color(*color)
         shape.circulo = Ellipse(size=(d, d), pos=shape.pos)
Example #21
0
    def __init__(self, area_size, area_pos, rgb, border=True):
        super(Cursor3D, self).__init__()
        self.area_size = area_size
        self.area_pos = area_pos
        self.xy = np.array((0, 0))

        if border:
            self.add(Color(1, 0, 0))
            self.add(Line(rectangle=area_pos + area_size))

        self.color = Color(*rgb)
        self.add(self.color)

        self.cursor = Ellipse(segments=40)
        self.cursor.size = (30, 30)
        self.add(self.cursor)
Example #22
0
    def on_touch_down(self, touch):
        if self in touch.ud:
            self.anim_complete(self, self)
            self.ripple_pos = ripple_pos = (touch.x, touch.y)
            Animation.cancel_all(self, 'ripple_rad', 'ripple_color')
            rc = self.ripple_color
            ripple_rad = self.ripple_rad
            self.ripple_color = [rc[0], rc[1], rc[2], .16]
            anim = Animation(
                ripple_rad=max(self.width, self.height) * self.ripple_scale,
                t=self.ripple_func_in,
                ripple_color=[rc[0], rc[1], rc[2], self.fade_to_alpha],
                duration=self.ripple_duration_in)
            anim.start(self)
            with self.canvas.after:
                x,y = self.to_window(*self.pos)
                width, height = self.size
                #In python 3 the int cast will be unnecessary
                pos = (int(round(x)), int(round(y)))
                size = (int(round(width)), int(round(height)))

                if _has_scissor_instr:
                    ScissorPush(x=pos[0], y=pos[1],
                                width=size[0], height=size[1])
                else:
                    StencilPush()
                    Rectangle(pos=(int(round(x)), int(round(y))),
                              size=(int(round(width)), int(round(height))))

                    StencilUse()

                self.col_instruction = Color(rgba=self.ripple_color)
                self.ellipse = Ellipse(size=(ripple_rad, ripple_rad),
                                       pos=(ripple_pos[0] - ripple_rad/2.,
                                            ripple_pos[1] - ripple_rad/2.))

                if _has_scissor_instr:
                    ScissorPop()
                else:
                    StencilUnUse()
                    Rectangle(pos=(int(round(x)), int(round(y))),
                              size=(int(round(width)), int(round(height))))
                    StencilPop()

            self.bind(ripple_color=self.set_color, ripple_pos=self.set_ellipse,
                      ripple_rad=self.set_ellipse)
        return super(TouchRippleBehavior, self).on_touch_down(touch)
Example #23
0
    def ripple_show(self, touch):
        '''Begin ripple animation on current widget.

        Expects touch event as argument.
        '''
        self.init_pos = self.to_window(*self.pos)
        print self.init_pos
        Animation.cancel_all(self, 'ripple_rad', 'ripple_color')
        self._ripple_reset_pane()
        x, y = self.to_window(*self.pos)
        width, height = self.size
        if isinstance(self, RelativeLayout):
            self.ripple_pos = ripple_pos = (touch.x - self.pos[0], touch.y - self.pos[1])
        else:
            self.ripple_pos = ripple_pos = (touch.x, touch.y)
        if self.circular_ripple:
            self.ripple_pos = ripple_pos = self.ripple_center if self.ripple_center else self.center
        rc = self.ripple_color
        ripple_rad = self.ripple_rad
        self.ripple_color = [rc[0], rc[1], rc[2], self.ripple_fade_from_alpha]
        with self.ripple_pane:
            if not self.circular_ripple:
                self.sp = ScissorPush(
                    x=round(x),
                    y=round(y),
                    width=round(width),
                    height=round(height)
                )
            self.ripple_col_instruction = Color(rgba=self.ripple_color)
            self.ripple_ellipse = Ellipse(
                size=(ripple_rad, ripple_rad),
                pos=(
                    ripple_pos[0] - ripple_rad / 2.,
                    ripple_pos[1] - ripple_rad / 2.
                )
            )
            if not self.circular_ripple:
                ScissorPop()

        self.ripple_scale = self.circular_ripple if self.circular_ripple else self.ripple_scale
        anim = Animation(
            ripple_rad=max(width, height) * self.ripple_scale,
            t=self.ripple_func_in,
            ripple_color=[rc[0], rc[1], rc[2], self.ripple_fade_to_alpha],
            duration=self.ripple_duration_in
        )
        anim.start(self)
Example #24
0
    def draw_dot(self, cell_center, dims, r, g, b, d):

        self.d = d
        cell_center[0] = cell_center[0] / dims[1]
        cell_center[1] = (1 - cell_center[1] / dims[0])

        self.cell_center = cell_center

        ds = (self.height / self.d)
        xpos = (cell_center[0] * self.width) + self.pos[0] - ds / 2
        ypos = (cell_center[1] * self.height) + self.pos[1] - ds / 2

        with self.canvas:
            Color(r, g, b)
            self.dot = Ellipse(size=(ds, ds), pos=(xpos, ypos))

        self.bind(pos=self.update_im, size=self.update_im)
Example #25
0
    def add_bottles(self, wid):
        _x, _y = self.pos
        _h, _w = self.size

        self.load_image()
        height = ft.height
        width = ft.width
        grid = self.ftc.grid
        bottle_size = min(_h / height, _w / width)

        with wid.canvas:
            for x in range(width):
                for y in range(height):
                    r, g, b = grid[height - (y + 1)][x]
                    Color(r / 255, g / 255, b / 255)
                    Ellipse(pos=(x * bottle_size + _x, y * bottle_size + _y),
                            size=(bottle_size, bottle_size))  # NOQA
Example #26
0
 def on_touch_down(self, touch, *args):
     if self.collide_point(touch.x, touch.y):
         size = ceil(self.height * 0.7), ceil(self.height * 0.7)
         w, h = size
         pos = touch.x - w / 2, touch.y - h / 2
         if self.shape_down == None:
             self.shape_down = InstructionGroup(group="shape_down")
         else:
             self.container.canvas.before.remove(self.shape_down)
             self.shape_down.clear()
         color = Color(0, 0, 0, .4)
         self.shape_down.add(color)
         self.shape_down.add(Ellipse(pos=pos, size=size))
         self.container.canvas.before.add(self.shape_down)
         Clock.schedule_once(self.remove_shape_down, .05)
         super(LabelClicableBase, self).on_touch_down(touch)
         return True
Example #27
0
    def __init__(self, N):
        conf.set_backend('testing')
        self._circle_map = {}
        self.fgame_world = TestWorld(N)
        super().__init__()

        with self.canvas:
            Color(255, 255, 255)
            Rectangle(pos=(0, 0), size=(800, 600))

            for c in self.fgame_world.circles:
                d = 2 * c.radius
                Color(*c.color.rgbf)
                kcircle = Ellipse(pos=c.pos_sw, size=(d, d))
                self._circle_map[c] = kcircle

        Clock.schedule_interval(self.update_world, 1. / 60)
Example #28
0
    def on_touch_down(self, touch) -> bool:

        #self.DrawStandardGestures()
        # start collecting points in touch.ud
        # create a line to display the points

        if not self.collide_point(touch.x, touch.y):
            return False
        touch.grab(self)

        userdata = touch.ud
        with self.canvas:
            Color(1, 1, 0)
            d = 10.
            Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))
            userdata['line'] = Line(points=(touch.x, touch.y))
        return True
 def update_graphics(self, win, create=False):
     global Color, Ellipse
     de = self.ud.get('_drawelement', None)
     if de is None and create:
         if Color is None:
             from kivy.graphics import Color, Ellipse
         with win.canvas.after:
             de = (Color(.8, .2, .2, .7), Ellipse(size=(20, 20),
                                                  segments=15))
         self.ud._drawelement = de
     if de is not None:
         self.push()
         self.scale_for_screen(win.system_size[0],
                               win.system_size[1],
                               rotation=win.rotation)
         de[1].pos = self.x - 10, self.y - 10
         self.pop()
Example #30
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.name = "Player"
        self.origin_x = Window.width / 2
        self.origin_y = Window.height / 2
        self.origin = (self.origin_x, self.origin_y)
        self.obj_size = (20, 20)
        self.obj_pos_x = self.origin[0] - (self.obj_size[0] / 2)
        self.obj_pos_y = self.origin[1] + 100 - (self.obj_size[1] / 2)
        self.obj_pos = (self.obj_pos_x, self.obj_pos_y)

        with self.canvas:
            self.obj = Ellipse(size=self.obj_size,
                               pos=self.obj_pos,
                               source="images/happy.png")
        self.center = (self.obj.pos[0] + self.obj_size[0] / 2,
                       self.obj.pos[1] + self.obj_size[1] / 2)
Example #31
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.ellipse_width = 200
        self.ellipse_height = 200
        self.ellipse_pos_x = (Window.width - self.ellipse_width) / 2
        self.ellipse_pos_y = (Window.height - self.ellipse_height) / 2
        self.ellipse_pos = (self.ellipse_pos_x, self.ellipse_pos_y)
        self.ellipse_size = (self.ellipse_width, self.ellipse_height)
        self.origin_x = self.ellipse_pos_x + self.ellipse_width / 2
        self.origin_y = self.ellipse_pos_y + self.ellipse_height / 2
        self.origin = (self.origin_x, self.origin_y)
        self.angle = 0

        with self.canvas:
            self.earth = Ellipse(source="images/earth.png",
                                 pos=self.ellipse_pos,
                                 size=self.ellipse_size)
    def draw(self):

        #print(self.curPos)

        self.color = (0, 1, 0, 1)

        for each in InputGraph:
            global colorIndex
            with self.canvas:
                Color(rgba=(colours[colorIndex]))
                colorIndex = (colorIndex + 1) % 4
                d = 12
                Ellipse(pos=(each.p.x + self.curPos[0],
                             each.p.y - self.curPos[1]),
                        size=(d, d))

        colorIndex = 0
Example #33
0
 def draw(self, canvas, offset_vector):
     updated_position = Vector(self._position) + offset_vector
     with canvas:
         r = Ellipse(pos=updated_position, size=self._size, texture=self.texture)
         r.tex_coords = [x * 0.2 for x in r.tex_coords]
 def __init__(self, **kwargs):
     Ellipse.__init__(self, **kwargs)
     self.speed = 1