当前位置: 首页>>代码示例>>Python>>正文


Python ui.Path方法代码示例

本文整理汇总了Python中ui.Path方法的典型用法代码示例。如果您正苦于以下问题:Python ui.Path方法的具体用法?Python ui.Path怎么用?Python ui.Path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ui的用法示例。


在下文中一共展示了ui.Path方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: touch_moved

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def touch_moved(self, data):
    if self.dragging_waypoint:
      self.w.center = data.location
      return
    if self.flood_filling:
      if Vector(data.location).distance_to(self.touch_start) < 10:
        return
      else:
        self.flood_fill(self.control.edit_menu['flood_fill'])
    (w, h) = self.img.size
    with ui.ImageContext(w,h) as ctx:
      self.img.draw()
      blend_mode = ui.BLEND_CLEAR if self.digging else ui.BLEND_NORMAL
      ui.set_blend_mode(blend_mode)
      ui.set_color('black')
      (x, y) = data.location #* self.multiplier
      (px, py) = data.prev_location #* self.multiplier
      path = ui.Path()
      path.move_to(px, py)
      path.line_to(x, y)
      path.line_width = 30 #* self.multiplier #if self.digging else 1
      path.line_cap_style = ui.LINE_CAP_ROUND
      path.stroke()
      self.img = ctx.get_image()
    #self.set_needs_display() 
开发者ID:mikaelho,项目名称:caves,代码行数:27,代码来源:caves.py

示例2: load_actual

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def load_actual(self, burn_waypoints_in=False):
    # Clear old waypoints
    for wp in self.edit_view.waypoints:
      self.edit_view.remove_subview(wp)
    self.edit_view.waypoints = []
    
    # Load image
    img_filename = self.filename
    iv = ui.ImageView(frame=self.bg.bounds)
    iv.image = ui.Image(img_filename)
    self.edit_view.img = snapshot(iv)
    self.multiplier = self.edit_view.img.size[1]/self.edit_view.height

    # Load settings
    json_filename = img_filename[:-3]+'json'
    if os.path.exists(json_filename):
      with open(json_filename) as fp:
        settings = json.load(fp)
      if isinstance(settings, dict):
        locations = settings['waypoint_locations']
        self.bg.image = ui.Image.named(settings['bg_filename'])
        self.edit_view.bg_filename = settings['bg_filename']
      else:
        locations = settings
        self.bg.image = ui.Image.named('backgrounds/caves.jpg')
        self.edit_view.bg_filename = None
      for loc in locations:
        wp = self.edit_view.add_waypoint()
        wp.center = loc
        
    if burn_waypoints_in:
      with ui.ImageContext(self.edit_view.width, self.edit_view.height) as ctx:
        self.edit_view.img.draw()
        ui.set_blend_mode(ui.BLEND_CLEAR)
        ui.set_color('black')
        for wp in self.edit_view.waypoints:
          (x,y) = wp.center
          path = ui.Path.oval(x-15, y-15, 30, 30)
          path.fill()
        self.edit_view.img = ctx.get_image() 
开发者ID:mikaelho,项目名称:caves,代码行数:42,代码来源:caves.py

示例3: draw

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def draw(self):
    if self.tracking:
      ui.set_color('black')
      ui.fill_rect(0, 0, self.width, self.height)
    else:
      base_color = tuple([self.color[i] for i in range(3)])
      opacity_increment = 1.0/(len(self.current_move)+1) # 0.002
      alpha_incremental = 1.0 - self.animate_counter*opacity_increment
      if self.animate_counter > 0:
        for i in range(1, self.animate_counter):
          alpha_actual = max(0, alpha_incremental)
          self.draw_segment(base_color + (alpha_actual,), self.current_move[i-1], self.current_move[i])
          alpha_incremental += opacity_increment
          if len(self.waypoints_hit_this_turn) > 0:
            (hit_distance, waypoint_index) = self.waypoints_hit_this_turn[0]
            if self.animate_counter >= hit_distance:
              sound.play_effect('digital:PowerUp1')
              self.waypoints[waypoint_index].background_color = '#6cd655'
              self.waypoints_hit_this_turn = self.waypoints_hit_this_turn[1:]
      if self.animation_state == 'sploding':
        splode_alpha = 1.0-self.splosion_counter*0.15
        splode_radius = self.splosion_counter * 4
        splode_color = base_color + (splode_alpha,)
        (x,y) = self.current_move[-1]
        path = ui.Path.oval(x-splode_radius,y-splode_radius,2*splode_radius,2*splode_radius)
        ui.set_color(splode_color)
        path.fill()
#        pos1 = self.current_move[self.animate_counter - 2]
#        pos2 = self.current_move[self.animate_counter - 1]
#        angle = (Vector(pos2) - Vector(pos1)).degrees
        #print(self.animate_counter, angle) 
开发者ID:mikaelho,项目名称:caves,代码行数:33,代码来源:caves.py

示例4: new_path

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def new_path(self, path_color, line_width=3):
    ui.set_color(path_color)
    path = ui.Path()
    path.line_width = line_width
    path.line_cap_style = ui.LINE_CAP_ROUND
    return path 
开发者ID:mikaelho,项目名称:caves,代码行数:8,代码来源:caves.py

示例5: get_polygon_path

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def get_polygon_path(points):
    """ Get a ui.Path object that connects a list of points with straight lines
    to form a closed figure """
    p = ui.Path()
    # Move to first point
    p.move_to(*points[0])
    # Begin path, drawing line to the rest
    for point in points[1:]:
        p.line_to(*point)
    # close the shape
    p.close()

    return p 
开发者ID:controversial,项目名称:ui2,代码行数:15,代码来源:shapes.py

示例6: get_regular_polygon_path

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def get_regular_polygon_path(*args, **kwargs):
    """ Get a ui.Path for a regular polygon. See 'get_regular_polygon_points'
    for description of arguments """
    return get_polygon_path(get_regular_polygon_points(*args, **kwargs)) 
开发者ID:controversial,项目名称:ui2,代码行数:6,代码来源:shapes.py

示例7: __init__

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def __init__(self):
        self.p = ui.Path()

        # Stores all arcs, curves, and lines in the path. They are stored as
        # [start_point, function_args, end_point]
        self.components = []
        # Keeps track of the current position internally. Only updated manually
        # and is therefore used to track old values
        self._position = (0, 0)

        # Copy docstring
        self.__doc__ == ui.Path.__doc__

    # Wrapper methods 
开发者ID:controversial,项目名称:ui2,代码行数:16,代码来源:NewPath.py

示例8: copy_path

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def copy_path(path):
    """ Make a copy of a ui.Path and return it. Preserves all data. """
    new = ui.Path()
    new.append_path(path)
    # Copy over the attributes
    new.line_cap_style = path.line_cap_style
    new.line_join_style = path.line_join_style
    new.line_width = path.line_width

    return new 
开发者ID:controversial,项目名称:ui2,代码行数:12,代码来源:path_helpers.py

示例9: demo_ProgressPathView

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def demo_ProgressPathView():
    import math
    import random

    p = ui.Path()
    p.move_to(20, 20)
    p.line_to(480, 20)
    p.line_to(480, 250)
    p.add_arc(250, 250, 230, 0, math.radians(110))
    p.add_curve(50, 450, 20, 250, 480, 250)
    p.close()  # This makes the end look nicer

    ppv = ui2.ProgressPathView(p)

    view = ui.View(background_color="white")
    view.add_subview(ppv)
    view.width = view.height = ppv.width = ppv.height = 500
    view.present("sheet", hide_title_bar=True)

    def advance():
        """Advance by a random amount and repeat."""
        pg = ppv.progress + random.random() / 20
        if pg < 1:
            ppv.progress = pg
            ui.delay(advance, random.random() / 2)
        else:
            ppv.progress = 1

    advance() 
开发者ID:controversial,项目名称:ui2,代码行数:31,代码来源:demo.py

示例10: draw

# 需要导入模块: import ui [as 别名]
# 或者: from ui import Path [as 别名]
def draw(self):
        # redraw button
        def darken(color):
            return tuple([0.5*x for x in color])

        
        #set up button size to fit.
        padding=10
        textsize=ui.measure_string(string=self.title,max_width=0,font=self.font,alignment=ui.ALIGN_CENTER)

        #draw border
        ui.set_color(self.border_color)
        path = ui.Path.rounded_rect(0, 0, self.width, self.height,self.corner_radius)
        path.line_width=self.border_width
        path.stroke()
        
        #fill button, depending on touch state
        if self.touched:
            if self.doing_longtouch:
                ui.set_color('blue')
            else:
                ui.set_color('grey')
        else :
            ui.set_color(self.bg_color)
        path.fill()
        
        # fill corner darker, if has children
        if self.flow.subviews:
            corner = ui.Path()
            corner.move_to(self.width-1.5*self.corner_radius,0)
            corner.line_to(self.width,0)
            corner.line_to(self.width,1.5*self.corner_radius)
            corner.line_to(self.width-1.5*self.corner_radius,0)
            ui.set_color(darken(darken(self.bg_color)))
            corner.stroke()
            corner.fill()

        # draw title, center vertically, horiz
        rect=list(self.bounds)
        rect[1]=(rect[3]-textsize[1])/2 #vert center
        rect[2]=max(rect[2],textsize[0]+10)
        ui.draw_string(self.title, rect=tuple(rect), font=self.font, color=self.tint_color, alignment=ui.ALIGN_CENTER, line_break_mode=ui.LB_WORD_WRAP)
        
        if textsize[0]>self.bounds[2]:
            self.width=textsize[0]+10 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:47,代码来源:PopupButton.py


注:本文中的ui.Path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。