graphics

create images clickable on jpanel

≯℡__Kan透↙ 提交于 2019-12-12 20:24:02
问题 How i can add icon (car, earth or other) image that can be clickabel by user? i want to add them on an jpanel with overrided paint method. 回答1: Just use a JLabel with an icon. Then add a MouseListener to listen for clicks. JLabel label = new JLabel(yourIcon); // probably an ImageIcon label.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { System.out.println("Click at: " + e.getPoint(); } }); 回答2: The easiest way is to add an Icon to a JButton, then you can use an

Find an image in an image C#

我是研究僧i 提交于 2019-12-12 19:17:16
问题 I have a scan of a document (a form actually) filled with some handwritten infos. I have a bitmap of the form empty. how can i "cancel" the printed form to extract the handwritting only. I use C#... Thanks Jonathan 回答1: What you want to do is subtract the empty form image from the image of the form with handwriting in it. This will give you a reasonable image of the handwriting alone. Please note that this will not register the images. Registration will line them up so that they are at

WPF game with click to move written in C#

邮差的信 提交于 2019-12-12 18:43:00
问题 I'm attempting to move a grid of labels to the position of my mouse, like movement in an adventure game. Ideally I'd delete and redraw them on the way there. But, for now I just want to figure out how to convert int to thickness or pointtoscreen. So far I have: player.XMove = (int)Mouse.GetPosition(Application.Current.MainWindow).X; player.YMove = (int)Mouse.GetPosition(Application.Current.MainWindow).Y; I've tried converting player.XMove and player.YMove to thickness and storing it as a

R save images to create animation of plot incrementally generated with large number of points

只愿长相守 提交于 2019-12-12 18:34:54
问题 I'm trying to create an animation based on a scatter plot that is incrementally built up over time. The use case is that I have a database of about 2 million points with timestamps for each, and want to generate frames that show all the points at or before a specific date. Without saving the images, I'm able to do this by first calling plot() , and then having a for loop that incrementally draws the data for each successive day using the points() function. When I try to save images using the

How do I create an NSAffineTransform with a skew effect?

亡梦爱人 提交于 2019-12-12 17:48:11
问题 I'm quite new to drawing in Cocoa, and working on an experimental app involving a hexagonal grid. In order to simplify this, I want to skew the coordinate system so that the Y axis is rotated 30 degrees to the left. I came across this in Apple's Cocoa Drawing Guide, which indicates it is possible: Combining a non-uniform scaling transform with a rotation transform can also give your content a skewed effect. However, I cannot understand how this would work, or locate any examples. How can I

Draw frequency density histogram in R

怎甘沉沦 提交于 2019-12-12 17:25:53
问题 Using R, can anyone show me how to draw a simple histogram with no gaps between the bins of the following data :- Class Width Freq. Dist 0 <= x < 5 0.2 5 <= x < 15 0.1 15 <= x < 20 1.2 20 <= x < 30 0.4 30 <= x < 40 0.4 So I want the X axis to go from 0-5,5-15,15-20,20-30 and 30-40 with the bars drawn appropriately. Thanks in advance ! 回答1: How about this one? breaks <- c(0,5,15,20,30,40) counts <- c(0.2, 0.1, 1.2, 0.4, 0.4) barplot(counts, names=sprintf("[%g,%g)", breaks[-length(breaks)],

Java Graphics: Each time it repaints, i get a blackflash

瘦欲@ 提交于 2019-12-12 17:11:03
问题 I'm pretty new to the java draw functions, but I have a sample histogram that I build. on button click, i have it rebuilding the histogram with random values. However, every time i hit the button to repaint, i get a black flash before it redraws. I remember hearing this was pretty common and the fix had something to do with buffering. Any advice? 回答1: The first thing you do when you draw is clear your canvas. The flash you see is the blank canvas as things get drawn. If you were to slow it

OpenGL glGetTexImage2d type parameter?

て烟熏妆下的殇ゞ 提交于 2019-12-12 17:02:12
问题 reading the docs i see that the glGetTexImage2d() function has a 'type' parameter. The docs say that the type parameter "specifies the data type of the pixel data" and gives some examples of types such as GL_INT, GL_BYTE, etc. but what does it mean precisely when the image format is GL_RGBA and GL_INT ? is it an int for each channel? or an int for the whole color? and if it's an int for th whole color, then isn't that really the same as GL_BYTE ? since there's 4 bytes in an int which makes

Drawing Graphics is too slow

ぃ、小莉子 提交于 2019-12-12 15:42:43
问题 So, I have this project, and you can draw images in it. I wanted people to be able to draw on it, but at first it was too slow when I was using repaint() So i used the repaint(Rectangle r) tool. It's better, but still not the speed i was looking for. Here is the code: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class DrawingPad extends JPanel implements MouseListener,MouseMotionListener,ListSelectionListener{ public Color[][] picture =

draw graphics outside of paint method

会有一股神秘感。 提交于 2019-12-12 15:15:37
问题 private void draw_shape() { Graphics g = getGraphics(); g.drawLine(0, 0, 100, 100); repaint(); } In paint method only those graphics are drawn which is a part of paint method because of which I wanted to draw shapes outside of paint method. This code draws the line but it immediately disappeares, I don't understand why this is happening. please help 回答1: This doens't work because you are getting the current Graphics outside of the Swing repaint thread. Basically: you get the current Graphics