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

How to Display graphics in whole Screen??

Question

Im trying to develop a tankAPI to monitor my railcraft tanks.

I want to put in the screen all tanks together so I need to create an ultra wide screen to show all but I don't know how to print graphics in the whole ultra wide screen

As you can see in the picture, I can only display colors in that green area.

Can someone help me? 

Thanks

2019-07-23_20.08.58.png

Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
19 hours ago, Molinko said:

I'm afraid it's not possible. The max screen resolution is 160x50. But you could use multiple screens for extra real estate

so, how can I controll multiple screens with one computer??

Link to post
Share on other sites
  • 0

So there are two ways to do this. The first is a little more complex. You can simply have two screens and one gpu and switch which screen the gpu is bound to and draw. The second and probably better way is to have two gpus, one for each screen.

-- # 2 screens 1 gpu
local component = require "component"
local prim_screen = component.gpu.getScreen()
local sec_screen

-- # get the second(non primary or unbound) screen address from the dev fs
local f = assert(io.open "/dev/components/by-type/screen/1/address")
sec_screen = f:read "*a" -- # read the file which has the component address
f:close() -- # clean your room

-- # the goods
print "this is one screen 1"
compnent.gpu.bind(sec_screen)
print "gpu is bound to screen 2 now"
component.gpu.bind(prim_screen)
print "back to screen 1"
-- # 2 gpus
local component = require "component"
local gpu1 = component.gpu
local gpu2_address, scr2_address

for address, ctype in component.list() do
  if ctype == 'gpu' and address ~= gpu1.address then
    gpu2_address = address
  elseif ctype == 'screen' and address ~= gpu1.getScreen() then
    scr2_address = address
  end
  if gpu2_address and scr2_address then break end -- # quit early if we have the second gpu & screen pair
end

local gpu2 = component.proxy(gpu2_address)
gpu2.bind(scr2_address) -- # bind the second screen to the second gpu

gpu1.set(3, 3, "this is on screen 1")
gpu2.set(3, 3, "this is on screen 2")

Hope this gets you started. Feel free to ask more if you like :)

Link to post
Share on other sites
  • 0

TL;DR: set the resolution to 159×28.

Displays automatically scale the content to fit the screen's inner area. If you decrease the resolution height, the display area will occupy more horizontal space.

I'll assume that your screen is 8×3. The aspect ratio of the screen's inner area is (2 × (8×16 - 4.5)) : (3×16 - 4.5) = 494×87. The "- 4.5" terms are the screen borders, and the width is doubled because the cell width is half its height. If you set the resolution proportional to this ratio, it will fill the whole screen. Of course, you can't do this, as the maximum resolution is 160×50. So we have to compromise and choose the resolution that fits the screen the best.

local function round(num)
  local integer, frac = math.modf(num)

  if frac >= 0.5 then
    integer = integer + 1
  end

  return integer
end

local data = {}

for w = 1, 160, 1 do
  local h = math.max(math.min(round(w * 87 / 494), 160 * 50 / w, 160), 1)
  local area = w * h
  local delta = (w / h) - 494 / 87

  table.insert(data, {delta, area, ("%d×%d"):format(w, h)})
end

table.sort(data, function(lhs, rhs)
  return lhs[1] < rhs[1]
end)

local f = io.open("./data", "w")

for k, v in ipairs(data) do
  f:write(("%.6f %d %s\n"):format(v[1], v[2], v[3]))
end

f:close()

The above code creates an array and fills it with 160 possible resolutions by choosing a width and calculating the height such that the aspect ratio is the closest to what we're trying to achieve (494:87). Then it writes the data to a file so that we can plot it. Here's what we get:

spacer.png

Now it's clear that the best resolution is 159×28. Its aspect ratio differs from 494/87 by ~0.000411, which is really small. Let's go ahead and calculate the thickness of the black area.

  1. Let dw, dh be the dimensions of the display area, and iw, ih the dimensions of the inner area.
  2. dw/dh = 159/28; iw/ih = 494/87.
  3. 159/28 > 494/87, so the display area height is less than the screen's inner area height. Therefore, the width of the black area is dw = iw.
  4. The height equals 0.5 × (ih - dh) = 0.5 × (87/494 × iw - 28/159 × dw) = 0.5 × iw × (87/494 - 28/159) = 0.5 × 494/87 × ih × (87/494 - 28/159) = 1/27666 × ih.

In other words, the height of the black area is 1/27666th of the whole inner area height, which is negligible.

Edited by Fingercomp
Link to post
Share on other sites
  • 0

I've had that problem too so I made a small program to automatically fix it. (It works for any screen size)

pastebin run B9Enk6qp

Just write this line and thats it. :)

 

It works with Tier 1, 2 and 3 screens.

spacer.png

If you want to code a program on your own to monitor your railcraft tanks then you can stop reading here but if you just want to have a program thats already finished for doing it then you can try out mine.

 

Link to post
Share on other sites
  • 0
On 7/24/2019 at 9:52 PM, Molinko said:

So there are two ways to do this. The first is a little more complex. You can simply have two screens and one gpu and switch which screen the gpu is bound to and draw. The second and probably better way is to have two gpus, one for each screen.


-- # 2 screens 1 gpu
local component = require "component"
local prim_screen = component.gpu.getScreen()
local sec_screen

-- # get the second(non primary or unbound) screen address from the dev fs
local f = assert(io.open "/dev/components/by-type/screen/1/address")
sec_screen = f:read "*a" -- # read the file which has the component address
f:close() -- # clean your room

-- # the goods
print "this is one screen 1"
compnent.gpu.bind(sec_screen)
print "gpu is bound to screen 2 now"
component.gpu.bind(prim_screen)
print "back to screen 1"

-- # 2 gpus
local component = require "component"
local gpu1 = component.gpu
local gpu2_address, scr2_address

for address, ctype in component.list() do
  if ctype == 'gpu' and address ~= gpu1.address then
    gpu2_address = address
  elseif ctype == 'screen' and address ~= gpu1.getScreen() then
    scr2_address = address
  end
  if gpu2_address and scr2_address then break end -- # quit early if we have the second gpu & screen pair
end

local gpu2 = component.proxy(gpu2_address)
gpu2.bind(scr2_address) -- # bind the second screen to the second gpu

gpu1.set(3, 3, "this is on screen 1")
gpu2.set(3, 3, "this is on screen 2")

Hope this gets you started. Feel free to ask more if you like :)

Thank you :) I'll give a try 

On 7/25/2019 at 6:26 AM, Fingercomp said:

TL;DR: set the resolution to 159×28.

Displays automatically scale the content to fit the screen's inner area. If you decrease the resolution height, the display area will occupy more horizontal space.

I'll assume that your screen is 8×3. The aspect ratio of the screen's inner area is (2 × (8×16 - 4.5)) : (3×16 - 4.5) = 494×87. The "- 4.5" terms are the screen borders, and the width is doubled because the cell width is half its height. If you set the resolution proportional to this ratio, it will fill the whole screen. Of course, you can't do this, as the maximum resolution is 160×50. So we have to compromise and choose the resolution that fits the screen the best.


local function round(num)
  local integer, frac = math.modf(num)

  if frac >= 0.5 then
    integer = integer + 1
  end

  return integer
end

local data = {}

for w = 1, 160, 1 do
  local h = math.max(math.min(round(w * 87 / 494), 160 * 50 / w, 160), 1)
  local area = w * h
  local delta = (w / h) - 494 / 87

  table.insert(data, {delta, area, ("%d×%d"):format(w, h)})
end

table.sort(data, function(lhs, rhs)
  return lhs[1] < rhs[1]
end)

local f = io.open("./data", "w")

for k, v in ipairs(data) do
  f:write(("%.6f %d %s\n"):format(v[1], v[2], v[3]))
end

f:close()

The above code creates an array and fills it with 160 possible resolutions by choosing a width and calculating the height such that the aspect ratio is the closest to what we're trying to achieve (494:87). Then it writes the data to a file so that we can plot it. Here's what we get:

spacer.png

Now it's clear that the best resolution is 159×28. Its aspect ratio differs from 494/87 by ~0.000411, which is really small. Let's go ahead and calculate the thickness of the black area.

  1. Let dw, dh be the dimensions of the display area, and iw, ih the dimensions of the inner area.
  2. dw/dh = 159/28; iw/ih = 494/87.
  3. 159/28 > 494/87, so the display area height is less than the screen's inner area height. Therefore, the width of the black area is dw = iw.
  4. The height equals 0.5 × (ih - dh) = 0.5 × (87/494 × iw - 28/159 × dw) = 0.5 × iw × (87/494 - 28/159) = 0.5 × 494/87 × ih × (87/494 - 28/159) = 1/27666 × ih.

In other words, the height of the black area is 1/27666th of the whole inner area height, which is negligible.

Curious and usefull explanation, thank you :)!

Link to post
Share on other sites
  • 0
On 7/28/2019 at 12:09 AM, Nexarius said:

I've had that problem too so I made a small program to automatically fix it. (It works for any screen size)


pastebin run B9Enk6qp

Just write this line and thats it. :)

 

It works with Tier 1, 2 and 3 screens.

spacer.png

If you want to code a program on your own to monitor your railcraft tanks then you can stop reading here but if you just want to have a program thats already finished for doing it then you can try out mine.

 

Nice solution! Can you explain how did you do that?? I'm refering to the resizeable screen haha

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.