natiny.view.get_changed

Lua
natiny.view.get_changed(view) -> changed

Returns whether a view's rectangle is different from the one it had in the render before.

Parameters

Name Type Description
view number View handle

Returns

Type Description
boolean true when the position or the size changed, or this is the first render of the view

Example

Lua
-- rebuild an expensive picture only when its size changes
natiny.view.set_hook(map, natiny.view.HOOK_DRAW, function(self)
    local x, y, w, h = natiny.view.get_rect(self)
    if natiny.view.get_changed(self) then
        map_picture = build_map_picture(w, h)
    end
    natiny.render.texture(map_picture, x, y, w, h)
end)