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

Need help in gpu.copy()

Question

The gpu.copy() is a little bit bugged i would say or i use it wrong

 

 

local c = require("component")
local gpu2 = c.proxy(c.get("009"))
gpu2.setBackground(0xCC0000) -- setting background to red
local x,y = gpu2.getResolution()
gpu2.fill(1,1,x,y," ")       -- fill the whole screen red
gpu2.setBackground(0x000000) -- setting background to black
gpu2.fill(1,1,x,y/2," ")     -- fill the top half screen black
os.sleep(2)
gpu2.copy(1,y/2,x,y/2,1,1)   -- copy the red half bottom to the half top
print(y/2) -- just to check if i calculate something wrong
os.sleep(2)

 

And it doesn't work at all as you can see in the picture...

I maybe need some examples and tutorials for this.

Desktop Screenshot 2019.03.13 - 21.32.18.01.png

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1
  • Solution

The inputs for gpu.copy() are x, y, width, height, x_offset (relative position to x; so the new rectangle starts at coordinate x - tx), y_offset (same as for x_offset).

So basically if you want to copy the lower part to the upper part, you have to call: 

gpu.copy(1, y/2, x, y, 0, -y/2)
-- x_offset is 0 because you want to have the rectangle at the same x position as the old one
-- y_offset is -y/2 (-25 for tier 3 screen), because the rectangle starts at a smaller y value compared to the old one

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

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