@HomineLudens, thanks, but this not work for me... I still get zeros...
As i write - current (here) function is useless in project, need only to explain question :3
I have function which should 'cut' sprite into 9 pieces only having left
, right
, top
& bottom
values...
So i need some value to be calculating in middle sections, like:
Example:
Sprite looks like this (|
& -
is shows divider of areas) and called sprite
:
```
|.1|...2|..3| left area is 2x1, middle 4x1 and right is 3x1 (top = 1, left = 2, right = 3 and middle calculated from 9 - 2 - 3
|..|....|...| left is 2x2, middle (calculated) 4x2, right 3x2
|.4|...5|..6| height here is calculated from sprite.height - top - bottom
|..|....|...| left is 2x2, middle in 4x2 and right is 3x2
|.7|...8|..9|
Ist 9x5 sprite (dots as pixels, number also pixels showing area number) |
& -
is sprite and areas borders.
And i have this function (just to explain, not working one):
init = function()
some('sprite', 2, 3, 1, 2)
end
some = function (sprite, left, right, top, bottom)
w = sprite.width
h = sprite.height
//now assign arrays as [width, height] for pieces (9 pieces in total)
left_top = [left, top] //Area 1
left_bottom = [left, bottom] //Area 7
right_top = [right, top] //Area 3
right_bottom = [right, bottom] //Area 9
//Here we cut
left & right for width from sprite width to get middle parts width
//and top & bottom from sprite height to get middle parts height
middle_width = w - left - right
middle_height = h - top - bottom
left_border = [left, middle_height] //Area 4
right_border = [right, middle_height] //Area 6
top_border = [middle_width, top] //Area 2
bottom_border = [middle_width, bottom] //Area 8
middle = [middle_width, middle_height] //Area 5
end
After proper work we should get this values:
w = 9
h = 5
left_top = [2, 1]
left_bottom = [2, 2]
right_top = [3, 1]
right_bottom = [3, 2]
middle_width = 4
middle_height = 2
left_border = [2, 2]
right_border = [3, 2]
top_border = [4, 1]
bottom_border = [4, 2]
middle = [4, 2]
So i need to get actual sprite width & height.