I was asked to work on this shape called the Squircle. It is very similar to a rounded rectangle or square with rounded corners. However that's not the desired shape. How can I achieve this?
I came up with my own solution, and today is a very simple library, here's the link.
https://github.com/MicroRJ/android_superellipse
Here are a few sample images of my particular output.
You can create Shape Drawable and set corner radius.
Related
I'm asking about how can I Rotate (Y-axis) a picture in ImageView programmatically in kotlin or java for android Studio as showed below
I searched a lot.. Googled it.. but no answers
Here an example:
Another Example:
To rotate your image on the Y-Axis, All you have to do is set this on your imageView. Keep in mind this is for Java.
imageView.setRotationY(25);
Your image will rotate just like you wanted, you can change the float value if you want.
I have two rectangles in Libgdx but they seem not to overlap right. Is there a way so I see where the rectangles are?
I have this:
Body2.setSize(72, 72);
Body2.setPosition(20, squiddyY);
Body.setHeight(Assets.sprite_body.getHeight());
Body.setPosition(pipe1X, Assets.sprite_body.getY()+Assets.sprite_body.getHeight());
if(Body2.overlaps(Body)){
squiddyY=1000;
}
but it looks like body is half size of sprite_body(or the Y is just too low?) and is a bit behind it (the X location of sprite_body is pipe1X). Maybe i'm putting it at the wrong place so visualizing it will really help.
You can draw shapes with ShapeRenderer
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html
The link includes examples.
I am using the LibGDX orthographic camera class to handle different screen sizes and it works pretty well for me. The only issue I have is the border around the screen when the device doesn't stretch to scale.
I don't mind a border that much, the only thing that bothers me is the color of the border. I think it would look much nicer if it was black instead of white. Any way to change that?
Also I posted another question about android touch handling that was never answered. If someone could answer that, that would be great. I don't want to have to ask it again, I don't want to seem spammy. My Question
When your camera view is smaller than screen you probably just need to change clear color of GL.
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,1);
Black clear screen. Thats all you need.
I am currently working on Code based drawables in Android but ran into a little bump, I have a rectangular LinearLayout that I want to set it's drawable to a circle I have reasons for doing this in code so please do not recommend xml, I did some searching on Google and was only really able to come up with the opposite an inscribed rectangle in circle and that is not what I need.
So let's say I have a rectangle of 80 wide and 120 in length(these are random guesses, and need to be able to change) what would be the formula I need to use to determine the largest circle I can create in this rectangle and when I say circle let me be more specific I do not want a oval I want a full circle.
So this question is simply what would be the proper formula needed for this. Thank you for your time =)
int Radius = Math.min( width, height ) / 2;
That is the largest radius circle that can fit in the rectangle
Well I'm back again and feel slightly stupid on this one,
The answer came to me during good old shower time (doesn't it always). I was thinking about my problem in the 3d senses something I regretfully did not do before I posted on here. It occurred to me that if I want to make a for lack of better term a perfect circle that the diameter of this circle would always be constricted by the smaller side of the rectangle and then you can account for that to center the circle.
So in my scenario my circle with be 80 in diameter because it would be restricted by the width of the rectangle. Sorry for wasting your time have a good day =)
I am trying to draw rounded diagonal lines in Java using the ACM library.
A very complicated method would involve drawing a diagonal line, scaling it up to increase its width, drawing an arc on the top of that line with respect to the angles it is rounded.
From the picture you linked to, it looks like you want lines with round end-caps, sometimes called line-joins. I don't know the ACM library too well, but looking at the docs for it, it seems like you could achieve that look by using a GPen with an image that is just a filled-in circle. You could call the setLocation(x,y) and then drawLine(dx, dy) methods on it.
I've never used ACM but looking at the javadoc you might want to consider using shapes rather then lines. So for example, you can draw a rectangle of width using GPolygon then draw circles on the ends using GOval
So something like: draw a polygon around the points [100,0],[0,100],[10,110],[110,10], then draw two circles of size 10 at 0,110 and 110,0. If those shapes are all filled with the same color, they should look like one solid.