Пример #1
0
    def update_visible(self, viewport):
        self.visible_track_segments = []
        for segment in self.track_segments:
            if self.segment_in_rect(segment, viewport):
                self.visible_track_segments.append(segment)

        self.visible_sleepers = []
        for sleeper in self.sleepers:
            if point_in_rect((sleeper.x, sleeper.y), viewport):
                self.visible_sleepers.append(sleeper)
Пример #2
0
 def update_visible(self, viewport):
     self.visible = [
         obj for obj in self.objects
         if point_in_rect(obj.gp, viewport)]
Пример #3
0
    def segment_in_rect(self, segment, rect):
        point1 = segment[:2]
        point2 = segment[2:]

        return point_in_rect(point1, rect) or point_in_rect(point2, rect)