def __init__(self, position, color=Color.cyan()): """ :type position: Vector :type color: Color """ self.position = position self.color = color
def draw_point(self, point, color=Color.cyan()): """ :type point: Vector :type color: Color :return: None """ if 0 <= point.x < self.width and 0 <= point.y < self.height: self.put_pixel(point.x, point.y, color)
def __init__(self, position: Vector, normal: Vector, u: float, v: float, color: Color = Color.cyan()): self.position = position self.normal = normal self.u = u self.v = v self.color = color
def __init__(self, pixels, width, height): self.pixels = pixels self.width = width self.height = height self.canvas = Canvas(width, height, pixels) # setup key handlers key_esc = 27 self.handlers = {key_esc: self.exit} self.v1 = Vertex(Vector(0, 0), Color.cyan()) self.v2 = Vertex(Vector(300, 100), Color.red()) self.v3 = Vertex(Vector(200, 300), Color.green())
def prettyPrint(self, trains, queryData): header = [ "车次", "车站", "时间", "历时", "商务座", "一等座", "二等座", '高级软卧', "软卧", "动卧", "硬卧", "硬座", "无座", '其他' ] pt = PrettyTable(header) date = queryData['trainDate'] title = '{}——>{}({} {}),共查询到{}个可购票的车次'.format( queryData['fromStation'], queryData['toStation'], Utility.getDateFormat(date), Utility.getWeekDay(date), len(trains)) pt.title = Color.cyan(title) pt.align["车次"] = "l" # 左对齐 for train in trains: pt.add_row(train) print(pt)
def __init__(self, pixels, width, height): self.pixels = pixels self.width = width self.height = height self.canvas = Canvas(width, height, pixels) # setup key handlers key_esc = 27 self.handlers = { key_esc: self.exit } self.v1 = Vertex(Vector(0, 0), Color.cyan()) self.v2 = Vertex(Vector(300, 100), Color.red()) self.v3 = Vertex(Vector(200, 300), Color.green())
def pretty_print(trains, queryData): """ 按照一定格式打印,美化 :param trains: 所有火车信息 :param queryData: 用户输入的查票信息字典 """ header = [ "车次", "车站", "时间", "历时", "商务座", "一等座", "二等座", '高级软卧', "软卧", "动卧", "硬卧", "硬座", "无座", '其他' ] pt = PrettyTable(header) date = queryData['trainDate'] title = '{}——>{}({} {}),共查询到{}个可购票的车次' \ .format(queryData['fromStation'], queryData['toStation'], Utility.get_date_format(date), Utility.get_week_day(date), len(trains)) pt.title = Color.cyan(title) pt.align["车次"] = "l" # 左对齐 for train in trains: pt.add_row(train) print(pt)