Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

CHlM3RA

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by CHlM3RA

  1. I'm currently working on a state machine like function set to maximize efficiency with GPU calls.
    It is meant for usage with a program that builds its interface dynamically (user input, config file)
    where thinking about efficiency will give you more then just headaches.

    It is called like the gpu.set/fill command and returns a id for the given command so you can undo it.
    if you add commands or remove commands it will take care that the other commands are displayed
    correctly and given the case that a command would be displayed just to be overridden within the
    same render sequence its not calling it. To that I'm trying to let it find the most efficient way to execute
    the commands because GPU calls are the most time taking thing in open computers i found so far.
     

     

    Current version 0.6

    Graphics_0.6

    - Optimized memory usage and made id consistent on:
        - move()
        - setTop()

    - Optimized memory usage on
        - remove()

    - Added
        - setBack()
        - removeAll()
        - refreshAll()

    Note:
        - Move, setTop and remove will no longer return an id in the future because it stays the same.
        - The memory usage is almost 50% more efficient on those functions now
        - (It was a get two for the price of one thing).

    Todo:
        - cleaning up color sorting and adding fill/set sorting
        - returning estimated time on how long draw will take to render

     

     

    Graphics_0.4

    - Improved remove efficiency
    - Minimized gpu.setBackground calls
    - added lots of functions
    - removed lots of bugs
    - doesn't draw outside of screen

    I didn't do much testing yet there may be some bugs here and there.
    Please if you find any bugs then leave a comment so i can fix it thanks.




    Functions:

    set(x, y, with, height, background color) or set(x, y, text, background color, text color) returns: id
    - The id is required to make changes or delete a command. Don't lose it.

    remove(id) returns: x, y, with, height, background color or x, y, string, background color, text color nil since 0.6
    - removes command that has given id, thows an error if it does not find it
    - Memory is only freed after the next draw()

    draw() returns: nil
    - Draws any changes on the screen

    move(id, x, y) returns: id (nil in 0.7)
    - Moves a command by x, y and sets it on top.
    - Important: Important: will return nill in upcoming versions.

    setTop(id) returns: id(nil in 0.7)
    - Moves command on top (as if it was the last command given)
    - Important: Important: will return nill in upcoming versions.

    setText(id, text [, text color]) returns: boolean(nil in 0.7)
    - Changes the text. I have no clue what happens if the text is shorter or longer than the old one
    - Returns true if it found the id, false if not
    - Uses old text color if not specified

    setCol(id, color) returns: boolean(nil in 0.7)
    - Changes the background color
    - Returns true if it found the id, false if not

    refresh(id) returns: boolean(nil in 0.7)
    - Redraws itself and everything on top of it.
    - Returns true if it found the id, false if not

     

    setBack(color) returns: nil
    - sets backgroundcolor

    refreshAll() returns: nil

    - refreshes everything

     

    removeAll()  returns: nil

    - removes everything

    example:

    local gra = dofile "graphics_0.6.txt"
    local component = require "component"
    local gpu = component.gpu
    
    x, y = gpu.maxResolution()
    
    local id = {}
    
    gra.setBack(0x000000)
    id[1] = gra.set(5,5,"moving -->", 0xffffff, 0x000000)
    
    gra.draw()
    os.sleep(0.5)
    
    for i = 1, x do
      gra.move(id[1], 1, 0)
      gra.draw() os.sleep(0.05)
    end
    
    gra.setBack(0xffffff)
    gra.setCol(id[1], 0x000000)
    gra.setText(id[1], "<-- moving", 0xffffff)
    gra.draw()
    
    for i = 1, x do
      gra.move(id[1], -1, 0)
      gra.draw() os.sleep(0.05)
    end
    
    os.sleep(0.5)
    gra.setBack(0x000000)
    gra.remove(id[1])
    gra.draw()
    
    gpu.setBackground(0x000000)
    gpu.setForeground(0xffffff)

    graphics_0.4.txt

    test.txt

    graphics_0.6.txt

    test_2.txt

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.