0
\$\begingroup\$

How do I create some circle - like the one on the image - in Java, and in various colors?

enter image description here

I would like to make more of these circles to fly from specific position to random direction.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I don't know android specifically, but if you are using OpenGL ES, you can use a shader to make this work. First create a image like this in black color. Then use a color tint.

Image Right click here and select save

Now use a fragment shader to draw this texture. The code looks like this.

#ifdef GL_ES
    precision mediump float;
#endif

varying vec2 texCoords;

uniform vec4 color;
uniform sampler2D image;

void main()
{
    vec4 texel = texture2D(texCoords, image);

    gl_FragColor = vec4(texel.rgb + color.rgb, texel.a * color.a);
}

This uses additive blending, and hence using an image with black color is very important. You can then draw this image using this shader at any scale you want.

Hope this helps.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .