draw smooth thin circle in java 2d graphics [duplicate] - java

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to draw a decent looking Circle in Java.
hi I drew onw circle with stroke in java by using graphics2d ...but am getting always irregular circle...I am getting circle without smooth...can u plz help me?

According to How to draw a decent looking Circle in Java:
Turning on antialiasing helps make things look better:
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
See also: Antialiasing, images, and alpha compositing in Java 2D

Related

Get Intersection of two shapes in javaFX [duplicate]

This question already has answers here:
Checking Collision of Shapes with JavaFX
(1 answer)
JavaFX Two Shapes Intersecting - Collision Method Not Working
(2 answers)
Constantly checking if a bullet has touched a node
(3 answers)
Closed 24 days ago.
Please how I get the intersection of two Circle objects where in transition in my situation the red circle and the blue .enter image description here
i try to use Shape.intersection() but doesn't work !!!

Java - Draw rectangle with two rounded corners [duplicate]

This question already has an answer here:
How to draw custom rounded rectangles in java?
(1 answer)
Closed 6 years ago.
I need to draw a rectangle with the top-left and bottom-left corners, and another rectangle with the top-right and bottom-right corners, rounded.
I know you can draw a rounded rectangle using Graphics2D#drawRoundRect, but that rounds all four corners.
I think this question haves an answer here https://stackoverflow.com/a/20321954/4443053
Basically, you need to define your own shape. I-m pretty sure you can modify that example to your needed corners.

Create wind rose android [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to create a wind rose similar to this :
The goal is to be able to update the green area based on information from a database.
The green area should take in two degrees and then create the green area between them.
Where could i start looking for a soulution ?
I have done such a compass for ios.
Besides custom views, you should be familiar with polar coordinates:
A point then is defined by (r, phi) instead of (x,y).
You need that all the time, you loop around the rose iterating with phi from 0 to 360, in steps. When you have the drawing coordinates in polar, you have to transform to x,y and draw it.
Further you will need AffineTransformations to scale the rose from a given pixel width, and height to a neutral -1, 1 range. Then drawing is easier.
Look at how to create a custom view : http://developer.android.com/training/custom-views/index.html
And keep in mind that you will have to optimize your drawing code : no object creation and rely as much as possible on java graphics primitives.
Happy coding, that's a very fun android development ahead, but a bit complex for novices.
Oh, and by the way, here you might be interested in using PorterDuff mode for translucency.
As has been mentioned, you'll likely want to implement a custom view.
In particular though, you'll want to divide the rendering into two. The background static image and the foreground dynamic image.
The foreground image could be generated using the Canvas class. It's quite easy to use once you get your head around it. The idea is that you'll be generating a bitmap using the canvas on whcih you draw. See the docs for more details:
http://developer.android.com/guide/topics/graphics/2d-graphics.html
For the actual rendering, you can use the drawArc method in the Canvas class:
public void drawArc (RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)
http://developer.android.com/reference/android/graphics/Canvas.html#drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint)
All the best!

Basic Graphics. Need help in drawing [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm just beginning to learn basic graphics, particularly drawing, and I would like to ask for suggestions on how I draw animals such as this fox.
http://www.wikihow.com/images/2/2f/Draw-a-Fox-Step-9.jpg
Do I use polygons and hard code the whole drawing? Or is there a program that allows me to input the image in it and it outputs the x and y coordinates of all the vertices that I'd need in order to draw it? Basically, what I have to do is I'd draw that fox in Java but I have to draw it on my own using shapes. I'd have to start from scratch and work my way up until I recreate the fox using Java's shapes. Any suggestions how I do this?
When people want graphics like that in their games/applications, they usually create the files in other applications and then import the image files. There are many different application to create images in, but two of the popular ones are Photoshop and Illustrator. For a free application to create images, look into GIMP.
There are a variety of different files types you can use in almost all languages and platforms. For example, .png files are particularly useful because they can have transparency. For resolution independent images people often use .svn file format.
It is rare for anyone to have the program generate the images with polygons, unless you have some type of severe constraint, there is no reason to.
Look up how to load and display image files in the language and platform of your choice.
This block'll paint the fox:
#Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
ImageIcon fox = new ImageIcon(new URL('http://i.stack.imgur.com/vJOsv.jpg'));
fox.paintIcon(this, g, x, y) // Replace x and y with the x/y coordinates
}

How to perform gradient effect in Android? [duplicate]

This question already has answers here:
Oval Gradient in Android
(5 answers)
Closed 9 years ago.
I want to perform a gradient effect that shines from bottom of the layout as appear in the following picture. Notice that it is not a regular tag with start colour and end colour because I tried those but I haven't reach to the required solution. Also I don't want to set the background with a picture because I’m concern of quality issues. Please help. Thank you.
You can't do this using XML drawables in Android. I recommend using images.

Categories

Resources