class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.texture = window.ctx.load_texture(RESOURCE_PATH / "robocute.png", flip=False) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Image example") draw_list = imgui.get_window_draw_list() #imgui.image(self.texture.glo, *self.texture.size) #draw_list.add_image(self.texture_id, (0, 0), (self.width, self.height)) draw_list.add_image(self.texture.glo, (0, 0), self.texture.size) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # Window variables self.test_input = 0 def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_input = imgui.input_int("Integer Input Test", self.test_input) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) if imgui.begin_main_menu_bar(): # first menu dropdown if imgui.begin_menu('File', True): imgui.menu_item('New', 'Ctrl+N', False, True) imgui.menu_item('Open ...', 'Ctrl+O', False, True) # submenu if imgui.begin_menu('Open Recent', True): imgui.menu_item('doc.txt', None, False, True) imgui.end_menu() imgui.end_menu() imgui.end_main_menu_bar() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.visible = True def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: collapsing header") expanded, self.visible = imgui.collapsing_header( "Expand me!", self.visible) if expanded: imgui.text("Now you see me!") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # Window variables self.test_input = 0
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.texture = window.ctx.load_texture(RESOURCE_PATH / "robocute.png", flip=False)
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def render(self): imgui.new_frame() if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True ) if clicked_quit: exit(1) imgui.end_menu() imgui.end_main_menu_bar() imgui.show_test_window() imgui.begin("Custom window", True) imgui.text("Bar") imgui.text_colored("Eggs", 0.2, 1., 0.) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: simple popup modal") if imgui.button("Open Modal popup"): imgui.open_popup("select-popup") imgui.same_line() if imgui.begin_popup_modal("select-popup")[0]: imgui.text("Select an option:") imgui.separator() imgui.selectable("One") imgui.selectable("Two") imgui.selectable("Three") imgui.end_popup() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.sprite = arcade.Sprite(":resources:images/space_shooter/playerShip1_orange.png", SPRITE_SCALING) image = self.sprite.texture.image self.texture = window.ctx.texture(image.size, components=3, data=image.convert("RGB").tobytes()) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Sprite") imgui.image(self.texture.glo, *self.texture.size) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.current = 2 def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: combo widget") clicked, self.current = imgui.combo( "combo", self.current, ["first", "second", "third"] ) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Line") draw_list = imgui.get_overlay_draw_list() draw_list.add_line(20, 35, 180, 80, imgui.get_color_u32_rgba(1,1,0,1), 3) draw_list.add_line(180, 35, 20, 80, imgui.get_color_u32_rgba(1,0,0,1), 3) imgui.end() imgui.begin("Poly Line") draw_list = imgui.get_overlay_draw_list() draw_list.add_polyline([(20, 35), (90, 35), (55, 80)], imgui.get_color_u32_rgba(1,1,0,1), closed=False, thickness=3) draw_list.add_polyline([(110, 35), (180, 35), (145, 80)], imgui.get_color_u32_rgba(1,0,0,1), closed=True, thickness=3) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.value = 42.0 def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: drag float") changed, self.value = imgui.drag_float( "Default", self.value, ) changed, self.value = imgui.drag_float("Less precise", self.value, format="%.1f") imgui.text("Changed: %s, Value: %s" % (changed, self.value)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: the variable that contains the color data, should be initialized # outside of the main interaction loop self.color = 1., .0, .5, 1. def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: color edit with alpha") # note: first element of return two-tuple notifies if the color was changed # in currently processed frame and second element is current value # of color and alpha _, self.color = imgui.color_edit4("Alpha", *self.color, show_alpha=True) _, self.color = imgui.color_edit4("No alpha", *self.color, show_alpha=False) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: popup context view") imgui.text("Right-click to set value.") if imgui.begin_popup_context_item("Item Context Menu", mouse_button=0): imgui.selectable("Set to Zero") imgui.end_popup() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) style = imgui.get_style() imgui.begin("Colors") imgui.columns(4) for color in range(0, imgui.COLOR_COUNT): imgui.text("Color: {}".format(color)) imgui.color_button("color#{}".format(color), *style.colors[color]) imgui.next_column() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: these should be initialized outside of the main interaction # loop self.flags = imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.sprite = arcade.Sprite(":resources:images/space_shooter/playerShip1_orange.png", SPRITE_SCALING) image = self.sprite.texture.image self.texture = window.ctx.texture(image.size, components=3, data=image.convert("RGB").tobytes())
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: the variable that contains the color data, should be initialized # outside of the main interaction loop self.color = 1., .0, .5, 1.
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: these should be initialized outside of the main interaction # loop self.checkbox1_enabled = True self.checkbox2_enabled = False
class Gui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.render() self.renderer.render(imgui.get_draw_data())
def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) io = imgui.get_io() self.new_font = io.fonts.add_font_from_file_ttf( str(RESOURCE_PATH / "DroidSans.ttf"), 20) self.renderer.refresh_font_texture()
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: Columns - File list") imgui.columns(4, 'fileLlist') imgui.separator() imgui.text("ID") imgui.next_column() imgui.text("File") imgui.next_column() imgui.text("Size") imgui.next_column() imgui.text("Last Modified") imgui.next_column() imgui.separator() imgui.set_column_offset(1, 40) imgui.next_column() imgui.text('FileA.txt') imgui.next_column() imgui.text('57 Kb') imgui.next_column() imgui.text('12th Feb, 2016 12:19:01') imgui.next_column() imgui.next_column() imgui.text('ImageQ.png') imgui.next_column() imgui.text('349 Kb') imgui.next_column() imgui.text('1st Mar, 2016 06:38:22') imgui.next_column() imgui.columns(1) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def __init__(self, window): self.window = window gui.create_context() self.renderer = ArcadeRenderer(window) self.sprite = arcade.Sprite( ":resources:images/space_shooter/playerShip1_orange.png", SPRITE_SCALING, center_x = 256, center_y = 128 ) image = self.sprite.texture.image self.texture = window.ctx.texture(image.size, components=3, data=image.convert("RGB").tobytes()) self.offscreen = window.ctx.framebuffer(color_attachments=window.ctx.texture(FBSIZE)) self.reset()
class ArcadeImGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def __enter__(self): imgui.new_frame() def __exit__(self, exc_type, exc_val, exc_tb): self.render() def render(self): imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(256, 256, imgui.ONCE) imgui.begin("Rectangle") draw_list = imgui.get_window_draw_list() draw_list.add_rect(20, 35, 90, 80, imgui.get_color_u32_rgba(1, 1, 0, 1), thickness=3) draw_list.add_rect(110, 35, 180, 80, imgui.get_color_u32_rgba(1, 0, 0, 1), rounding=5, thickness=3) imgui.end() imgui.set_next_window_position(270, 32, imgui.ONCE) imgui.set_next_window_size(256, 256, imgui.ONCE) imgui.begin("Filled Rectangle") draw_list = imgui.get_window_draw_list() draw_list.add_rect_filled(20, 35, 90, 80, imgui.get_color_u32_rgba(1, 1, 0, 1)) draw_list.add_rect_filled(110, 35, 180, 80, imgui.get_color_u32_rgba(1, 0, 0, 1), 5) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def __init__(self, width, height, title): """ Initializer """ super().__init__(width, height, title) # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) # Sprite lists self.coin_list = None self.wall_list = None # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(self)
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: empty window") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: these should be initialized outside of the main interaction # loop self.flags = imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: checkboxes for flags", flags=self.flags) clicked, self.flags = imgui.checkbox_flags( "No resize", self.flags, imgui.WINDOW_NO_RESIZE ) clicked, self.flags = imgui.checkbox_flags( "No move", self.flags, imgui.WINDOW_NO_MOVE ) clicked, self.flags = imgui.checkbox_flags( "No collapse", self.flags, imgui.WINDOW_NO_COLLAPSE ) # note: it also allows to use multiple flags at once clicked, self.flags = imgui.checkbox_flags( "No resize & no move", self.flags, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE ) imgui.text("Current flags value: {0:b}".format(self.flags)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) # note: these should be initialized outside of the main interaction # loop self.checkbox1_enabled = True self.checkbox2_enabled = False def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: checkboxes") # note: first element of return two-tuple notifies if there was a click # event in currently processed frame and second element is actual # checkbox state. _, self.checkbox1_enabled = imgui.checkbox("Checkbox 1", self.checkbox1_enabled) _, self.checkbox2_enabled = imgui.checkbox("Checkbox 2", self.checkbox2_enabled) imgui.text("Checkbox 1 state value: {}".format(self.checkbox1_enabled)) imgui.text("Checkbox 2 state value: {}".format(self.checkbox2_enabled)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
class MyGui: def __init__(self, window): self.window = window # Must create or set the context before instantiating the renderer imgui.create_context() self.renderer = ArcadeRenderer(window) self.values = 88, 42, 69, 0 def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: drag int") changed, self.values = imgui.drag_int4("drag ints", *self.values) imgui.text("Changed: %s, Values: %s" % (changed, self.values)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())