graphics

Why does my MouseListener not increment a variable in sequential order?

拥有回忆 提交于 2019-12-12 05:48:14
问题 In my Class X I have extended JPanel and implemented MouseListener , MouseMotionListener int numPoints = 0; Point controlPoints[] = new Point[10]; public void MousePressed (MouseEvent arg0) { if (numPoints < 5) controlPoints[numPoints] = arg0.getPoint(); numPoints++; } * When I System.out.println(numPoints); * output after 3 CLICKS; 0 0 2 2 3 3 5 WHY Does it not INCREMENT by 1, 2 ,3 ??? output (for numPoints) (first mouseclick) 1 2 ***I will provide more information if necessary. Thanks for

Transparent TextBox - OnPaint not firing when changin text

纵然是瞬间 提交于 2019-12-12 05:47:29
问题 My control properly starts as transparent, but once I enter text, it's going to a regular white background. If I move my mouse over the control, it fires the OnPaint again, and is able to draw the control with text correctly. How can I get it to paint the transparent background when text is being entered? Default: Directly after entering text: After moving mouse over, to force OnPaint to fire: ref class CustomTextBox : System::Windows::Forms::TextBox { public: CustomTextBox() { SetStyle

Combine two graphics objects in Java

旧城冷巷雨未停 提交于 2019-12-12 05:36:44
问题 I got two Graphics objects, is it possible to combine them into one? The answer of Hovercraft Full of Eels is useful, but not what I meant. Say I have two Graphics objects, private Graphics gr1 and private Graphics gr2 . Now, how should I merge them in the paintComponent(Graphics) method to draw them to my (for example JPanel)? The question is not at all about images, but about mere Graphics objects. Sorry, the first paragraph was misleading. Edit: In response to Hovercraft Full of Eels: If

Get Data from OpenGL glReadPixels(using Pyglet)

…衆ロ難τιáo~ 提交于 2019-12-12 05:36:40
问题 I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal format for working with. Based on some reading I've come up with this: http://dpaste.com/99206/ , however it fails with an IndexError. How would I go about doing this? 回答1: You must

php - how to find coordinates of edges in an image using imagick or other library?

吃可爱长大的小学妹 提交于 2019-12-12 05:03:28
问题 given an image composed of a plain black field with a single white rectangle inside it somewhere, how can i extract the coordinates of the rectangle ? i've googled and googled and found numerous articles on edge detection using hough lines, convolution, morphology, etc., but all of these actually edge the image or convert it in some way. i don't want to change the image, all i want to do is find where the edges are. obviously, i could simply iterate over the entire width+height of the image

Using Draw again vs Repaint

荒凉一梦 提交于 2019-12-12 04:56:34
问题 I'm trying to figure out if the repaint method does something that we can't do ourselves. I mean,how are these two versions different? public class Component extends JComponent { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(0,0,20,10); g2.draw(r); r.translate(5,5); g2.draw(r); } } and public class Component extends JComponent { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 =

How do I redraw things when my JFrame is restored (deiconified)?

孤街醉人 提交于 2019-12-12 04:56:27
问题 I have a very basic little JFrame with JToggleButtons and subclassed JPanels that know how to draw what I want them to draw. Selecting a button causes an oval to appear in the corresponding panel. Unselecting the buttons makes the drawings disappear. Unfortunately, minimizing (iconifying) and then restoring (deiconifying) causes any drawn shapes to disappear. So I need to trigger redrawings manually. The problem is that I can only get the redrawing done (that is, I only see it) if I show a

Find rectangle boundary point at an angle from point that is not in the middle of the rectangle

◇◆丶佛笑我妖孽 提交于 2019-12-12 04:52:39
问题 I am trying to display where, in a rectangle, is player aiming in my game. He's in such a square: I found an algorithm to find rectangle point by angle, applied it and the results were wrong (real game screenshot): I soon realized this is because player is not in the center of the rectangle. So I replaced the center point in the algorighm with my point. But the result is just shifted point by constant distance: So I guess my current algorithm needs more than just one change. My code: function

Move circle around jpanel using keylistener

久未见 提交于 2019-12-12 04:48:29
问题 Ok so i'm attempting to create a Jpanel that creates a circle which can then be moved around the screen. I've been going back and forth for awhile and can't seem to figure out how to get the actual thing to move for me. package astroidlab; import java.awt.BorderLayout; import javax.swing.JFrame; public class MainFrame { public static void main(String[] args) { //components JFrame jf = new JFrame(); PaintObjects po = new PaintObjects(); jf.setLayout(new BorderLayout()); jf.add(po, BorderLayout

Rotating icosahedron with circles located at every vertex in three.js

守給你的承諾、 提交于 2019-12-12 04:45:30
问题 I have an icosahedron mesh which I am rotating and then adding circle geometries and setting their location to each vertex at every frame in the animation loop. geometry = new THREE.IcosahedronGeometry(isoRadius, 1); var material = new THREE.MeshBasicMaterial({ color: wireframeColor, wireframe: true }); isoMesh = new THREE.Mesh(geometry, material); scene.add(isoMesh); Set each circle geometries location as the icosahedron mesh rotates: function animate() { isoMesh.rotation.x += 0.005; isoMesh