diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-25 08:51:38 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-25 08:51:38 -0700 |
commit | 3d4bee26b5ce8fd8157224de97c9f2292abcdf5f (patch) | |
tree | fd0311a6a6d9e0af3edf2e33dbdabffc8ed8ab9f | |
parent | 93afa269f3fc18b40c0c86c920a1a0d565731dff (diff) |
fix sdl alpha
-rw-r--r-- | src/library_sdl.js | 6 | ||||
-rw-r--r-- | tests/sdl_canvas.c | 6 | ||||
-rw-r--r-- | tests/sdl_mouse.c | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 199af7c4..49f52a11 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -175,15 +175,15 @@ mergeInto(LibraryManager.library, { // Load SDL color into a CSS-style color specification loadColorToCSS: function(color) { var rgba = {{{ makeGetValue('color', '0', 'i32') }}}; - return 'rgba(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ',' + (1-((rgba >> 24)&255)/255) + ')'; + return 'rgba(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ',' + (((rgba >> 24)&255)/255) + ')'; }, translateColorToCSS: function(rgba) { - return 'rgba(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ',' + (1-(rgba&255)/255) + ')'; + return 'rgba(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba&255)/255) + ')'; }, translateRGBAToCSS: function(r, g, b, a) { - return 'rgba(' + r + ',' + g + ',' + b + ',' + (1-a/255) + ')'; + return 'rgba(' + r + ',' + g + ',' + b + ',' + (a/255) + ')'; }, makeSurface: function(width, height, flags, usePageCanvas, source) { diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c index aaa9d653..6c6adc2d 100644 --- a/tests/sdl_canvas.c +++ b/tests/sdl_canvas.c @@ -12,11 +12,11 @@ int main() { TTF_Font *font = TTF_OpenFont("myfont.ttf", 40); printf("Font: %p\n", font); - SDL_Color color = { 0xff, 0x99, 0x00, 0xb0 }; + SDL_Color color = { 0xff, 0x99, 0x00, 0x4f }; SDL_Surface *text = TTF_RenderText_Solid(font, "hello faint orange world", color); - SDL_Color color2 = { 0xbb, 0, 0xff, 0 }; + SDL_Color color2 = { 0xbb, 0, 0xff, 0xff }; SDL_Surface *text2 = TTF_RenderText_Solid(font, "a second line, purple", color2); // render @@ -27,7 +27,7 @@ int main() { // fill stuff SDL_Rect rect = { 200, 200, 175, 125 }; - SDL_FillRect(screen, &rect, 0x2222ff00); + SDL_FillRect(screen, &rect, 0x2222ffff); SDL_Flip(screen); diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c index a0520839..dae3f636 100644 --- a/tests/sdl_mouse.c +++ b/tests/sdl_mouse.c @@ -44,7 +44,7 @@ int main() { SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); SDL_Rect rect = { 0, 0, 600, 450 }; - SDL_FillRect(screen, &rect, 0x2244ff00); + SDL_FillRect(screen, &rect, 0x2244ffff); emscripten_run_script("simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20 emscripten_run_script("simulateMouseEvent(10, 20, 0)"); // click |