aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_sdl.js6
-rw-r--r--tests/sdl_canvas.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index fcc7e5b9..93bf133b 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 'rgb(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ')';
+ return 'rgba(' + (rgba&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba >> 16)&255) + ',' + (1-((rgba >> 24)&255)/255) + ')';
},
translateColorToCSS: function(rgba) {
- return 'rgb(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ')';
+ return 'rgba(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ',' + (1-(rgba&255)/255) + ')';
},
translateRGBAToCSS: function(r, g, b, a) {
- return 'rgb(' + r + ',' + g + ',' + b + ')';
+ return 'rgba(' + r + ',' + g + ',' + b + ',' + (1-a/255) + ')';
},
makeSurface: function(width, height, flags, usePageCanvas, source) {
diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c
index ae617604..aaa9d653 100644
--- a/tests/sdl_canvas.c
+++ b/tests/sdl_canvas.c
@@ -12,9 +12,9 @@ int main() {
TTF_Font *font = TTF_OpenFont("myfont.ttf", 40);
printf("Font: %p\n", font);
- SDL_Color color = { 0xff, 0x99, 0x00, 0x77 };
+ SDL_Color color = { 0xff, 0x99, 0x00, 0xb0 };
- SDL_Surface *text = TTF_RenderText_Solid(font, "hello orange world", color);
+ SDL_Surface *text = TTF_RenderText_Solid(font, "hello faint orange world", color);
SDL_Color color2 = { 0xbb, 0, 0xff, 0 };
SDL_Surface *text2 = TTF_RenderText_Solid(font, "a second line, purple", color2);