0

I need to port this codehttp://www.pahgawks.com/blog/fire-particles-for-html5-canvas/ from css and javascript to Android. in this code if change this line

stage.fillStyle = "rgba("+(260-(particles[i].life*2))+","+((particles[i].life*2)+50)+","+(particles[i].life*2)+","+(((max-particles[i].life)/max)*0.4)+")";

to:

stage.fillStyle = "rgba("+255+","+50+","+0+","+0.4+")";

see fire with yellow and red and white color but in Android I see just red color

paint.setColor(Color.argb(102,255,50,0);

but I have problem with paint.setColor(Color.argb(alpha,red,green,blue)) and rgba css in the css code we see a color read yellow and white that created in fire.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

In your Java code, you have a static color (Color.argb(102, 255, 50, 0)) when it is dynamically set in JavaScript (based on particles[i].life and max value).

Try using these value in your Java code too, in order to see all the colors.

Gaëtan
  • 11,912
  • 7
  • 35
  • 45
0

Don't know why Android choose to use #ARGB color layout instead of canonical #RGBA color layout. Here comes a news of hex value handling in the coming Android P.

Android P apps enable the draft CSS Color Module Level 4 behaviour for handling 4 and 8 hex digit CSS colors.

CSS Color Module Level 4 has been supported by Chrome since release 52, but WebView currently disables the feature because existing Android applications were found to contain 32 bit hex colors in the Android ordering (ARGB), which would cause rendering errors.

For example, the color #80ff8080 is currently rendered in WebView as opaque light red (#ff8080) for apps targeting pre-Android P SDKs. The leading component (which would be interpreted by Android as the alpha component) is currently ignored. If an app targets P or above, this will be interpreted as 50% transparent light green (#80ff80).

KAlO2
  • 838
  • 11
  • 13