Removed Image:mapPixel(), updated doc/api.md
This commit is contained in:
@@ -220,11 +220,6 @@ position is outside of the image then 0 is returned.
|
|||||||
Sets the pixel of the image at the position `x`, `y` to `color`. If the
|
Sets the pixel of the image at the position `x`, `y` to `color`. If the
|
||||||
position is outside of the image then no change is made.
|
position is outside of the image then no change is made.
|
||||||
|
|
||||||
##### Image:mapPixel(fn)
|
|
||||||
Takes the function `fn` which is called for each pixel of the image and is
|
|
||||||
given the arguments `x`, `y` and `color`: The position of the current pixel and
|
|
||||||
its color. Each pixel will be set to the color returned by this function.
|
|
||||||
|
|
||||||
|
|
||||||
### Quad
|
### Quad
|
||||||
A rectangle used to represent the clipping region of an image when drawing.
|
A rectangle used to represent the clipping region of an image when drawing.
|
||||||
|
|||||||
20
src/image.c
20
src/image.c
@@ -301,25 +301,6 @@ int l_image_setPixel(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int l_image_mapPixel(lua_State *L) {
|
|
||||||
image_t *self = luaobj_checkudata(L, 1, CLASS_TYPE);
|
|
||||||
luaL_argcheck(L, lua_isfunction(L, 2), 2, "expected function");
|
|
||||||
int y, x;
|
|
||||||
for (y = 0; y < self->height; y++) {
|
|
||||||
for (x = 0; x < self->width; x++) {
|
|
||||||
lua_pushvalue(L, 2);
|
|
||||||
lua_pushinteger(L, x);
|
|
||||||
lua_pushinteger(L, y);
|
|
||||||
lua_pushinteger(L, self->data[x + y * self->width]);
|
|
||||||
lua_call(L, 3, 1);
|
|
||||||
self->data[x + y * self->width] = lua_tointeger(L, -1);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int luaopen_image(lua_State *L) {
|
int luaopen_image(lua_State *L) {
|
||||||
luaL_Reg reg[] = {
|
luaL_Reg reg[] = {
|
||||||
{ "new", l_image_new },
|
{ "new", l_image_new },
|
||||||
@@ -329,7 +310,6 @@ int luaopen_image(lua_State *L) {
|
|||||||
{ "getHeight", l_image_getHeight },
|
{ "getHeight", l_image_getHeight },
|
||||||
{ "getPixel", l_image_getPixel },
|
{ "getPixel", l_image_getPixel },
|
||||||
{ "setPixel", l_image_setPixel },
|
{ "setPixel", l_image_setPixel },
|
||||||
{ "mapPixel", l_image_mapPixel },
|
|
||||||
{ 0, 0 },
|
{ 0, 0 },
|
||||||
};
|
};
|
||||||
luaobj_newclass(L, CLASS_NAME, NULL, l_image_new, reg);
|
luaobj_newclass(L, CLASS_NAME, NULL, l_image_new, reg);
|
||||||
|
|||||||
Reference in New Issue
Block a user