In response to Loduwijk
Loduwijk wrote:
Shadowdarke wrote:
In the current BYOND you can mask out all but a single pixel and duplicate it as needed to make a scaled version

You can also mask out all but a single line of pixels to get an entire vertical or horizontal column. That would be better for scaling, as it would be much faster and consume less memory.

Very clever! Using 64 to 128 slice passes instead of 1024 pixel passes cuts out a great deal of the overhead, though I'd still rather do it with only 1 to 9 icon operations with all the calculations handled as non-icon data.


One note for OFD: you can go up to 160x160 pixels for a single atom, allowing you to scale a single icon up to 500%.

I have never heard of this. How exactly do you accomplish such a thing?

You can use negative pixel offsets as well, expanding a couple icons in each direction. Pixel offsets act pretty fruity beyond +/-92, so you can't go further than that. You could really push it to 224x244 pixels with +/-92 if you wanted to.

I limit myself to +/-64 (5x5 tiles) for a total size of 160x160 pixels. I had to think a bit to recall why I prefer these limits. The reason is that an atom's pixel offsets are a factor as well. If the atom's offset + the overlay offset goes beyond the limits, the display breaks. Limitting my atom offsets to 0-31 and my overlay offsets to -64 to +64 guarantees no offset related problems. (I could get away with -92 to 64, but why complicate things with lopsided images?)

Here is a quick demo so you can see for yourself:
mob
New()
..()
var/obj/O = new()
O.icon = 'base.dmi'
for(var/X = 1 to 4)
O.pixel_x = X*32
O.pixel_y = X*32
O.pixel_y = O.pixel_x
overlays += O
O.pixel_x = -X*32
O.pixel_y = O.pixel_x
overlays += O
del(O)

verb/x_offset(X as num)
pixel_x = X
In response to OneFishDown
OneFishDown wrote:
The original .zip can be found here: http://s95013793.onlinehome.us/byond/users/rob/ icon%20scaling.zip (it doesn't have a large .rsc file there)

Ah, I was wondering what you could possibly be hiding in that large rsc to make matters simpler. ;)


It scales them horizontally and vertically (separately), taking a strip of the icon and blending it to a new icon. The procs then return the list of new icons and it creates the overlays.

As I noted in my response to Loduwijk, that's a very nice solution. I didn't really think that critically about the process.
In response to Shadowdarke
I'd try doing it pixel-by-pixel if there was a way to check the color of a pixel*, then draw a box of that color. I don't know how quick those functions are, or would be.

Also, that has a problem if the box to draw goes over the edge of the icon, then it has to draw one box on each icon.

I'd guess that pixel offsets range from -128 to +127, but I've never checked that.

* This would also speed it up by ignoring blank pixels or strips.
In response to OneFishDown
OneFishDown wrote:
I'd try doing it pixel-by-pixel if there was a way to check the color of a pixel*, then draw a box of that color. I don't know how quick those functions are, or would be.

Pixel by pixel would also allow you to anti-alias the parts that aren't near a mask, though I'm not sure how well that would turn out. All my ideas on the topic are just theory.

I'd guess that pixel offsets range from -128 to +127, but I've never checked that.

That's a logical conclusion, but the limit is 92 before it starts doing very strange things. It's not a byte math error, it's something to do with BYOND's drawing routines.
In response to Shadowdarke
Shadowdarke wrote:
One note for OFD: you can go up to 160x160 pixels for a single atom, allowing you to scale a single icon up to 500%.

I have never heard of this. How exactly do you accomplish such a thing?

You can use negative pixel offsets as well, expanding a couple icons in each direction. Pixel offsets act pretty fruity beyond +/-92, so you can't go further than that. You could really push it to 224x244 pixels with +/-92 if you wanted to.

I see what you are saying now. This morning when I read your reply I thought you were talking about the size of an icon, not limits on pixel offsets. I thought perhaps you knew something that everyone else did not. ;)

Chalk it up to my state today, as I was very tired. (still am even now that it is evening)
Page: 1 2