Author Topic: Pixel Color  (Read 2985 times)

I was wondering whether it would be possible to obtain the color of a pixel at a point on the screen?
« Last Edit: May 16, 2015, 08:37:06 AM by General »

I was wondering whether it would be possible to obtain the color of a pixel at a point on the screen?
Are you just trying to get the color of a pixel so that you can use that color? Or do you want to get the color of the pixel via script to do something with it in your script? The latter isn't really possible in Blockland.

Why don't you just tell us what you're trying to do?

Are you just trying to get the color of a pixel so that you can use that color? Or do you want to get the color of the pixel via script to do something with it in your script? The latter isn't really possible in Blockland.

Why don't you just tell us what you're trying to do?
Get the color of a pixel so I can use it

Get the color of a pixel so I can use it
Yes. I read the OP. But what do you want to do with it? Give us details of exactly what you're trying to do.

More specifically, i want to get the center pixel of the screen while facing down at multiple points on a map to produce a flat image. Not sure if it's possible to do this another way on blockland at least.

Do a set of raycasts for the bricks and get the color property of the found brick.

(You can take multiple samples near each target point if you want and blend the colors if you want to be fancy)

I was thinking of doing that, but I don't think raycasts take into account the shape of the brick, but rather its bounds?

Also does anyone know whether there's a way to modify shaders to produce an isometric view?

I was thinking of doing that, but I don't think raycasts take into account the shape of the brick, but rather its bounds?
From my experience, this is true. Its one of the main aggravating factors that made me give up on my rts mod haha
Also does anyone know whether there's a way to modify shaders to produce an isometric view?
Theres not a built in way that I know of but a quick search lets me believe you can set up the camera's FOV with setFOV(45); to make it look more like you want, then make sure the camera is mounted in an applicable orientation.
« Last Edit: October 20, 2014, 01:21:57 PM by Ladios »

Theres not a built in way that I know of but a quick search lets me believe you can set up the camera's FOV with setFOV(45); to make it look more like you want, then make sure the camera is mounted in an applicable orientation.
The issue is that i'm trying to take a top-down image of a build I have, this method would work given the map was flat but unfortunately it contains rather high skyscrapers which obstruct some parts of the map due to perspective :(

Thanks much for your help though, i was beginning to question whether i'd get answers haha

If you are producing the image by a sampling of raycasts, the screen becomes less relevant. Just find the location above the city you think you would get the clearest picture from and test from there?

Example if highest building is at height 100 and the city is bounded 500x by 500 y, then you could create an (likely unreasonable) array of 2500 raycasts at elevation 101 going straight down, spaced one unit apart, to get an unobstructed ("isometric") color sampling
« Last Edit: October 20, 2014, 01:40:00 PM by Ladios »

Oh wow. Lol. I thought you were talking about doing this client sided. Like on a GUI. I guess you should have explained yourself better.

If you are producing the image by a sampling of raycasts, the screen becomes less relevant. Just find the location above the city you think you would get the clearest picture from and test from there?

Example if highest building is at height 100 and the city is bounded 500x by 500 y, then you could create an (likely unreasonable) array of 2500 raycasts at elevation 101 going straight down, spaced one unit apart, to get an unobstructed ("isometric") color sampling
Yeah I'm gonna do it this way, then write a quick program to place all the pixels together lol. Mucho thanks

Oh wow. Lol. I thought you were talking about doing this client sided. Like on a GUI. I guess you should have explained yourself better.
It was supposed to be client-sided, for the color detecion part... :I

It was supposed to be client-sided, for the color detecion part... :I
Nah that would be more tricky, and I dunno if server admins would like people being able to cheat extra information into their view, I know I never appreciated people barging on my server with that clientsided_rearview thing. As a thing accessable on a server though, i've always felt an more concise updatable map addon  would be neat.

Another interesting way of doing this I am thinking is to do the sampling based on where the character wanders. As your screen updates you randomly sample your view to create a client-sided map thats parsed together over time based on the samplings of the player's view. That would be interesting, however since all of the brick information has to be transmitted to the client anyways I think there would be an easier way of doing that.

Actually it's significantly easier than this. Sorry that I didn't get here sooner.

The GuiBitmapCtrl has a getPixelColor( x , y ) method. If you don't bind an image it'll get the pixel color of the pixel behind it. It also isn't constrained by the bounds of the object.

So..


function getPixelColor(%x, %y) {
    if(!isObject(getPixelColorObject))
        new GuiBitmapCtrl(getPixelColorObject) { position = "0 0"; extent = "0 0"; };
    return getPixelColorObject.getPixelC olor(%x, %y);
}


That should work perfectly for you.


I misunderstood your request. There's really no efficient way to serversidedly capture an image. The only way that's close to efficient is by using Badspot's built in isometric image generator and stealing the image from Blockland.us.
« Last Edit: October 20, 2014, 03:43:15 PM by $trinick »

Actually this is perfect! I can put a bitmap image over the play gui and get pixel colours from there.

Ladios' method is pretty neat though - A.C.M City