mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-17 14:47:19 +01:00
Emscripten: use cursor hotspot
the cursor's hotspot simply wasn't translated to it's CSS equivalent, yet see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor?v=example#Syntax. no explicit hotspot if (0|0) for compatibility with Edge and IE, which indeed don't support custom hot spots
This commit is contained in:
parent
bb8c3a9cc2
commit
1724313349
@ -79,7 +79,9 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
|||||||
cursor_url = (const char *)EM_ASM_INT({
|
cursor_url = (const char *)EM_ASM_INT({
|
||||||
var w = $0;
|
var w = $0;
|
||||||
var h = $1;
|
var h = $1;
|
||||||
var pixels = $2;
|
var hot_x = $2;
|
||||||
|
var hot_y = $3;
|
||||||
|
var pixels = $4;
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = w;
|
canvas.width = w;
|
||||||
@ -114,13 +116,15 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.putImageData(image, 0, 0);
|
ctx.putImageData(image, 0, 0);
|
||||||
var url = "url(" + canvas.toDataURL() + "), auto";
|
var url = hot_x === 0 && hot_y === 0
|
||||||
|
? "url(" + canvas.toDataURL() + "), auto"
|
||||||
|
: "url(" + canvas.toDataURL() + ") " + hot_x + " " + hot_y + ", auto";
|
||||||
|
|
||||||
var urlBuf = _malloc(url.length + 1);
|
var urlBuf = _malloc(url.length + 1);
|
||||||
stringToUTF8(url, urlBuf, url.length + 1);
|
stringToUTF8(url, urlBuf, url.length + 1);
|
||||||
|
|
||||||
return urlBuf;
|
return urlBuf;
|
||||||
}, surface->w, surface->h, conv_surf->pixels);
|
}, surface->w, surface->h, hot_x, hot_y, conv_surf->pixels);
|
||||||
|
|
||||||
SDL_FreeSurface(conv_surf);
|
SDL_FreeSurface(conv_surf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user