コード例 #1
0
            running = False

        # User is dragging a point across the screen if left click is selected and being dragged down
        elif event.type == pygame.MOUSEMOTION and event.buttons[0] and len(
                points) > 0:

            # Get position of mouse
            position = pygame.mouse.get_pos()

            # Finds index of point clicked on
            point_index = point_clicked_on(position)

            # Sets new selected point if necessary, and repositions said point to the closest point on the circumference
            if points[point_index].is_draggable:
                points[
                    point_index].pos = circle.closest_point_on_circumference(
                        position)

            # Readjust the points' positions
            adjust_point(point_index, points[point_index].pos)

        # If left mouse button is clicked, the user is selecting a button option
        elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:

            # Gets position of mouse
            position = pygame.mouse.get_pos()

            # If the theorem button is selected, toggle the display of all buttons
            if within(buttons[0].pos, buttons[0].size, position):
                for button in buttons[1:]:
                    button.is_shown = not button.is_shown