diff --git a/README.md b/README.md index d1cf20d..060a67e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,9 @@ For example, for apps running on a Mac/PC/Linux, it is usually set to `host`, wh If you are building for Nerves, it will use `cairo-fb` + Previous versions of `scenic_driver_local` would use `bcm` (Broadcom Manager) for any of `rpi`, `rpi0`, `rip2`, `rpi3`, and `rpi3a` and `drm` for `bbb` and `rpi4`. + You can explicitly use these by setting `SCENIC_LOCAL_TARGET=bcm` or `SCENIC_LOCAL_TARGET=drm`, **but these options are being deprecated**. Please try the default of `SCENIC_LOCAL_TARGET=cairo-fb` as this should work universally on any Nerves target. diff --git a/c_src/device/cairo/cairo_script_ops.c b/c_src/device/cairo/cairo_script_ops.c index e26fa3e..ee1f807 100644 --- a/c_src/device/cairo/cairo_script_ops.c +++ b/c_src/device/cairo/cairo_script_ops.c @@ -322,7 +322,8 @@ static void draw_sprite(scenic_cairo_ctx_t* p_ctx, cairo_rectangle(p_ctx->cr, sprite.dx, sprite.dy, sprite.dw, sprite.dh); cairo_scale(p_ctx->cr, sprite.dw / sprite.sw, sprite.dh / sprite.sh); - cairo_fill(p_ctx->cr); + cairo_clip(p_ctx->cr); + cairo_paint_with_alpha(p_ctx->cr, sprite.alpha); cairo_restore(p_ctx->cr); } diff --git a/c_src/device/nvg/nvg_script_ops.c b/c_src/device/nvg/nvg_script_ops.c index 1f2ceec..8237030 100644 --- a/c_src/device/nvg/nvg_script_ops.c +++ b/c_src/device/nvg/nvg_script_ops.c @@ -223,7 +223,7 @@ void script_ops_draw_text(void* v_ctx, // see: https://github.com/memononen/nanovg/issues/348 static void draw_image(NVGcontext* p_ctx, sid_t id, - const sprite_t s) + const sprite_t sprite) { float ax, ay; NVGpaint img_pattern; @@ -236,20 +236,20 @@ static void draw_image(NVGcontext* p_ctx, int iw,ih; nvgImageSize(p_ctx, p_image->image_id, &iw, &ih); - // Aspect ration of pixel in x an y dimensions. This allows us to scale + // Aspect ratio of pixel in x and y dimensions. This allows us to scale // the sprite to fill the whole rectangle. - ax = s.dw / s.sw; - ay = s.dh / s.sh; + ax = sprite.dw / sprite.sw; + ay = sprite.dh / sprite.sh; // create the temporary pattern img_pattern = nvgImagePattern(p_ctx, - s.dx - s.sx*ax, s.dy - s.sy*ay, + sprite.dx - sprite.sx*ax, sprite.dy - sprite.sy*ay, (float)iw*ax, (float)ih*ay, - 0, p_image->image_id, 1.0); + 0, p_image->image_id, sprite.alpha); // draw the image into a rect nvgBeginPath(p_ctx); - nvgRect(p_ctx, s.dx, s.dy, s.dw, s.dh); + nvgRect(p_ctx, sprite.dx, sprite.dy, sprite.dw, sprite.dh); nvgFillPaint(p_ctx, img_pattern); nvgFill(p_ctx); diff --git a/c_src/scenic/script.c b/c_src/scenic/script.c index aa3e6fa..3a1661d 100644 --- a/c_src/scenic/script.c +++ b/c_src/scenic/script.c @@ -317,10 +317,11 @@ void render_script(void* v_ctx, sid_t id) .dx = get_float(p, i + 16), .dy = get_float(p, i + 20), .dw = get_float(p, i + 24), - .dh = get_float(p, i + 28) + .dh = get_float(p, i + 28), + .alpha = get_float( p, i + 32 ) }; - i += 32; + i += 36; } script_ops_draw_sprites(v_ctx, id, count, sprites); free(sprites); diff --git a/c_src/scenic/script_ops.c b/c_src/scenic/script_ops.c index 17ed51c..181eb6c 100644 --- a/c_src/scenic/script_ops.c +++ b/c_src/scenic/script_ops.c @@ -222,10 +222,12 @@ void log_script_ops_draw_sprites(const char* prefix, const char* func, log_level for (int i = 0; i < count; i++) { log_message(level, "%s %s: index: %d %{" "s: {{%.1f,%.1f},{%.1f,%.1f}}, " - "d: {{%.1f,%.1f},{%.1f,%.1f}}" + "d: {{%.1f,%.1f},{%.1f,%.1f}}, " + "alpha: %.1f}" "}", prefix, func, i, sprites[i].sx, sprites[i].sy, sprites[i].sw, sprites[i].sh, - sprites[i].dx, sprites[i].dy, sprites[i].dw, sprites[i].dh); + sprites[i].dx, sprites[i].dy, sprites[i].dw, sprites[i].dh, + sprites[i].alpha); } } diff --git a/c_src/scenic/script_ops.h b/c_src/scenic/script_ops.h index ce21202..760038a 100644 --- a/c_src/scenic/script_ops.h +++ b/c_src/scenic/script_ops.h @@ -76,6 +76,7 @@ typedef struct { float dy; float dw; float dh; + float alpha; } sprite_t; typedef struct {