Skip to content

Commit

Permalink
revert export_png and rename export_screenshot (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
tehn authored May 9, 2023
1 parent e0f1185 commit 52f9080
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/core/screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ _norns.screen_circle = function(x, y, r)
_norns.screen_arc(x, y, r, 0, math.pi*2)
end

--- export png
--- export screenshot
-- @param filename: saved to dust/data/(script)/(filename).png
Screen.export_png = function(filename) _norns.screen_export_png(norns.state.data..filename..'.png') end
Screen.export_screenshot = function(filename) _norns.screen_export_screenshot(norns.state.data..filename..'.png') end

--- display png
-- @param filename
Expand Down
5 changes: 5 additions & 0 deletions matron/src/hardware/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ double *screen_text_extents(const char *s) {
}

extern void screen_export_png(const char *s) {
CHECK_CR
cairo_surface_write_to_png(surface, s);
}

extern void screen_export_screenshot(const char *s) {
CHECK_CR
static cairo_surface_t *png;
static cairo_t *temp; // for bg fill
Expand Down
1 change: 1 addition & 0 deletions matron/src/hardware/screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern void screen_clear(void);
extern void screen_close_path(void);
extern double *screen_text_extents(const char *s);
extern void screen_export_png(const char *s);
extern void screen_export_screenshot(const char *s);
extern void screen_display_png(const char *filename, double x, double y);
extern char *screen_peek(int x, int y, int *w, int *h);
extern void screen_poke(int x, int y, int w, int h, unsigned char *buf);
Expand Down
15 changes: 15 additions & 0 deletions matron/src/weaver.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static int _screen_clear(lua_State *l);
static int _screen_close(lua_State *l);
static int _screen_text_extents(lua_State *l);
static int _screen_export_png(lua_State *l);
static int _screen_export_screenshot(lua_State *l);
static int _screen_display_png(lua_State *l);
static int _screen_peek(lua_State *l);
static int _screen_poke(lua_State *l);
Expand Down Expand Up @@ -463,6 +464,7 @@ void w_init(void) {
lua_register_norns("screen_close", &_screen_close);
lua_register_norns("screen_text_extents", &_screen_text_extents);
lua_register_norns("screen_export_png", &_screen_export_png);
lua_register_norns("screen_export_screenshot", &_screen_export_screenshot);
lua_register_norns("screen_display_png", &_screen_display_png);
lua_register_norns("screen_peek", &_screen_peek);
lua_register_norns("screen_poke", &_screen_poke);
Expand Down Expand Up @@ -956,6 +958,19 @@ int _screen_export_png(lua_State *l) {
return 0;
}

/***
* screen: export_screenshot
* @function s_export_screenshot
* @tparam string filename
*/
int _screen_export_screenshot(lua_State *l) {
lua_check_num_args(1);
const char *s = luaL_checkstring(l, 1);
screen_export_screenshot(s);
lua_settop(l, 0);
return 0;
}

/***
* screen: display_png
* @function s_display_png
Expand Down

0 comments on commit 52f9080

Please sign in to comment.