This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
dimitriye98's profile picture

[1.4/1.5] Pixel Manipulation

Started by dimitriye98, 11 August 2012 - 11:58 PM
dimitriye98 #1
Posted 12 August 2012 - 01:58 AM
We should be able to turn on and off certain pixels on the console monitor. Not screen pixels and no color but the actual square "dots" on the console/monitor screen. Thus I propose 6 functions to the term api:

term.getPixelSize()

Does exactly what it says, returns to variables, just like term.size(), except these are in pixels.

term.togglePixel(x, y)

Toggles the pixel at (x, y). Note that coordinates are in pixel coordinates, not text coordinates like term.setCursorPos(x, y)

term.setPixel(x, y, set)

If "set" is true then turns pixel (x, y) on, otherwise turns it off.

term.getPixel(x, y)

Returns true if pixel (x, y) is on, otherwise returns false.

term.setPixels(...)

Takes a list of tables with 2 indices, x and y, which both need to be numbers. Simultaneously turns all those pixels on, JAVA-side, so there's none of the lua delay from running a for loop.

term.clear()

Should be modified to clear pixels.

term.clearLine()

Should still work to preserve compatibility, and would clear all pixels in the text-coordinate based line.

Also, text would turn on the right pixels and it would no longer matter what the font file is, it would always be in the default font since text would be pixel based, not character based.
Pharap #2
Posted 12 August 2012 - 07:41 AM
Issue with that is, if just 8 people on a server attempt to do that, it might cause a massive data spike and cause a load of problems either with server speed or possible just the render speed for anyone seeing the computer.

Also, if you just want that for the font, it's not the best way to implement adaptable font. Though it would be fun (fun as in horribly brain exploding, the kind of fun a programmer usually likes) programming a method to alter pixels according to a string argument.

It would also be okay-ish for programming the monitor to draw stuff, but again, probably issues with the draw speed so unless your texture pack was a 1-pixel texture pack, things might get ugly.

The issue above all though is that it would mean changing the entire system for how monitors and computers handle things being drawn, as well as many functions.
dimitriye98 #3
Posted 12 August 2012 - 07:58 AM
the reason I want it is custom graphics and better guis…
Pharap #4
Posted 12 August 2012 - 08:28 AM
the reason I want it is custom graphics and better guis…

Loads of people do, but ultimately it would probably make your computer lag horribly. At any rate, the creators of the mod aren't going to do it, I've seen loads of people ask for things like this, the answer is always no. You're better off trying to contact someone non involved in the creation of CC to make an add-on for it that allows something like that.
dimitriye98 #5
Posted 13 August 2012 - 02:54 AM
Why would it make your computer lag horribly? Practically any application for your computer does a lot more graphically intensive work than determining whether a certain grid square (since I'm not referring to true pixels, but the low-res squares that the text on the computer is made up of at the moment) should be colored black or white. They need to manage 3 values between 0 and 255, and they do this on a much higher resolution. So no, it would not make your computer lag like hell thank you very much.
Pharap #6
Posted 13 August 2012 - 03:15 AM
Why would it make your computer lag horribly? Practically any application for your computer does a lot more graphically intensive work than determining whether a certain grid square (since I'm not referring to true pixels, but the low-res squares that the text on the computer is made up of at the moment) should be colored black or white. They need to manage 3 values between 0 and 255, and they do this on a much higher resolution. So no, it would not make your computer lag like hell thank you very much.


Mostly it would kill servers, as for single player minecraft, there's a chance that the individual drawing logic would cause a load of slow down.

What games do, they load up all their sounds and textures at one point early on in the execution of the program/level. The textures are optimised at that point so it's easy to draw objects coated in those textures, since it is essentially just copying and pasting data.
When you start to invoke complicated calculations to determine an image from individual rectangles or pixels, the computer then has to calculate those every time the screen draws, so a simple copy and paste is now a drawn out calculation. If you have enough monitors running this in normal mode alone it would add to the already noticeably existent minecraft lag.
Put it on a server and you'd be lucky to not cause exceptions or stack overflows.

So that's why it's a bad idea, it introduces a lot of extra processing in the most important event (I'm assuming lwjgl handles draw events similar to game maker and XNA. I don't see why it wouldn't, it was designed to be lightweight after all)

Despite all that, if you really want to try something like this, I believe this add-on may be up your street/alley:
http://www.computercraft.info/forums2/index.php?/topic/1956-ccgpu-basic-shapes-api-v10/page__hl__pixel__fromsearch__1

Yes, I am slightly contradicting myself, but the point of these forums are to resolve people's issues, so here you go, one resolution for you.

If you want more information into the background behind the no pixels argument, try threads like this: http://www.computercraft.info/forums2/index.php?/topic/540-individual-pixel-and-color-control/
dimitriye98 #7
Posted 13 August 2012 - 10:01 AM
Mostly it would kill servers, as for single player minecraft, there's a chance that the individual drawing logic would cause a load of slow down.

What games do, they load up all their sounds and textures at one point early on in the execution of the program/level. The textures are optimised at that point so it's easy to draw objects coated in those textures, since it is essentially just copying and pasting data.
When you start to invoke complicated calculations to determine an image from individual rectangles or pixels, the computer then has to calculate those every time the screen draws, so a simple copy and paste is now a drawn out calculation. If you have enough monitors running this in normal mode alone it would add to the already noticeably existent minecraft lag.
Put it on a server and you'd be lucky to not cause exceptions or stack overflows.

3D rendering is much more intensive then copy-pasting a small white square around the screen so I fail to see your point.

Also, this leads me to believe we have a misunderstanding, I want to change pixels as in this:



Not the pixels on your computer screen.

Pharap said:
Despite all that, if you really want to try something like this, I believe this add-on may be up your street/alley:
http://www.computerc...__fromsearch__1

Yes, I am slightly contradicting myself, but the point of these forums are to resolve people's issues, so here you go, one resolution for you.

If you want more information into the background behind the no pixels argument, try threads like this: http://www.computerc...-color-control/

Again, that's not what I want. Also, can anyone else give me feedback as well? Seriously, my thread has 75 views and all five of the replies are a debate between me and Pharap over weather pixel support can be efficiently implemented or not.
Pinkishu #8
Posted 13 August 2012 - 03:31 PM
I honestly doubt any "drawing logic" here would cause that slowdown, its not a high-resolution and doesn't even have to draw unless the GUI is opened.
And I doubt it would make server lag horribly Oo
Cranium #9
Posted 13 August 2012 - 06:18 PM
So are you saying to manually draw the pixels for each character using a function? Or are you saying to get the pixel x,y for the entire screen?
dimitriye98 #10
Posted 13 August 2012 - 10:01 PM
So are you saying to manually draw the pixels for each character using a function? Or are you saying to get the pixel x,y for the entire screen?

I want to manually draw the pixels. This allows for much better GUI's and greatly expands the function of ComputerCraft graphics-wise. That doesn't mean I want the text functions removed, far from it, I simply want the addition of pixel manipulation.
Cranium #11
Posted 13 August 2012 - 10:24 PM
But I meant for the entire screen at a time, or just for the block normally allotted for characters?
Pharap #12
Posted 13 August 2012 - 10:52 PM
So are you saying to manually draw the pixels for each character using a function? Or are you saying to get the pixel x,y for the entire screen?

I want to manually draw the pixels. This allows for much better GUI's and greatly expands the function of ComputerCraft graphics-wise. That doesn't mean I want the text functions removed, far from it, I simply want the addition of pixel manipulation.

So are saying you want it only for the gui that opens when you right click, or do you want it to draw on the huge monitors as well?
Cranium #13
Posted 13 August 2012 - 10:53 PM
^^that would cause massive lag just to get the pixel size^^
Sammich Lord #14
Posted 14 August 2012 - 07:31 AM
I have read in other threads that admins were saying the reason why it will NOT be added is due to lag.
However if the code for CC was open source people would probably do that but it is NOT.
I would love to see this feature added but it sadly will not.
ardera #15
Posted 14 August 2012 - 08:07 AM
I am working on something like this… Its not an extra mod, but its an modified "default.png" Image.
dimitriye98 #16
Posted 14 August 2012 - 09:34 AM
So are saying you want it only for the gui that opens when you right click, or do you want it to draw on the huge monitors as well?

Both.


^^that would cause massive lag just to get the pixel size^^

No it wouldn't, you already have to get pixel size for displaying text on monitors.


I have read in other threads that admins were saying the reason why it will NOT be added is due to lag.
However if the code for CC was open source people would probably do that but it is NOT.
I would love to see this feature added but it sadly will not.

These were likely talking about different "pixel manipulation" then I am. Earlier I made an image to explain what I meant. They were likely talking about screen pixels.


I am working on something like this… Its not an extra mod, but its an modified "default.png" Image.

How exactly would this work? The application of what I suggested is impossible without changes to the code.
Pharap #17
Posted 14 August 2012 - 10:29 AM
So are saying you want it only for the gui that opens when you right click, or do you want it to draw on the huge monitors as well?

Both.


^^that would cause massive lag just to get the pixel size^^

No it wouldn't, you already have to get pixel size for displaying text on monitors.


I have read in other threads that admins were saying the reason why it will NOT be added is due to lag.
However if the code for CC was open source people would probably do that but it is NOT.
I would love to see this feature added but it sadly will not.

These were likely talking about different "pixel manipulation" then I am. Earlier I made an image to explain what I meant. They were likely talking about screen pixels.


I am working on something like this… Its not an extra mod, but its an modified "default.png" Image.

How exactly would this work? The application of what I suggested is impossible without changes to the code.
That's what I thought.

No you don't, you get the character size. A screen can display 900 ascii characters.

Unless the average computer screen has only 5,000 pixels, they weren't (here's a hint, my laptop screen resolution is 1366x768, and has 1049088 pixels).

Yes, they are talking about the only current way to develop non-text guis. Changing the text texture file. (Yes, the text on a computercraft screen is made of rendered textures. LWJGL does not support individual pixel changing as far as I am aware. Like I said the only way to do it this far away from the central draw event is to edit textures on the fly, which will cause a fair bit of lag after about the 7th screen +/- 3)
Floedekage #18
Posted 14 August 2012 - 02:41 PM
I like this idea, this is exactly what I need.
However, why not make a font.png image in every computers directory containing 256 characters, then this could be edited in-game and if one character was "font.png / 16" in width and the same in height you could make 256 color graphics. You could even make Arabic and Chinese characters easily or change the font color.

I hope this is understandable.
Pharap #19
Posted 14 August 2012 - 05:49 PM
I like this idea, this is exactly what I need.
However, why not make a font.png image in every computers directory containing 256 characters, then this could be edited in-game and if one character was "font.png / 16" in width and the same in height you could make 256 color graphics. You could even make Arabic and Chinese characters easily or change the font color.

I hope this is understandable.

Because it would only change the appearance for you, since it would be your font file (like a texture pack only changes the appearance for you) which partly defeats the object. It would be an ok fix for single player, but the people in charge like to have the mod's client and server versions synced, so they will almost certainly say no.
dimitriye98 #20
Posted 15 August 2012 - 04:01 AM
That's what I thought.

No you don't, you get the character size. A screen can display 900 ascii characters.

Unless the average computer screen has only 5,000 pixels, they weren't (here's a hint, my laptop screen resolution is 1366x768, and has 1049088 pixels).

Yes, they are talking about the only current way to develop non-text guis. Changing the text texture file. (Yes, the text on a computercraft screen is made of rendered textures. LWJGL does not support individual pixel changing as far as I am aware. Like I said the only way to do it this far away from the central draw event is to edit textures on the fly, which will cause a fair bit of lag after about the 7th screen +/- 3)

Like I keep saying look at this image I made earlier:


Those are the "pixels" I want to change. As in, the little white squares that make up the text on the computer craft screen. These are many times bigger than the pixels you are talking about, the pixels on the actual computer screen.
Cranium #21
Posted 15 August 2012 - 04:19 AM
I'm asking if you are wanting to change the pixels for the cahracters at a time, or be able to do the entire screen at a time?
Pharap #22
Posted 15 August 2012 - 05:14 AM
That's what I thought.

No you don't, you get the character size. A screen can display 900 ascii characters.

Unless the average computer screen has only 5,000 pixels, they weren't (here's a hint, my laptop screen resolution is 1366x768, and has 1049088 pixels).

Yes, they are talking about the only current way to develop non-text guis. Changing the text texture file. (Yes, the text on a computercraft screen is made of rendered textures. LWJGL does not support individual pixel changing as far as I am aware. Like I said the only way to do it this far away from the central draw event is to edit textures on the fly, which will cause a fair bit of lag after about the 7th screen +/- 3)

Like I keep saying look at this image I made earlier:


Those are the "pixels" I want to change. As in, the little white squares that make up the text on the computer craft screen. These are many times bigger than the pixels you are talking about, the pixels on the actual computer screen.

It's still the same base problem, it means a complete design of how the screen works and if every character on the screen was 8 pixels you'd be rendering 8 times as many textures on top of each console. It's a significant increase.
immibis #23
Posted 15 August 2012 - 05:23 AM
That's what I thought.

No you don't, you get the character size. A screen can display 900 ascii characters.

Unless the average computer screen has only 5,000 pixels, they weren't (here's a hint, my laptop screen resolution is 1366x768, and has 1049088 pixels).

Yes, they are talking about the only current way to develop non-text guis. Changing the text texture file. (Yes, the text on a computercraft screen is made of rendered textures. LWJGL does not support individual pixel changing as far as I am aware. Like I said the only way to do it this far away from the central draw event is to edit textures on the fly, which will cause a fair bit of lag after about the 7th screen +/- 3)

Like I keep saying look at this image I made earlier:


Those are the "pixels" I want to change. As in, the little white squares that make up the text on the computer craft screen. These are many times bigger than the pixels you are talking about, the pixels on the actual computer screen.

It's still the same base problem, it means a complete design of how the screen works and if every character on the screen was 8 pixels you'd be rendering 8 times as many textures on top of each console. It's a significant increase.

There's no law of nature saying each pixel has to be rendered as a separate texture. It could be one texture for the whole screen updated when the computer changes pixels, for example.
Luanub #24
Posted 15 August 2012 - 05:49 AM
It don't matter if you're doing the pixel's on the computer screen or the pixels on the CC Terminal screen, its still going to take to much system resources to not cause issues with SMP servers. SSP it would probably work fine, but as long as it will cause issues with SMP it will not happen.
Pinkishu #25
Posted 15 August 2012 - 05:28 PM
It don't matter if you're doing the pixel's on the computer screen or the pixels on the CC Terminal screen, its still going to take to much system resources to not cause issues with SMP servers. SSP it would probably work fine, but as long as it will cause issues with SMP it will not happen.

Interesting, how would such a low-resolution thing that only needs to be sent fully on opening and just updates on changes put any stress on smp?
Luanub #26
Posted 15 August 2012 - 08:42 PM
Due to having more users using it on the same server at the same time maybe? Just like anything else you increase the number of instances being ran and you increase the load on the system. Having multiple people controlling pixels like that will take its toll on the server and cause performance issues(unless you've got a top end machine but I imagine very few of the MC servers run on those types of machines). It people get control of pixels they are going to do more then just print a banner for their program. They are going to go all out and do animations. Thats why it would be okay in SSP, but have issues in SMP.

Do you work with servers? I spent 8+ hours at day working on them…
Floedekage #27
Posted 16 August 2012 - 01:01 AM
Because it would only change the appearance for you, since it would be your font file (like a texture pack only changes the appearance for you) which partly defeats the object. It would be an ok fix for single player, but the people in charge like to have the mod's client and server versions synced, so they will almost certainly say no.

Now, I mean if every computer had a font.png file in their directory it could be transferred to the client when opening the computer, like a texture pack.
Now, I can see the trouble considering the speed and I don't know how long it would take to transfer an image even if it only was in 256 or even 16 colors. (I don't know if you can do that with .png)

But there must be a way to make this happen, even if it should be an add-on.
Luanub #28
Posted 16 August 2012 - 01:35 AM
There is this http://www.computercraft.info/forums2/index.php?/topic/986-132-ccgpu-a-gpu-addon-for-computercraft/

I haven't played with it so I'm not sure what all it is capable of.
Pinkishu #29
Posted 16 August 2012 - 01:41 AM
Due to having more users using it on the same server at the same time maybe? Just like anything else you increase the number of instances being ran and you increase the load on the system. Having multiple people controlling pixels like that will take its toll on the server and cause performance issues(unless you've got a top end machine but I imagine very few of the MC servers run on those types of machines). It people get control of pixels they are going to do more then just print a banner for their program. They are going to go all out and do animations. Thats why it would be okay in SSP, but have issues in SMP.

Do you work with servers? I spent 8+ hours at day working on them…

Which isn't too much updating, if setting a few pixels on/off lags a server they shouldn't be hosting :(/>/> Any sophisticated RP2 systems would probably cause more toll (Note: RP2 allows "drawing" by having a bigger display and being able to draw box-characters)
inventor2514 #30
Posted 16 August 2012 - 02:38 AM
Personally, I would like to have pixel manipulation. I can't see it being a huge issue, but I haven't worked much with servers. Maybe the API could be optional, like the http API.
Pharap #31
Posted 16 August 2012 - 07:00 AM
That's what I thought.

No you don't, you get the character size. A screen can display 900 ascii characters.

Unless the average computer screen has only 5,000 pixels, they weren't (here's a hint, my laptop screen resolution is 1366x768, and has 1049088 pixels).

Yes, they are talking about the only current way to develop non-text guis. Changing the text texture file. (Yes, the text on a computercraft screen is made of rendered textures. LWJGL does not support individual pixel changing as far as I am aware. Like I said the only way to do it this far away from the central draw event is to edit textures on the fly, which will cause a fair bit of lag after about the 7th screen +/- 3)

Like I keep saying look at this image I made earlier:


Those are the "pixels" I want to change. As in, the little white squares that make up the text on the computer craft screen. These are many times bigger than the pixels you are talking about, the pixels on the actual computer screen.

It's still the same base problem, it means a complete design of how the screen works and if every character on the screen was 8 pixels you'd be rendering 8 times as many textures on top of each console. It's a significant increase.

There's no law of nature saying each pixel has to be rendered as a separate texture. It could be one texture for the whole screen updated when the computer changes pixels, for example.

Even doing it that way could have major negative effects. It means that the texture has to be opened for editing, then each pixel has to be read and updated according to the new arrangement. This arguable takes longer than the method I stated earlier since you are editing a texture mid game, also meaning you have to store each computer's texture separately on top of that, and the edit would have to occur each update without a complicated way of testing if it needs updating (you can't test if images are equal in programming since they are essentially large arrays of data, you can only assign images).
dimitriye98 #32
Posted 16 August 2012 - 08:34 AM
Ok, we've been arguing quite a bit wether this is possible or not, so Cloudy or Dan200, please answer:

Is this feasible?

If so, can/will it be implemented?
Pharap #33
Posted 16 August 2012 - 09:05 AM
Ok, we've been arguing quite a bit wether this is possible or not, so Cloudy or Dan200, please answer:

Is this feasible?

If so, can/will it be implemented?

Was luanub's link to mast3rplan's project not enough?
Pinkishu #34
Posted 16 August 2012 - 12:14 PM
Fun fact: the server doesn't have to do any drawing. It just saves and array of boolean values thats is sent to the client which then handles the drawing and that only if the PC screen is opened
Pharap #35
Posted 16 August 2012 - 12:49 PM
Fun fact: the server doesn't have to do any drawing. It just saves and array of boolean values thats is sent to the client which then handles the drawing and that only if the PC screen is opened
If there were colours, it would have to be an array of 3 byte values, which could make the array anywhere from 2 to 1 times more bigger (boolean values take up different amounts of bytes per pc, or so I'm told)
For those who no thing of arrays, they are one of the optional equivalents of lua's tables. Lua works weirdly with it's tables compared to the c and basic based languages.
Pinkishu #36
Posted 16 August 2012 - 01:16 PM
As far as i've seen the first post doesn't mention colors though~
dimitriye98 #37
Posted 16 August 2012 - 07:34 PM
Fun fact: the server doesn't have to do any drawing. It just saves and array of boolean values thats is sent to the client which then handles the drawing and that only if the PC screen is opened
If there were colours, it would have to be an array of 3 byte values, which could make the array anywhere from 2 to 1 times more bigger (boolean values take up different amounts of bytes per pc, or so I'm told)
For those who no thing of arrays, they are one of the optional equivalents of lua's tables. Lua works weirdly with it's tables compared to the c and basic based languages.

I don't want colors, I simply want to turn on and off those white squares, also:

Funfact: If I was implementing this, I wouldn't use an array of boolean values, I'd use a function which maps the boolean values to a binary number.
Luanub #38
Posted 16 August 2012 - 10:21 PM
Here's a reply from an admin about having control over the 5000 pixels on the default CC Screen and why it won't happen… http://www.computercraft.info/forums2/index.php?/topic/540-individual-pixel-and-color-control/

As people have said, this has been brought up and has been rejected due to the impact on servers in SMP…
Pinkishu #39
Posted 16 August 2012 - 10:29 PM
well 900 characters at 1 byte = 900 byte
5000 pixels at 1 bit = 625 byte

Also noting: that topic had colors suggested too

RP monitors have 4000 characters
Luanub #40
Posted 16 August 2012 - 11:03 PM
There's a big difference between the way people will use characters vs pixels. No one ever really uses all the possible char space and they are not refreshing it on a constant and rather fast rate to make images. If people gain pixel control they will make images and things such as animated games that will need to refresh a lot faster and will cause performance issues on servers with any load on them at all(color or not, color would just be worse).

RP also uses your systems/servers hardware differently :(/>/>
Pinkishu #41
Posted 16 August 2012 - 11:25 PM
Interesting, my animation system uses every character for some effects :(/>/>
And well without pixel control or anything like that CC will stay very limited in what is possible with it
immibis #42
Posted 17 August 2012 - 09:16 AM
There's a big difference between the way people will use characters vs pixels. No one ever really uses all the possible char space and they are not refreshing it on a constant and rather fast rate to make images. If people gain pixel control they will make images and things such as animated games that will need to refresh a lot faster and will cause performance issues on servers with any load on them at all(color or not, color would just be worse).

RP also uses your systems/servers hardware differently :(/>/>

And then the server will refuse to send screen updates that quickly, and everyone will stop making high-res animated games in SMP because of the lag - it wouldn't be Minecraft that lagged, just that in-game computer.
Luanub #43
Posted 17 August 2012 - 09:34 AM
There's a big difference between the way people will use characters vs pixels. No one ever really uses all the possible char space and they are not refreshing it on a constant and rather fast rate to make images. If people gain pixel control they will make images and things such as animated games that will need to refresh a lot faster and will cause performance issues on servers with any load on them at all(color or not, color would just be worse).

RP also uses your systems/servers hardware differently :(/>/>

And then the server will refuse to send screen updates that quickly, and everyone will stop making high-res animated games in SMP because of the lag - it wouldn't be Minecraft that lagged, just that in-game computer.

With the way that CC uses the servers hardware it would lag the entire server. Unlike RP, CC's computers has full access to the systems resources. RP is limited to the ram modules you install 8KB isn't much if your running a system with 4GB each CC computer gets access to the full 4GB. On the CPU side RP has access to a 1MHz CPU while each CC computer has you're entire CPU(most these days are well over 2GHz) available to it. Due to that if people were hamming it that hard it would lag the entire server, possibly even crash it.
Cloudy #44
Posted 17 August 2012 - 10:18 AM
There's a big difference between the way people will use characters vs pixels. No one ever really uses all the possible char space and they are not refreshing it on a constant and rather fast rate to make images. If people gain pixel control they will make images and things such as animated games that will need to refresh a lot faster and will cause performance issues on servers with any load on them at all(color or not, color would just be worse).

RP also uses your systems/servers hardware differently :(/>/>

And then the server will refuse to send screen updates that quickly, and everyone will stop making high-res animated games in SMP because of the lag - it wouldn't be Minecraft that lagged, just that in-game computer.

With the way that CC uses the servers hardware it would lag the entire server. Unlike RP, CC's computers has full access to the systems resources. RP is limited to the ram modules you install 8KB isn't much if your running a system with 4GB each CC computer gets access to the full 4GB. On the CPU side RP has access to a 1MHz CPU while each CC computer has you're entire CPU(most these days are well over 2GHz) available to it. Due to that if people were hamming it that hard it would lag the entire server, possibly even crash it.

What are you talking about? It would be no different than any other script running on a computer. Providing we have the correct server side control.
immibis #45
Posted 17 August 2012 - 02:39 PM
And then the server will refuse to send screen updates that quickly, and everyone will stop making high-res animated games in SMP because of the lag - it wouldn't be Minecraft that lagged, just that in-game computer.

With the way that CC uses the servers hardware it would lag the entire server. Unlike RP, CC's computers has full access to the systems resources. RP is limited to the ram modules you install 8KB isn't much if your running a system with 4GB each CC computer gets access to the full 4GB. On the CPU side RP has access to a 1MHz CPU while each CC computer has you're entire CPU(most these days are well over 2GHz) available to it. Due to that if people were hamming it that hard it would lag the entire server, possibly even crash it.

What are you talking about? It would be no different than any other script running on a computer. Providing we have the correct server side control.

This. I meant that the rate of updates should be limited, so that using pixels is a trade-off between refresh rate and resolution. If you use pixels, you get more resolution, but can't update the screen as quickly. If you use text, you can update the screen quickly, but only get text.

Semi-related, there should be block and line drawing characters in CC, something like code page 437
Sebra #46
Posted 17 August 2012 - 03:20 PM
Limit it by one draw operation on console/monitor per tick.
So you can write 20 lines of text per second or spend two seconds to draw one 5x8 symbol.
Cloudy #47
Posted 17 August 2012 - 03:22 PM
Yeah, agreed. We do want to support other languages' char sets, so we will probably look into support for that at the same time (they are already in the default font image).
Sebra #48
Posted 17 August 2012 - 03:26 PM
Then make other code pages possible, please.
As a config choice or a picture swap. or …
Cloudy #49
Posted 17 August 2012 - 03:40 PM
Then make other code pages possible, please.
As a config choice or a picture swap. or …

We won't support it as a code page if we do - we will just try and get the characters supported.
dimitriye98 #50
Posted 25 August 2012 - 02:03 AM
Ok, I apologize for my absence in arguing my suggestion, I'd forgotten that I'd even suggested something :D/>/> Anyhow, so, Cloudy, would it be possible for this suggestion to be added?

Limit it by one draw operation on console/monitor per tick.
So you can write 20 lines of text per second or spend two seconds to draw one 5x8 symbol.

Also, I would agree with this if provided with the ability to combine multiple coordinates into a single update, so, while I could spend two seconds to draw one 5x8 symbol, I could also put all the points into a table or something similar and call a special set function which would draw the whole 5x8 character in one go. So basically what I would request if such a limitation were added would be a method of combining points similar to how, in the redstone api, I can combine bundled cable colors to change them all with one function.
Sammich Lord #51
Posted 25 August 2012 - 11:42 AM
What if to display pixels you had to define the pixel locations at the top of the code then it loads the custom pixel gen into memory then just copies and pastes them when called for. So kinda like how games load the graphics first then basically just copies and pastes them.
ds84182 #52
Posted 28 August 2012 - 01:40 AM
First, the server would be informed by draw commands. So if I wanted to set all of the pixel to white then fill true in some kind of number system gets sent. The server then tells the client what to draw. It creates a drawlist. The drawlist isn't syncronized, so you don't have to tell the server over and over again. Plus, like how the yielding timer works, it could stop all draw commands for a few seconds if too many are sent. Basically, it is sent like a cpu opcode, the first 4 bits are the command, and the other 28 are options (32 bit values are used)
[] = unused
, = option seperator
clear -> 0x0[0000000]
fill true -> 0x1[000000],1
fill false -> 0x1[000000],0
plot 400, 144, true -> 0x2,190,90,1[0]
plot 400, 144, false -> 0x2,190,90,0[0]
You probably get the rest… And It DOESN'T HAVE TO BE LIMITED TO 32BIT(4bytes)
immibis #53
Posted 29 August 2012 - 04:19 AM
First, the server would be informed by draw commands. So if I wanted to set all of the pixel to white then fill true in some kind of number system gets sent. The server then tells the client what to draw. It creates a drawlist. The drawlist isn't syncronized, so you don't have to tell the server over and over again. Plus, like how the yielding timer works, it could stop all draw commands for a few seconds if too many are sent. Basically, it is sent like a cpu opcode, the first 4 bits are the command, and the other 28 are options (32 bit values are used)
,
Like display lists in OpenGL? I like it.
GopherAtl #54
Posted 06 September 2012 - 12:34 AM
Maybe its just me, but vector graphics seem more appropriate. Logo-style, penUp, penDown, move, and turn.
Pharap #55
Posted 06 September 2012 - 02:03 AM
Maybe its just me, but vector graphics seem more appropriate. Logo-style, penUp, penDown, move, and turn.
Vector graphics are more complicated and involve loads of calculations, hence why raster graphics are still standard
GopherAtl #56
Posted 06 September 2012 - 04:41 PM
Loads of calculations? Not really. Line drawing algorithms are trivial, and a 360-degree slope lookup table is trivial as well; using reflection you only need a table for 45 degrees. Other than that you just need basic vector addition. More Important, I think, is that vector graphics take a lot less memory than pixel graphics, making them more server and bandwidth friendly.
Pharap #57
Posted 08 September 2012 - 12:05 AM
Loads of calculations? Not really. Line drawing algorithms are trivial, and a 360-degree slope lookup table is trivial as well; using reflection you only need a table for 45 degrees. Other than that you just need basic vector addition. More Important, I think, is that vector graphics take a lot less memory than pixel graphics, making them more server and bandwidth friendly.

If they are so trivial, I'd love to see some examples of such calculations. I assume you have some you'd be willing to share with the community?
GopherAtl #58
Posted 08 September 2012 - 06:28 AM
challenge: accepted.

Just threw together a basic line drawing function in terminal, and a program to use it to do a basic dancing line. Time so far: ~45 minutes. Later will make a logo API with penUp/Down, penChar, turn, turnTo, forward, and moveTo functions.

http://pastebin.com/iJYzitra

works with any size monitors if you run it as "monitor <side> dancingLine" (or whatever you named it in the pastebin get)

stop with ctrl-T

:edit:

after a break went back and spent another 45 mins or so of effort. Now have logo API…

http://pastebin.com/vn5B8ZUg (save as "logo" for the sample program to load and use it properly)

and the sample program…

http://pastebin.com/QyCQAhqP
dimitriye98 #59
Posted 09 September 2012 - 05:29 AM
Wow, I forgot about this thread and it's stayed alive for a very long time. Anyhow, GopherAlt, thats very neat but raster graphics would honestly be easier to use. Simply tell the computer to turn a certain set of coordinates on or off.
GopherAtl #60
Posted 09 September 2012 - 06:48 AM
well, easier to use? certainly. But vector graphics would offload most of the heavy lifting to the clients instead of the server, who simply maintains lists of lines, and maybe I'm crazy (ok, certainly I'm crazy - I've started implementing a full logo language interpreter now, complete with variables and functions based on this initial code), but I like the symetry of turtle graphics in the computercraft universe.

My only point was that the arguments against vector graphics shouldn't include complexity or computational cost, and in fact from a technical standpoint they have advantages in reduced memory, and thus bandwidth, load for the server.
Pharap #61
Posted 10 September 2012 - 12:36 AM
challenge: accepted.

Just threw together a basic line drawing function in terminal, and a program to use it to do a basic dancing line. Time so far: ~45 minutes. Later will make a logo API with penUp/Down, penChar, turn, turnTo, forward, and moveTo functions.

http://pastebin.com/iJYzitra

works with any size monitors if you run it as "monitor <side> dancingLine" (or whatever you named it in the pastebin get)

stop with ctrl-T

:edit:

after a break went back and spent another 45 mins or so of effort. Now have logo API…

http://pastebin.com/vn5B8ZUg (save as "logo" for the sample program to load and use it properly)

and the sample program…

http://pastebin.com/QyCQAhqP

I'll be fair, you did actually go and do it, and in that situation vector graphics are better,
but when I tried the following:


function line(x1,y1,x2,y2)
  local distX=x2-x1
  local distY=y2-y1
  if math.abs(distX)>math.abs(distY) then
    --step over x
    local stepx=1
    if x2<x1 then
      stepx=-1
    end
    local stepy=stepx*distY/distX
    local y=y1    
    for x=x1,x2,stepx do
      term.setCursorPos(x,y)
      term.write("x")
      y=y+stepy
    end
  else
    --step over y
    local stepy=1
    if y2<y1 then
      stepy=-1
    end
    local stepx=stepy*distX/distY
    local x=x1    
    for y=y1,y2,stepy do
      term.setCursorPos(x,y)
      term.write("x")
      x=x+stepx
    end

  end
end

term.clear()
line(3,9,2,2)
line(3,9,7,4)
line(7,4,2,2)
term.setCursorPos(12,12)

The results weren't exactly the 3 lines expected, so needless to say it needs a bit of work.
The whole 'real line' to 'pixel line' thing is the main reason I say vector graphics aren't as simple as you would first expect.
Not saying they aren't useful, but there are reasons that they have yet to replace raster graphics, and I doubt it's merely because raster graphics are more user friendly, because as any programmer knows, with the right user interface, even complex tasks can look simple.

I do however encourage you to keep doing what you are doing and hopefully figure out why some of these little obscurities occur and how to get around them.
GopherAtl #62
Posted 10 September 2012 - 12:50 AM
heh. yeah, my line algo is not very polished, but it was a rush job, and I hadn't implemented a line drawing algorithm in probably a decade or more. I plan on continuing with my logo project at least a bit longer, and eventually I'll get around to disecting and improving the line drawing algorithm; it was basically "good enough" for me to continue pushing forward with the proof of concept.

And actually, raster graphics replaced vector graphics 30 years ago. The earliest monitors were all vector-based, as early computers didn't have the memory for pixel graphics, at least not at any reasonable resolutions. Vector graphics are decidedly low tech, which is what I like about them :D/>/>
Pharap #63
Posted 10 September 2012 - 01:34 AM
heh. yeah, my line algo is not very polished, but it was a rush job, and I hadn't implemented a line drawing algorithm in probably a decade or more. I plan on continuing with my logo project at least a bit longer, and eventually I'll get around to disecting and improving the line drawing algorithm; it was basically "good enough" for me to continue pushing forward with the proof of concept.

And actually, raster graphics replaced vector graphics 30 years ago. The earliest monitors were all vector-based, as early computers didn't have the memory for pixel graphics, at least not at any reasonable resolutions. Vector graphics are decidedly low tech, which is what I like about them :D/>/>

Well, if you think Vector graphics are the way forward for CC, a good API is always the best way to prove a point (aside from my favourite technique, the cannon, but sadly they've become less effective since the introduction of the internet).

Makes me yearn for floppy disks, even though I've only ever owned about 1.
It makes me beg the question though, surely using less memory was a good thing, but hey-ho, I'm no computer scientist.
I yearn for the days when it wasn't all 'screw gameplay, this game has good graphics'.
I'm going to stop now before I start talking about cathode ray tubes.
GopherAtl #64
Posted 10 September 2012 - 01:42 AM
well, less memory was good, but memory became cheap, and raster graphics are more flexible. Vector graphics can be implemented on a raster display easily, as I just proved, but a raster display can't be emulated with vectors, at least not in a sane way - vectors cease to use less memory if you fill the whole screen with 1-pixel-long lines of different colors!

:edit: refreshed myself on bresenham's algorithm and wrote a new line function earlier. This version should give you the lines you expected in your example before :D/>/> Logo api has been updated, link's in my logo thread

Spoiler

--Bresenham's line algo, adapted to lua by me
function line(x1,y1,x2,y2) 
  local steep = math.abs(y2-y1)>math.abs(x2-x1)
  local setPos
  if steep then
    y1,x1=x1,y1
    y2,x2=x2,y2
    setPos=function(y,x) term.setCursorPos(x,y) end
  else
    setPos=function(x,y) term.setCursorPos(x,y) end
  end
  if x1>x2 then
    x1,x2=x2,x1
    y1,y2=y2,y1
  end
  local dx=x2-x1
  local dy=y2-y1
  local err=dx/2
  local ys= y1<y2 and 1 or -1
  local y=y1
  for x=x1,x2 do
    setPos(x,y)
    term.write("x")
    err=err-dy
    if err<0 then
	  y=y+ys
	  err=err+dx
    end
  end  
end

[color="#000000"]term[/color][color="#666600"].[/color][color="#000000"]clear[/color][color="#666600"]()[/color]
[color="#000000"]line[/color][color="#666600"]([/color][color="#006666"]3[/color][color="#666600"],[/color][color="#006666"]9[/color][color="#666600"],[/color][color="#006666"]2[/color][color="#666600"],[/color][color="#006666"]2[/color][color="#666600"])[/color]
[color="#000000"]line[/color][color="#666600"]([/color][color="#006666"]3[/color][color="#666600"],[/color][color="#006666"]9[/color][color="#666600"],[/color][color="#006666"]7[/color][color="#666600"],[/color][color="#006666"]4[/color][color="#666600"])[/color]
[color="#000000"]line[/color][color="#666600"]([/color][color="#006666"]7[/color][color="#666600"],[/color][color="#006666"]4[/color][color="#666600"],[/color][color="#006666"]2[/color][color="#666600"],[/color][color="#006666"]2[/color][color="#666600"])[/color]
[color="#000000"]term[/color][color="#666600"].[/color][color="#000000"]setCursorPos[/color][color="#666600"]([/color][color="#006666"]12[/color][color="#666600"],[/color][color="#006666"]12[/color][color="#666600"])[/color]
dimitriye98 #65
Posted 16 September 2012 - 12:13 AM
Ok, still, though, raster graphics are easier to use. You argued that with vector graphics the server can have the client do the heavy lifting, you can do that with raster as well. The server tells the client a set of coordinates, probably compressed, and the client draws them. Honestly, as you said:
Vector graphics can be implemented on a raster display easily, as I just proved, but a raster display can't be emulated with vectors, at least not in a sane way - vectors cease to use less memory if you fill the whole screen with 1-pixel-long lines of different colors!
So, honestly, raster graphics seem better. You won't need that much memory if you limit the display clock-speed. What about this:
term.newCanvas() - Returns a new canvas.
term.queueCanvas(canvas) - Queues the canvas to be displayed at the next display update.
canvas:setPixel(x, y, on) - Where canvas is the return value of term.newCanvas() if on is true sets pixel (x, y) on the canvas, otherwise clears it.
canvas:getPixel(x, y) - returns wether or not pixel (x, y) on that canvas is on.
canvas:setPixels(on, x1, y1, x2, y2, …, xn, yn) - sets the pixels indicated on the canvas if on is true otherwise clears them.
GopherAtl #66
Posted 16 September 2012 - 01:01 AM
that's the thing. Setpixel is bandwidth-unfriendly. If you were going to a raster display, you'd want to do what early raster displays for real-time graphics did - with tile/sprite sets, rather than pixel-level manipulation.
dimitriye98 #67
Posted 29 September 2012 - 12:09 AM
No, it isn't. You do this:

local canvas = term.newCanvas()
canvas:setPixels(true, 1, 1, 2, 1, 3, 1, 2, 2, 2, 3) --T stands for test :P/>/>
and the server doesn't send any data to the client until you do this:

term.queueCanvas(canvas)
GopherAtl #68
Posted 29 September 2012 - 03:56 AM
yeeah. You're suggesting that if the per-pixel api is implemented in a specific way that would be not at all intuitive to the average computercraft programmer, who has zero prior programming experience, graphics or otherwise, then yes, there's no problem.

Text mode works better with a buffer and a single command to send it to the client, too. It doesn't have one built-in for a reason.
Pharap #69
Posted 29 September 2012 - 07:25 AM
There is of course an alternative that I wouldn't recommend be implemented in the the real world.
Since vector graphics tend to be complicated for those less mathematically inclined, and raster graphics tend to waste memory, there is one alternative.
Since images tend to have certain colours grouped together (eg the CC monitor, loads of black pixels grouped in a square), you can save on the information required by treating the image as groups of pixels instead of single points. That way, if you want to shade an entire line of pixels, instead of doing each one individually, have a function that says shade the pixels from x5 to x10 at y6, which is the same as setting 5 points (10 numbers) but instead doing it all at once (using 3 numbers). And when I say line, I don't mean treating it as an actual line, I mean a line of pixels.
Thus, such a method would be a simple half way between raster and vector.

In a way it would be like autoshapes in paint.

Have functions that draw the following shapes:
-Horizontal Line
-Vertical Line
-Filled Square
-Empty Square

And you could save on data without any nasty complicated equations.
Any objections?
GopherAtl #70
Posted 29 September 2012 - 06:44 PM
I really don't know what's so nasty or complicated about line( x1, y1, x2, y2 ), which is the basic method for vector graphics… the logo language adds the idea of angles to that, but even that doesn't involve complex math. Logo is an example of something you can do with vector graphic though, not a proposed interface for them.
Pharap #71
Posted 29 September 2012 - 07:12 PM
I really don't know what's so nasty or complicated about line( x1, y1, x2, y2 ), which is the basic method for vector graphics… the logo language adds the idea of angles to that, but even that doesn't involve complex math. Logo is an example of something you can do with vector graphic though, not a proposed interface for them.
the nasty bit is figuring out how to express the line in pixels (writing code to decide which pixels the line intersects, not forgetting to account for scaling and angles)
dimitriye98 #72
Posted 30 September 2012 - 08:55 AM
Ok, then hide my buffering in the java implementation, that can't be too hard?
Honestly, I am absolutely sure that buffered raster graphics are the way to go. Ok, so you implement un-buffered vector graphics. Then some smartass makes raster graphics by making tons of 1 pixel length lines on the screen. Have you achieved anything? If you make buffered raster graphics, that same smartass can try to make vector graphics. And he'll succeed, because while raster graphics cannot be expressed in any reasonable way using vector graphics, vector graphics can EASILY be implemented using raster graphics.
immibis #73
Posted 30 September 2012 - 10:50 AM
There is of course an alternative that I wouldn't recommend be implemented in the the real world.
<snip>
You've just described a limited subset of vector graphics.
dimitriye98 #74
Posted 01 October 2012 - 06:01 AM
You know, all I have to do is bump this thread every so often, the topic so controversial that the thread floats at the top of the forum for weeks at a time.
robhol #75
Posted 01 October 2012 - 07:57 AM
I actually think this would be very nice. If we get this, then boom! suddenly, graphical OSes/shells :)/>/>

Personally, I'd want something basic that allows you to draw shapes possibly text. Sending the instructions instead of an entire bitmap would be likely to save some space if it's not insanely complicated. Either way, there are compression algorithms that could help diminish the traffic.
Pharap #76
Posted 02 October 2012 - 09:26 PM
I actually think this would be very nice. If we get this, then boom! suddenly, graphical OSes/shells :(/>/>

Personally, I'd want something basic that allows you to draw shapes possibly text. Sending the instructions instead of an entire bitmap would be likely to save some space if it's not insanely complicated. Either way, there are compression algorithms that could help diminish the traffic.

The best way would be to divide the CCcomputer screen up into a number divisible by 8 so that each 'pixel' can be represented by a single bit, eg if the screen was an 8x8 grid of pixels, it would take just 2 java integers to track the data (assuming my sources are corrent and Java integers take 2bytes, I could be wrong, Java's memory usage isn't as clearly laid out as C#). Logically, 2 integers per computer object shouldn't be a massive increase in network traffic. Especially when you consider that a string holding just one word would use more than that. Of course 8x8 isn't much, but it's better than nothing, and even if it was a 16x16 grid, that would be about 8 integers, which still isn't a hugely massive amount. I don't know how much memory strings take up in Java, but I'm pretty sure that the string "Java uses 2 bytes per integer" already exceeds the memory use of 8 integers. I could be wrong, but that's what I'd guess the situation is.
immibis #77
Posted 03 October 2012 - 03:22 AM
I actually think this would be very nice. If we get this, then boom! suddenly, graphical OSes/shells :(/>/>

Personally, I'd want something basic that allows you to draw shapes possibly text. Sending the instructions instead of an entire bitmap would be likely to save some space if it's not insanely complicated. Either way, there are compression algorithms that could help diminish the traffic.

The best way would be to divide the CCcomputer screen up into a number divisible by 8 so that each 'pixel' can be represented by a single bit, eg if the screen was an 8x8 grid of pixels, it would take just 2 java integers to track the data (assuming my sources are corrent and Java integers take 2bytes, I could be wrong, Java's memory usage isn't as clearly laid out as C#). Logically, 2 integers per computer object shouldn't be a massive increase in network traffic. Especially when you consider that a string holding just one word would use more than that. Of course 8x8 isn't much, but it's better than nothing, and even if it was a 16x16 grid, that would be about 8 integers, which still isn't a hugely massive amount. I don't know how much memory strings take up in Java, but I'm pretty sure that the string "Java uses 2 bytes per integer" already exceeds the memory use of 8 integers. I could be wrong, but that's what I'd guess the situation is.

You can't do very much in 8x8 pixels.
Xfel #78
Posted 03 October 2012 - 08:34 AM
And you are wrong, java integers take 4 byte. And a string takes for byte for the length integer and two byte for each character.
Cloudy #79
Posted 03 October 2012 - 11:59 AM
With the upcoming background colour support, you could emulate pixels to some extent.
PixelToast #80
Posted 03 October 2012 - 02:57 PM
And you are wrong, java integers take 4 byte. And a string takes for byte for the length integer and two byte for each character.
well actually minecraft stores its own font table of 16x16 making it only one byte per character, although notch could have forgot to convert it to a byte before sending
Pharap #81
Posted 05 October 2012 - 04:29 AM
And you are wrong, java integers take 4 byte. And a string takes for byte for the length integer and two byte for each character.
Well it would help if that were better documented.
But this just makes the point clearer, all that flying around, you could easily just treat the bits as booleans and you'd easily manage the data transfer with minimal extra network traffic compared to what's already involved.
And I must say, they are right about Java, it is incredibly verbose compared to other languages.
Also I'm assuming that's meant to say 'a string takes four bytes for the length integer' instead of 'a string takes for byte for the length integer'.

You can't do very much in 8x8 pixels.

No, you can't, but it's better than nothing. You could probably go up to 32x32 and not notice any major traffic, maybe even more.

Unless of course you were stupid enough to make a massive grid of computers and have them all constantly changing pixels at once, but it's like creating a fort of tnt and lighting it, you know it's stupid and only do it in the case that you are trying to be stupid on purpose.