How to draw Center gradient in Libgdx of android
the following effect
I haven't skilled in OpenGL of Libgdx...
Thanks!
Probably the best way will be a PNG with transparency and loading the Texture from a Texture or TextureAtlas on the code. After that, adapt the position (setPosition) and scale (setScale) and you will have a similar efect on the screen.
You can create Circle, Rectangle,...but gradients. I don't think so. Check libGDX wiki.
Related
I am looking to dynamically create (bezier) curves in Android using Canvas and Paint. I can easily do nice curves with setStrokeWidth or doing a more complex polygon/path.
But how can I make the gradient follow the curve like in this example? LinearGradient in either direction would not give the same feel.
In some parts of the curve there is a narrower gradient as well.
Is it made by some inner shadow or maybe just redrawing lots and lots of curves?
I'm afraid curving the gradient is not possible using the built-in gradient classes (LinearGradient, RadialGradient, SweepGradient). It's possible to draw lots of curves, but that would basically mean writing the curved gradient yourself. :)
(And the shading of the surface looks a bit even more subtle to me, resembling a 3D render.)
I've been trying to figure out how to draw a transparent rectangle with rounded corners and border with no avail.
Being new to andengine, I'm wondering if it is possible at all. Can someone please provide some pointers or help with a link to a sample. Wasn't able to find any when searching over the internet.
There already Rectangle class in andengine..
Rectangle rec=new Rectangle(x,y,width,height,....);
For transparency:
rec.setAlpha(0):
Attach to your scene, if you are using rectangle as physics object like used for collision then create box body from PhysicsFactory.createBoxBody();
scene.attachChild(rec);
Instead of using a Rectangle can you use a Sprite. Just create an image in Photoshop or another program, apply some transparency and export as .png. Then just load the image as Sprite.
Using OpenGL ES, there seem to be two viable options for rounded rectangles:
Manually draw the shape using trig. (This is what I'm currently doing.)
Use a a texture or group of textures that scale appropriately, such as 9-Slice Scaling
The problem with the first option is that antialiasing does not come for free, and if you are aiming for compatibility with a wide array of devices, one can't count on OpenGL antialiasing hints to actually work on the hardware. So you're left with choppy-looking rounded rectangles, especially for small ones, and the performance overhead of making another vertex array draw call. I would like to switch away from this
The second option (9-Slice or 9-Patch) seems to be the go-to method for UI rounded rect elements, but there is surprisingly little information out there about implementing 9-patching in OpenGL ES.
What I would like is: an efficient strategy for rendering antialiased rounded rectangles in OpenGL ES with adjustable border widths, border colors and fill colors. Any suggestions?
What you want is essentially a technique called Edge Anti-Aliasing.
It is described very well in this answer: OpenGL ES iPhone - drawing anti aliased lines
Just apply the transparent vertexes at outmost borderline of your rectangle.
This is my first question...
I've a square (triangle strip) with a texture (.png).
This .png have smooth corners like a play card.
The four extremities (corners) are transparent.
When draw the square, in the corners, i see the white color of the shape.
(Like a background behind the texture)
My question is:
How can i draw a transparent color for the shape, but mantain the color of the texture with a full apha?
(If i set transparent colors.... then also the texture become transparent)
How can i separate the two contexts?
Thanks in advance.. and sorry for my bad english.
First of all, you must use a texture format with alpha channel.
Then if you are using fixed function pipeline, you must enable blending.
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
If you are not using fixed function pipeline, please share the fragment shader code; and a little more details on how you are using it.
So I'd like to be able to draw a circle where I can specify the amount of circle drawn as shown in the following diagram.
AS an opengl newbie I'm not really sure how to approach this.. I've previously drawn full circles using GL_TRIANGLE_FAN
You already know how to draw a circle using a triangle fan. Now you just have to calculate the angles of the cutoff corners, use those as the beginning and end of the arc and place the hub of the triangle fan at the middle of the cutoff edge.
you could use a glScissor test to cut off the parts of the circle that you don't want.
http://www.khronos.org/opengles/sdk/1.1/docs/man/glScissor.xml