コード例 #1
0
 def lay_canvas_instructions(self):
     with self.canvas.after:
         StencilPush()
         self.stencil = Ellipse(
             size=(self.width * self.ripple_scale,
                   self.height * self.ripple_scale),
             pos=(self.center_x - (self.width * self.ripple_scale) / 2,
                  self.center_y - (self.height * self.ripple_scale) / 2))
         StencilUse()
         self.col_instruction = Color(rgba=self.ripple_color)
         self.ellipse = Ellipse(size=(self.ripple_rad, self.ripple_rad),
                                pos=(self.center_x - self.ripple_rad / 2.,
                                     self.center_y - self.ripple_rad / 2.))
         StencilUnUse()
         Ellipse(pos=self.pos, size=self.size)
         StencilPop()
         self.bind(ripple_color=self._set_color,
                   ripple_rad=self._set_ellipse)
コード例 #2
0
ファイル: kivy_shapes.py プロジェクト: OrpingtonClose/daily
 def on_touch_down(self, touch):
   with self.canvas:
     Color(random(), random(), random())
     d = 30
     x = touch.x - d / 2
     y = touch.y - d / 2
     Ellipse(pos=(x, y), size=(d, d))
     for n in range(90):
       touch.ud['line{}'.format(n)] = Line(points=self._proc(touch, n))
コード例 #3
0
    def __init__(self, **kwargs):
        super(PainterWidget, self).__init__(**kwargs)

        with self.canvas:
            Color(0, 1, 0, 1)
            Ellipse(pos=(100, 300), size=(50, 50))
            Rectangle(pos=(300, 150), size=(50, 50))
            Line(points=(100, 100, 150, 200, 200, 100), close=True, width=5)
            self.line = Line(points=(), width=5, joint='miter', cap='square')
コード例 #4
0
    def set_player(self, player):
        self.player = player

        self.player_color = player.color
        self.player_circle = Ellipse(size=(50, 50), pos=self.pixel_pos)

        self.add(self.player_color)
        self.add(self.player_circle)
        self.change += 2  # total 2 passive increase
コード例 #5
0
 def on_touch_down(self, touch):
     if not self.disabled:
         with self.canvas:
             Color(*self.colorLinea, mode='rgb')
             d = self.grosorLinea
             w = self.grosorLinea*0.5
             Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
             touch.ud['line'] = Line(
                 points=(touch.x, touch.y), size=(d, d), width=w)
コード例 #6
0
 def on_touch_down(self, touch):
     with self.canvas:
         color = (random(), 1, 1)
         with self.canvas:
             Color(*color, mode='hsv')
             d = 1.
             Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
             touch.ud['line'] = Line(points=(touch.x, touch.y))
     print(touch)
コード例 #7
0
 def on_touch_down(self, touch):
     # start collecting points in touch.ud create a line to display the points
     userdata = touch.ud
     with self.canvas:
         Color(1, 1, 0)
         d = 30.
         Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
         userdata['line'] = Line(points=(touch.x, touch.y))
     return True
コード例 #8
0
    def __init__(self, lcolor, **kwargs):
        super().__init__(**kwargs)
        self.padding = '10dp'

        with self.canvas.before:
            Color(*lcolor)  
            self.rect = Ellipse(size=self.size, pos=self.pos)

        self.bind(size=self._update_rect, pos=self._update_rect)
コード例 #9
0
    def draw_button(self, *args):
        self.canvas.before.clear()
        with self.canvas.before:
            # trocar cor não funcionou
            Color(rgba=((get_color_from_hex('2BD62B') if self.state ==
                         'normal' else get_color_from_hex('219321'))))
            Ellipse(size=(self.height, self.height), pos=self.pos)
            Ellipse(size=(self.height, self.height),
                    pos=(self.x + self.width - self.height, self.y))
            Rectangle(size=(self.width - self.height, self.height),
                      pos=(self.x + self.height / 2.0, self.y))

            if self.image_state:
                Color(rgba=get_color_from_hex(self.image_color))
                Rectangle(pos=(self.x + self.height / 4,
                               self.y + self.height * 0.3),
                          size=(self.height * 0.4, self.height * 0.4),
                          source=self._scr_image)
コード例 #10
0
    def _make_chart(self,items):
        self.size= (min(self.size) , min(self.size))
        if not items:
            raise Exception('Items cannot be empty.') 

        items= self._format_items(items)
        angle_start=0
        color_item= 0
        i= 1
        circle_center= [self.pos[0]+self.size[0]/2, self.pos[1]+self.size[1]/2]

        for title,value in items.items():
            with self.canvas.before:

                if self.starting_animation:
                    alpha= 0
                else:
                    alpha=1

                if self.color_mode=='colors':
                    color= get_color_from_hex(colors[palette[color_item]]['500']) 

                c= Color(rgb= color, a=alpha)
                if self.starting_animation:
                    e= Ellipse(pos=self.pos , size=self.size ,angle_start=angle_start, angle_end=angle_start+0.01)                    
                    
                    anim= Animation(size=self.size, angle_end=angle_start+value, duration=self.duration, t=self.transition)
                    anim_opcity= Animation(a=1, duration=self.duration*0.5)

                    anim_opcity.start(c)
                    anim.start(e)
                else: 
                    Ellipse(pos=self.pos , size=self.size ,angle_start=angle_start, angle_end=angle_start+value)
            color_item+=1
            angle_start+= value
                
        angle_start=0
        for title,value in items.items():
            with self.canvas.after:
                label_pos= point_on_circle( (angle_start+angle_start+value)/2 , circle_center, self.size[0]/3 )
                l= PieChartNumberLabel( x=label_pos[0], y= label_pos[1] , title=title)
                anim_label= Animation(percent=value*100/360)
                anim_label.start(l)
            angle_start+= value
コード例 #11
0
    def __init__(self, **kw):
        self._trigger_genitems = Clock.create_trigger(self._genitems, -1)
        self.bind(min=self._trigger_genitems,
                  max=self._trigger_genitems,
                  multiples_of=self._trigger_genitems)
        super(CircularNumberPicker, self).__init__(**kw)
        self.selected = self.min
        self.bind(selected=self.on_selected,
                  pos=self.on_selected,
                  size=self.on_selected)

        cx = self.center_x + self.padding[0] - self.padding[2]
        cy = self.center_y + self.padding[3] - self.padding[1]
        sx, sy = self.pos_for_number(self.selected)
        epos = [
            i - (self.delta_radii * self.number_size_factor) for i in (sx, sy)
        ]
        esize = [self.delta_radii * self.number_size_factor * 2] * 2
        dsize = [i * .3 for i in esize]
        dpos = [i + esize[0] / 2. - dsize[0] / 2. for i in epos]
        csize = [i * .05 for i in esize]
        cpos = [i - csize[0] / 2. for i in (cx, cy)]
        dot_alpha = 0 if self.selected % self.multiples_of == 0 else 1
        color = list(self.selector_color)

        with self.canvas:
            self._selection_color = Color(*(color + [self.selector_alpha]))
            self._selection_circle = Ellipse(pos=epos, size=esize)
            self._selection_line = Line(points=[cx, cy, sx, sy],
                                        width=dp(1.25))
            self._selection_dot_color = Color(*(color + [dot_alpha]))
            self._selection_dot = Ellipse(pos=dpos, size=dsize)
            self._center_color = Color(*self.color)
            self._center_dot = Ellipse(pos=cpos, size=csize)

        self.bind(selector_color=lambda ign, u: setattr(
            self._selection_color, "rgba", u + [self.selector_alpha]))
        self.bind(selector_color=lambda ign, u: setattr(
            self._selection_dot_color, "rgb", u))
        self.bind(selector_color=lambda ign, u: self.dot_is_none())
        self.bind(color=lambda ign, u: setattr(self._center_color, "rgb", u))
        Clock.schedule_once(self._genitems)
        Clock.schedule_once(
            self.on_selected)  # Just to make sure pos/size are set
コード例 #12
0
ファイル: main.py プロジェクト: soukainaamraoui/TA1-Coloriage
 def on_touch_down(self, touch):
     if touch.x < 100 + d:  #Permert de ne pas colorier en dehors de la zone de dessin
         pass
     else:
         with self.canvas:
             (a, b, c) = color_choice
             Color(a, b, c)
             Ellipse(pos=(touch.x - int(d / 2), touch.y - int(d / 2)),
                     size=(d, d))
             touch.ud['line'] = Line(points=(touch.x, touch.y), width=d)
コード例 #13
0
    def _draw_circle(self, d, part):
        from kivy.graphics import Ellipse

        pos = (self.pos[0] + self.size[0] / 2 - d / 2,
               self.pos[1] + self.size[1] / 2 - d / 2)
        Ellipse(size=(d, d),
                pos=pos,
                angle_start=0,
                angle_end=part * 360,
                segments=45)
コード例 #14
0
 def on_touch_down(self, touch):
     Window.set_system_cursor('crosshair')
     with self.canvas:
         Ellipse(
             pos=(touch.pos[0] - self.shape_size[0] / 2,
                  touch.pos[1] - self.shape_size[1] / 2),
             size=self.shape_size) if self.shape == 'cir' else Rectangle(
                 pos=(touch.pos[0] - self.shape_size[0] / 2,
                      touch.pos[1] - self.shape_size[1] / 2),
                 size=self.shape_size)
コード例 #15
0
 def ModifyAngle(self, **kwargs):
     with self.canvas:
         self.canvas.clear()
         Color(self.tBackGroundColor[0], self.tBackGroundColor[1],
               self.tBackGroundColor[2], self.tBackGroundColor[3])
         self.rect_bg = Ellipse(pos=self.pos,
                                size=self.size,
                                angle_end=kwargs['angle_end'],
                                angle_start=kwargs['angle_start'],
                                source=kwargs['source'])
コード例 #16
0
 def __init__(self, x, y, r, src):
     self._x = x
     self._y = y
     #kivy takes size as (major,minor)
     self._r = r
     self._size = (r * 2, r * 2)
     self._source = src
     self._instruction = Ellipse(pos=(self._x, self._y),
                                 size=self._size,
                                 source=self._source)
コード例 #17
0
ファイル: main.py プロジェクト: cdimoush/brainArt-protoGUI
class Pen(Widget):
    pos = 10, 10
    cursor = Ellipse()
    s = 10

    def __init__(self, **kwargs):
        super(Pen, self).__init__(**kwargs)
        with self.canvas.before:
            Color(1, 0, 0)
            self.cursor = Ellipse(pos=self.pos, size=(self.s, self.s))
コード例 #18
0
 def visual_aps(self):
     with self.canvas:
         Color(1, 0, 0)
         d = 20.0
         for ssid in self.ssids:
             x, y = self.config_dict[ssid]
             print(x * Window.size[0])
             print(y * Window.size[1])
             Ellipse(pos=(x * Window.size[0], y * Window.size[1]),
                     size=(d, d))
コード例 #19
0
 def ButtonON(self, touch):
     self.img1.color = (
         0, 0, 0, 1
     )  #<-----------------Место для функции смены активного цвета кнопки
     with self.canvas.before:
         Color(
             0, 1, 1, 1
         )  #<-----------------Место для функции смены цвета бэка тулбара в активном состоянии
         self.rect = Ellipse(size=self.size, pos=self.pos)
         self.bind(size=self._update_rect, pos=self._update_rect)
コード例 #20
0
 def on_mouse_pos(self, *args):
     self.canvas.clear()
     if self.collide_point(*args[1]):
         with self.canvas:
             Color(1, 0.1, 0.1, mode='rgb')
             self.ellipse = Ellipse(width=dp(2))
         self.redraw()
     else:
         self.draw()
         self.redraw()
コード例 #21
0
ファイル: writing.py プロジェクト: SpudBoi/wheat
 def on_touch_down(self, touch):
     if self.collide_point(touch.x, touch.y):
         with self.canvas:
             Color(0, 0, 0)
             lineWidth = 2.5
             Ellipse(pos=(touch.x - lineWidth, touch.y - lineWidth),
                     size=(2 * lineWidth, 2 * lineWidth))
             touch.ud['line'] = Line(points=(touch.x, touch.y),
                                     width=lineWidth)
             print(touch.ud['line'].points)
コード例 #22
0
    def on_touch_down(self, touch):
        colorR = random.randint(0, 255)
        colorG = random.randint(0, 255)
        colorB = random.randint(0, 255)

        self.canvas.add(Color(rgb=(colorR / 255.0, colorG / 255.0, colorB / 255.0)))
        d = 14
        self.canvas.add(Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d)))
        touch.ud['line'] = Line(Points=(touch.x, touch.y))
        self.canvas.add(touch.ud['line'])
コード例 #23
0
 def segment(self,pos,size,color,first=False,last=False):
     with self.canvas:
         Color(*color)
         Ellipse(pos=pos,size=size)
         if not(first):
             Rectangle(pos=pos,size=(size[0]/2,size[1]))
         if not(last):
             Rectangle(pos=(pos[0]+size[0]/2,pos[1]),size=(size[0]/2,size[1]))
             Color(0,0,0,0.2)
             Line(points=[pos[0]+size[0],pos[1],pos[0]+size[0],pos[1]+size[1]])
コード例 #24
0
 def draw_rect(self, token_color, icon):
     canvas_color = [x / 255 for x in token_color] + [.99]
     if not icon:
         icon = 'default_icon.png'
     with self.canvas.before:
         Color(*canvas_color)
         # rgba: tuple([x / 255 for x in self.color] + [.99])
         self.rect = Ellipse(pos=self.pos, size=self.size, source=icon)
     self.bind(pos=self.update_rect)
     self.bind(size=self.update_rect)
コード例 #25
0
 def clear_obstacles(self, obj):
     global dest
     self.painter.canvas.clear()
     with self.painter.canvas:
         Color(1, 0, 0)
         d = 10.
         if (not type(dest) is str):
             Ellipse(pos=((dest[0] / px_to_m - d / 2),
                          cam_pose[1] + dest[1] / px_to_m - d / 2),
                     size=(d, d))
コード例 #26
0
ファイル: main.py プロジェクト: koreafuture/QuickDraw
 def on_touch_down(self, touch):
     with self.canvas:
         # 캔버스에 그릴 색과 획의 두께를 결정합니다.
         Color(0, 0, 0); d = 16
         # 마우스 클릭 한 번으로 점을 찍으며 <Ellipse object>. 이를 drawing 변수에 추가합니다.
         self.drawing.append(Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d)))
         # 마우스 클릭을 하고 움직일 때 <Line object> 좌표 정보를 drawing 변수에 추가합니다.
         # 즉, 한 번의 마우스 클릭은 <Ellipse object>와 <Line object>의 좌표 정보를 동시에 저장합니다.
         self.ud = Line(points=(touch.x, touch.y), width=8)
         self.drawing.append(self.ud)
コード例 #27
0
 def render(self, dt):
   with self.canvas:
     self.sim.step()
     self.canvas.clear()    
     Color(.5, .5, .5)
     x = (self.sim.center_axis[0] * PIXELS_PER_INCH)+400-4
     y = (self.sim.center_axis[1] * PIXELS_PER_INCH)+300-4
     Ellipse(pos=(x,y), size=(9, 9))
  
     Color(1, 1, 0)
     for p in self.sim.tool_history:
       x = ((p[0]*1) * PIXELS_PER_INCH)+400-1
       y = ((p[1]*1) * PIXELS_PER_INCH)+300-1
       Ellipse(pos=(x,y), size=(3, 3))
       
     Color(1,0,0)
     x = (self.sim.tool_position[0] * PIXELS_PER_INCH)+400-2
     y = (self.sim.tool_position[1] * PIXELS_PER_INCH)+300-2
     Ellipse(pos=(x,y), size=(5, 5))
コード例 #28
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.id = random.randint(1, 100)
     self.eggs_list = []
     self.set_of_ants = set()
     self.gene = 0
     self.waypoint = self.generate_waypoint()
     self.position = self.generate_waypoint()
     self.life_span = 10
     self.red = self.generate_random() / 10
     self.blue = self.generate_random() / 10
     self.green = self.generate_random() / 10
     Color(self.red, self.blue, self.green)
     self.queen = Ellipse(size=(30, 30),
                          pos=(self.position[0], self.position[1]))
     Color(self.red, self.blue, self.green)
     self.marker = Ellipse(size=(1, 1),
                           pos=(self.queen.pos[0], self.queen.pos[1]))
     self.collision = False
コード例 #29
0
 def on_touch_down(self, touch):
     #print(touch)
     color = (random(), random(), random())
     with self.canvas:
         Color(*color)
         parameter = 100  #size of your circles
         Ellipse(pos=(touch.x - parameter / 2, touch.y - parameter / 2),
                 size=(parameter, parameter))
         #Import Line for it to function properly
         touch.ud['Line'] = Line(points=(touch.x, touch.y))
コード例 #30
0
ファイル: edushapes.py プロジェクト: samhattangady/educorder
 def draw_shape(self):
     # Draws ellipse based on line and fill colours
     if self.fill:
         Color(1, 0, 0)
         Ellipse(pos=(self.x, self.y), size=(self.width, self.height))
     if self.line:
         Color(0, 0, 0)
         Line(ellipse=(self.x, self.y, self.width, self.height))
     if self.selected:
         self.reshape_circles.reshape_draw()