graphics

Connecting final and initial point in simple x-y plot (Plotting closed curve/polygon)

社会主义新天地 提交于 2019-12-30 08:41:55
问题 Say, for example, I had ... x = [1 1 2 2]; y = [1 2 2 1]; plot(x, y, 'b-'); I will get a plot with lines connecting the points (1,1), (1,2), and (2,2). Is there any way to connect the final point with the first, thus completing the square on the plot? I'm also pulling in lines of text with points, so simply adding another point 1,1 is not an option. 回答1: impoly can be useful, however, it creates a modifiable curve which is slower than plot. You can write a simple function for that: function

Connecting final and initial point in simple x-y plot (Plotting closed curve/polygon)

一世执手 提交于 2019-12-30 08:41:10
问题 Say, for example, I had ... x = [1 1 2 2]; y = [1 2 2 1]; plot(x, y, 'b-'); I will get a plot with lines connecting the points (1,1), (1,2), and (2,2). Is there any way to connect the final point with the first, thus completing the square on the plot? I'm also pulling in lines of text with points, so simply adding another point 1,1 is not an option. 回答1: impoly can be useful, however, it creates a modifiable curve which is slower than plot. You can write a simple function for that: function

Anti-aliasing in paintComponent() method

◇◆丶佛笑我妖孽 提交于 2019-12-30 07:23:11
问题 I want to print some text using the paintComponent(..) method. @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red); g.drawString("Hello world", 10, 10); } But the text is somewhat jaggy. How could you force text drawing with [anti-aliasing] in this method? Thank you. 回答1: You can set double buffering by: class MyPanel extends JPanel { public MyPanel() { super(true);//set Double buffering for JPanel } } or simply call JComponent

Drawing lines with mouse on canvas : Java awt

元气小坏坏 提交于 2019-12-30 06:27:14
问题 The attempt is to enable drawing of figures(a line for now) with mouse on the awt canvas . Iam trying out java graphics for the first time . So not sure how to go about it . This is my first attempt : package def.grafi; import java.awt.Canvas; import java.awt.Frame; import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Dra {

What is a null graphics device?

若如初见. 提交于 2019-12-30 06:16:07
问题 I'm reading the R help page for ?devAskNewPage (it was linked from ?par...ask ). I can't understand what par(ask=F) / par(ask=T) does. What do I need to read about to understand this: If the current device is the null device, this will open a graphics device. ... The precise circumstances when the user will be asked to confirm a new page depend on the graphics subsystem. Obviously this needs to be an interactive session. In addition ‘recording’ needs to be in operation, so only when the

Treemapping with a given aspect ratio

让人想犯罪 __ 提交于 2019-12-30 05:16:10
问题 I would like to create a TreeMap, using pictures to fill out the treemap rectangles. I can assume that all the pictures have the same width and height (i.e. the aspect ratio). Thus, I need a treemapping algorithm to create the rectangles with a given ratio, do I will be able to put the pictures there (and perhaps scale the pictures if I need). Could you recommend one ? 回答1: In general, a solution is not possible - Albin Sunnanbo has provided a proof by counterexample. Assuming your bounding

How to make gradient border of an image using java?

爱⌒轻易说出口 提交于 2019-12-30 04:50:08
问题 How can I make an image border as gradient. I googled a lot, but didn't find correct suggestion. Any one can help me... Any suggestion please... 回答1: This is an interesting one. I first thought that there should be a simple solution, using some Graphics#drawRoundRect call with the appropriate Paint , but it's not sooo simple. However, one solution is implemented in the following example: The image is painted as-it-is into a new image. Then the edges and corners are painted. These consist of

Invalid blending results across all browsers with HTML5 canvas

只谈情不闲聊 提交于 2019-12-30 03:46:04
问题 Summary When repeatedly drawing anything (apparently with a low alpha value) on a canvas, regardless of if it's with drawImage() or a fill function, the resulting colors are significantly inaccurate in all browsers that I've tested. Here's a sample of the results I'm getting with a particular blend operation: Problem Demonstration For an example and some code to play with, check out this jsFiddle I worked up: http://jsfiddle.net/jMjFh/2/ The top set of data is a result of a test that you can

Are GDI, GDI+ and OpenGL really obsolete/deprecated? [closed]

天大地大妈咪最大 提交于 2019-12-30 03:45:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . If you open the page "Graphics and Gaming (Windows)" on microsoft.com the last category is described as Legacy Graphics: Technologies that are obsolete and should not be used in new applications. This category includes (among others) the following APIs: GDI GDI+ OpenGL What's

Any code/library to scale down an UIImage?

≯℡__Kan透↙ 提交于 2019-12-30 03:35:05
问题 Is there any code or library out there that can help me scale down an image? If you take a picture with the iPhone, it is something like 2000x1000 pixels which is not very network friendly. I want to scale it down to say 480x320. Any hints? 回答1: This is what I am using. Works well. I'll definitely be watching this question to see if anyone has anything better/faster. I just added the below to a category on UIimage . + (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {