graphics

How to select a line

谁说我不能喝 提交于 2019-12-17 17:07:57
问题 So I'm trying to figure out how to implement a method of selecting lines or edges in a drawing area but my math is a bit lacking. This is what I got so far: A collection of lines, each line has two end points (one to start and one to end the line) The lines are drawn correctly on a canvas Mouse clicks events are received when clicking the canvas, so I can get the x and y coordinate of the mouse pointer I know I can iterate through the list of lines, but I have no idea how to construct an

Reducing size of vectorized contourplot

只谈情不闲聊 提交于 2019-12-17 16:53:37
问题 I would like to include a filled contour plot to a pdf document (for example a TeX document). Currently I am using pyplot s contourf, and saving to pdf with pyplot s savefig. The problem with this is that the size of the plots becomes rather big as compared to a high resolution png . One way to reduce the size is of course to reduce the number of levels in the plot, but too few levels gives a poor plot. I'm searching for a simple way to for example let the colors of the plot be saved as a png

How to change x,y origin of canvas to bottom left and flip the y coordinates?

邮差的信 提交于 2019-12-17 16:34:23
问题 I have a bunch of data points that I would like to two-way bind to points on a canvas. The points assume larger y values are reflected in an upwards direction like most math graphs. How do I change the x,y origin of the canvas to the bottom left corner and reverse it's interpretation of the y coordinate? (I would like to stay in XAML) 回答1: <Canvas> <Canvas.LayoutTransform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX=".5" CenterY=".5" /> </Canvas.LayoutTransform> </Canvas> 回答2: I tried the

java/swing: converting a text string to a Shape

倾然丶 夕夏残阳落幕 提交于 2019-12-17 16:27:56
问题 I want to convert some arbitrary text to a Shape (java.awt.Shape) and then stroke/fill the Shape to draw it. How can I do this? 回答1: Hm I did not know the answer to this but after a bit tweaking and poking around in with Eclipse content assist i found this which seems to be what you need: EDIT: i changed to code to change the way the string is displayed which is the reason you asked what you asked :) Try it. It renders the string with red color and a dashed outline import java.awt.BasicStroke

Which format for small website images? GIF or PNG? [closed]

大憨熊 提交于 2019-12-17 16:13:53
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . When doing small icons, header graphics and the like for websites, is it better to use GIFs or PNGs? Obviously if transparency effects

Coloring boxplot outlier points in ggplot2?

吃可爱长大的小学妹 提交于 2019-12-17 15:58:06
问题 How can I color the outlier points in ggplot2? I want them to be the same color as the boxplot itself. colour= is not enough to do this. Example: p <- ggplot(mtcars, aes(factor(cyl), mpg)) p + geom_boxplot(aes(colour=factor(cyl))) I want to color the outliers by factor(cyl) as well. This does not work: > p <- ggplot(mtcars, aes(factor(cyl), mpg)) > p + geom_boxplot(aes(colour=factor(cyl), outlier.colour=factor(cyl))) 回答1: In order to color the outlier points the same as your boxplots, you're

How to set a transparent background of JPanel?

核能气质少年 提交于 2019-12-17 15:39:42
问题 Can JPanel s background be set to transparent? My frame is has two JPanel s: Image Panel and Feature Panel . Feature Panel is overlapping Image Panel . The Image Panel is working as a background and it loads image from a remote URL. On Feature Panel I want to draw shapes. Now Image Panel cannot be seen due to Feature Panel's background color. I need to make Feature Panel background transparent while still drawing its shapes and I want Image Panel to be visible (since it is doing tiling and

Calculating pixel size on an iPhone

人盡茶涼 提交于 2019-12-17 15:36:46
问题 Is there a way in the iPhone SDK to calculate the size (in millimeters) of a single pixel? 回答1: Well, the size of a pixel is a constant. The screen size of a current iPhone or iPod touch 2" x 3" (50.8 mm x 76.2 mm) and the resolution is 320 x 480 pixel. 50.8 / 320 (or 76.2 / 480) => the size of 1 pixel is 0.15875 mm x 0.15875 mm 回答2: Answering the question as asked about the size of pixels: Pixel size on an iPhone and iPod Touch The earlier iPhones (pre-iPhone 4) Apple iPhone Technical

Given a set of points, find if any of the three points are collinear

独自空忆成欢 提交于 2019-12-17 15:33:11
问题 What is the best algorithm to find if any three points are collinear in a set of points say n. Please also explain the complexity if it is not trivial. Thanks Bala 回答1: If you can come up with a better than O(N^2) algorithm, you can publish it! This problem is 3-SUM Hard, and whether there is a sub-quadratic algorithm (i.e. better than O(N^2)) for it is an open problem. Many common computational geometry problems (including yours) have been shown to be 3SUM hard and this class of problems is

fast algorithm for drawing filled circles?

徘徊边缘 提交于 2019-12-17 15:27:00
问题 I am using Bresenham's circle algorithm for fast circle drawing. However, I also want to (at the request of the user) draw a filled circle. Is there a fast and efficient way of doing this? Something along the same lines of Bresenham? The language I am using is C. 回答1: Having read the Wikipedia page on Bresenham's (also 'Midpoint') circle algorithm, it would appear that the easiest thing to do would be to modify its actions, such that instead of setPixel(x0 + x, y0 + y); setPixel(x0 - x, y0 +