draw

Any java package to draw simple geometric shape?

£可爱£侵袭症+ 提交于 2019-11-27 04:48:58
问题 Does anyone have any suggestion about any lib/package to draw simple geometric, such as triangle, square? It can be saved into a png format. 回答1: You'll want to have a look at the Java 2D API: http://docs.oracle.com/javase/tutorial/2d/overview/index.html 回答2: This source uses Graphics2D of the Java 2D API to draw some simple colored shapes. For reference, here are the 32x32 images that result. import java.awt.*; import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt

How to draw a gradient line (fading in/out) with Core Graphics/iPhone?

让人想犯罪 __ 提交于 2019-11-27 04:13:35
问题 I know how to draw a simple line: CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0); CGContextMoveToPoint(context, x, y); CGContextAddLineToPoint(context, x2, y2); CGContextStrokePath(context); And I know how to do a gradient rectangle, i.g.: CGColorSpaceRef myColorspace=CGColorSpaceCreateDeviceRGB(); size_t num_locations = 2; CGFloat locations[2] = { 1.0, 0.0 }; CGFloat components[8] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; CGGradientRef myGradient =

How to use android canvas to draw a Rectangle with only topleft and topright corners round?

随声附和 提交于 2019-11-27 03:52:33
I found a function for rectangles with all 4 corners being round, but I want to have just the top 2 corners round. What can I do? canvas.drawRoundRect(new RectF(0, 100, 100, 300), 6, 6, paint); You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas . Use a path. It has the advantage of working for APIs less than 21 (Arc is also limited thusly, which is why I quad). Which is a problem because not everybody has Lollipop yet. You can however specify a RectF and set the values with that and use arc back to API 1, but then you wouldn't get to use a static (without

Android - drawing path as overlay on MapView

*爱你&永不变心* 提交于 2019-11-27 03:36:31
问题 I have a class that extends Overlay and implemments Overlay.Snappable. I have overriden its draw method: @Override public void draw(Canvas canvas, MapView mv, boolean shadow) { Projection projection = mv.getProjection(); ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); //Creating geopoints - ommited for readability Path p = new Path(); for (int i = 0; i < geoPoints.size(); i++) { if (i == geoPoints.size() - 1) { break; } Point from = new Point(); Point to = new Point(); projection

java draw line as the mouse is moved

自作多情 提交于 2019-11-27 03:00:27
问题 I would like to add a feature to my application which allows the user to draw a straight line by clicking the mouse at the start location and releasing it at the end location. The line should move as the mouse moves until it is finally released; similar to the way that a line can be drawn using the Microsoft Paint application. How can implement this so that the line is repainted as it moves without repainting other things that may already be drawn in that rectangular area? 回答1: Try this..

How to draw a circle with animation in android with circle size based on a value

狂风中的少年 提交于 2019-11-27 02:38:15
I want to develop a custom component which draws part of the circle based on different values. e.g draw 1/4 cirle, 1/2 circle etc. The component needs to be animated to display drawing process. The partial circle is drawn on top of a static imageview, and I plan to use two views, animated one on top of the static one. Any suggestion how to develop this? I put the screenshot for reference. Please refer to the picture, and get a feel how it looks like. Thanks! Thanks in advance. You have to draw the circle view, and after that you should create an animation to it. Creating the circle view:

How can I center Graphics.drawString() in Java?

混江龙づ霸主 提交于 2019-11-27 02:03:47
问题 I'm currently working on the menu system for my Java game, and I wonder how I can center the text from Graphics.drawString() , so that if I want to draw a text whose center point is at X: 50 and Y: 50 , and the text is 30 pixels wide and 10 pixels tall, the text will start at X: 35 and Y: 45 . Can I determine the width of the text before I draw it? Then it would be easy maths. EDIT: I also wonder if I can get the height of the text, so that I can center it vertically too. Any help is

How do I draw an arrowhead (in Android)?

强颜欢笑 提交于 2019-11-27 01:43:53
I'm fairly new to Android and have been toying around with Canvas. I'm attempting to draw an arrow but I'm only having luck with drawing the shaft, none of the arrowhead is working. I have searched a bit and found a Java example, but Android doesn't have GeneralPath or AffineTransform . Right now my code looks like the following (the arrowhead looks nothing like an arrowhead): public class DrawableView extends View { Context mContext; private int centerX; private int centerY; private int radius; private double arrLength; private double arrHeading; private int margin = 10; public DrawableView

How to draw polygons with CGPath?

99封情书 提交于 2019-11-27 01:23:53
问题 I have been reading thru the documentation however it is not immediatly clear to me how to draw a polygon using CGPath. All I need to do is to draw CGPath around something like this: __ \ \ \ \ \__\ Could anyone please provide an snippet on how to do this? Additionally I assume CGPathContainsPoint will help me determine if a point is inside such path?, or does the path have to be a solid drawing Also how can i move the cgpath around? Is this as easy as changing something like the origin just

android: quality of the images resized in runtime

拟墨画扇 提交于 2019-11-27 01:10:22
问题 I want to show images using drawBitmap() method. But before I want to resize it according screen dimensions. I have a problem with quality of result image. You can see screenshots and test code below. How can I resize images in runtime with a good quality? Thank you for solutions. Original image: alt text http://dl.dropbox.com/u/709109/gradient.png Result screenshot on device: alt text http://dl.dropbox.com/u/709109/device.png import android.app.Activity; import android.graphics.Bitmap;