graphics

How can I bring my shape that I painted with paintComponent and clicked with a mouse to front?

走远了吗. 提交于 2020-04-16 02:51:31
问题 I have a program that painted three different shapes(circle, triangle, and square) and I try to drag them with a mouse. What I want to do is to bring to the front that shape that is clicked. Can I pass the argument together with repaint() to tell a program that for example circle that is clicked has to be painted last, or is it possible to create three different paint methods to keep track of paint ordning? Another question is my if-loop, it works just fine to drag square through circle and

How to see lines drawn in real time. Java Swing

回眸只為那壹抹淺笑 提交于 2020-04-15 04:57:28
问题 I have a small program that outputs patterns. Id like to watch the lines being drawn in real time rather than just seeing the end program output, like mine. My end result would be to produce a real time kaleidoscope effect. How would I go about this? ( Just the real time bit ) Thank you. public void paintComponent(Graphics myPen) { super.paintComponent(myPen); myPen.setColor(Color.red); int increment = 1; int count = 0; while (count < 5) { int x = 0; int y = 0; while (x < 400) { myPen

Getting pixel information from the screen quickly [duplicate]

℡╲_俬逩灬. 提交于 2020-04-10 18:50:50
问题 This question already has an answer here : Fast Pixel Search in Java (1 answer) Closed 4 years ago . I am writing an application which needs to get the colors of pixels on the screen to run different automated tests. (Yes, I know of the preexisting automated testing libraries. No, I can't use them.) Currently, I'm writing in Java and the program mostly does this: Robot r = new Robot(); for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) r.getPixelColor(i*20, j*20); The problem with this

Getting pixel information from the screen quickly [duplicate]

你离开我真会死。 提交于 2020-04-10 18:49:09
问题 This question already has an answer here : Fast Pixel Search in Java (1 answer) Closed 4 years ago . I am writing an application which needs to get the colors of pixels on the screen to run different automated tests. (Yes, I know of the preexisting automated testing libraries. No, I can't use them.) Currently, I'm writing in Java and the program mostly does this: Robot r = new Robot(); for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) r.getPixelColor(i*20, j*20); The problem with this

Getting pixel information from the screen quickly [duplicate]

ⅰ亾dé卋堺 提交于 2020-04-10 18:48:07
问题 This question already has an answer here : Fast Pixel Search in Java (1 answer) Closed 4 years ago . I am writing an application which needs to get the colors of pixels on the screen to run different automated tests. (Yes, I know of the preexisting automated testing libraries. No, I can't use them.) Currently, I'm writing in Java and the program mostly does this: Robot r = new Robot(); for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) r.getPixelColor(i*20, j*20); The problem with this

Cannonjs - Change on body position&quaternion not affecting on child shapes

自古美人都是妖i 提交于 2020-03-25 12:30:53
问题 I use cannonjs vs three.js . Ussually in three.js it is easy with 3dObject container. I added a lot of bodies and translate/rotate then in circle but now i wanna rotate them all together. Any idea... /* globals CANNON THREE GROUP1 GROUP2 GROUP3 app world scene */ /** From visual JS project */ function orbit(cx, cy, angle, p) { var s = Math.sin(angle); var c = Math.cos(angle); // translate point back to origin: p.x -= cx; p.y -= cy; // rotate point // eslint-disable-next-line no-undef xnew = p

Implementing copy, cut and paste

依然范特西╮ 提交于 2020-03-23 06:58:08
问题 I want to implement copy, cut and paste in my drawing program (copy part of an image that is selected) I don't know how to start Any Ideas? 回答1: to copy: take the selected rectangle, create a new image of that size, take a copy of the current image and place it on the new rectangle, offset by the topleft of the selected rectangle 回答2: in short there are two ways exists 1) your own clipboard 2) system-wide clipboard in second case use must use standard format for storing your data. read MSDN

Need to read width/height from graphics file with VBScript/ASP classic

六眼飞鱼酱① 提交于 2020-03-16 09:16:21
问题 I need to read a graphics file and get the width/height in VBScript (ASP). I found a package called gfxSpex that seems to be what a lot of people use but the GIFs get the width right but not the height. PNGs don't work at all as the routine is looking for the type in 0-3 and that's %PN in the .png files. Function gfxSpex(flnm, width, height, depth, strImageType) Dim strPNG Dim strGIF Dim strBMP Dim strType strType = "" strImageType = "(unknown)" gfxSpex = False strPNG = Chr(137) & Chr(80) &

How can I represent a vector equation of a line segment in C++?

眉间皱痕 提交于 2020-03-16 05:55:42
问题 I am working with computer graphics. I would like to represent a line with two end points, and, then I would like my Line2d class to have a method that returns a Vector2d object. Suppose, I have the following classes: struct Point2d { int x; int y; }; Then, I can easily represent a line segment using two points: class LineSegment2d { private: Point2d start; Point2d end; public: ... ... }; According to the definition, a vector is composed of a magnitude and a direction. class Vector2d {

Java can only display 1 image on JFrame

心不动则不痛 提交于 2020-03-05 11:46:41
问题 I am trying to display two different images on my screen. one of which is a banner that goes at the top of my JFrame , and another that I just placed randomly below the banner for testing purposes. The issue I am having is that while I can display a single image on the screen by adding an object of class WindowStructure to my window, I am not able to display more than one image at a time. Only the last image added to the window is displayed on the screen: Here is the window class: import