graphics

Why does the height of the rectangles jump vary?

随声附和 提交于 2019-12-13 01:34:45
问题 Why does the height of the rectangle's jump vary? It seems to go in a cycle. First it jumps low then it doesn't jump at all then it jumps high then it doesn't jump at all. i can't figure out why as the same code is used and it is triggered by the same event. import java.awt.Color; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.KeyEvent; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyEvent; import

Using KeyListener with Java

筅森魡賤 提交于 2019-12-13 00:39:03
问题 For a homework assignment I need to create a program that essentially displays a ball and the user should be able to move it using the left and right keys. However, the program isn't responding to the keys. I don't know where the bug is, and I'd appreciate it very much if someone could help! This is the code: public class GraphicsComponent extends JComponent { Ellipse2D.Double ball = new Ellipse2D.Double(200, 400, 80, 80); public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D)

Why do my shapes and images disappear on my panel?

老子叫甜甜 提交于 2019-12-12 22:44:30
问题 I have used the paintComponent method to draw shapes on my panel. However, every time I minimize the frame or resize it, they disappear. Not sure what to add to my code. public class ShapePanel extends JPanel implements ActionListener, MouseListener{ int a,b,c,d; Graphics2D g2D; private Rectangle2D rect = new Rectangle2D(a,b,c-a,d-b); public ShapePanel(){ addMouseListener(this); setLayout(new GridLayout()); } public void paintComponent(Graphics g) { g2D = (Graphics2D) g; g2D.draw(rect);

How to get perpendicular vectors given a line segment [closed]

房东的猫 提交于 2019-12-12 22:31:31
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . How to get point A, B , C, and D? if AB and CD are perpendicular to p0p1. Assume p0A, p0B, p1C, and p1D have normalized length 回答1: The direction of the line is given by d = normalize(p1 - p0) . To calculate a perpendicular vector we can use the cross product with (0, 0, 1) . Which results in: d

TStatusBar flickers when calling Update procedure. Ways to painlessly fix this

一个人想着一个人 提交于 2019-12-12 22:18:31
问题 So, here is the discussion I have just read: http://www.mail-archive.com/delphi@delphi.org.nz/msg02315.html BeginUpdate and EndUpdate is not thi procedures I need ... Overriding API Call? I tried to get Update procedures code from ComCtrls unit, nut did not found... Maybe you could post here a code to fix thi flicker of statusbar compoent if the only text changes in it? I mean - something like TextUpdate or some kind of TCanvas method or PanelsRepaint ... ? The flickering is caused by this

Silverlight - Epic Graphical Fail (rectangle by two triangles) :(

Deadly 提交于 2019-12-12 22:18:16
问题 I want to draw rectangle by two triangles. Very simple task. But Silverlight can't handle it. <Grid x:Name="LayoutRoot" UseLayoutRounding="False" Background="White"> <Polygon Fill="Black"> <Polygon.Points> <Point X="10" Y="100"/> <Point X="100" Y="10"/> <Point X="100" Y="100"/> </Polygon.Points> </Polygon> <Polygon Fill="Black"> <Polygon.Points> <Point X="10" Y="10"/> <Point X="100" Y="10"/> <Point X="10" Y="100"/> </Polygon.Points> </Polygon> </Grid> Logicly i have to see a rectangle when i

smooth color interpolation along a “bresenham” line

早过忘川 提交于 2019-12-12 21:32:06
问题 I am trying to interpolate color along a line so that, given two points and their respective RGB values, I can draw a line with a smooth color gradient. Using Bresenham's Line Algorithm, I can now draw lines, but am not sure how to begin interpolating colors between the two end points. The following is part of the drawLine() function that works for all line whose slope are less than 1. int x_start = p1.x, x_end = p2.x, y_start =p1.y, y_end = p2.y; int dx = Math.abs(x_end-x_start), dy = Math

How do I draw transparent Rectangles using DirectX in C++?

百般思念 提交于 2019-12-12 21:16:44
问题 I want to draw objects to be partially transparent, but I don't know how. I'm using MSDN and coding in C++. The following code is how I draw a regular rectangle, but I want to draw a transparent rectangle. VOID DrawingObject::Draw() { ID2D1HwndRenderTarget *m_pRenderTarget; m_pRenderTarget->FillRectangle(RectF(10, 10, 20, 20), m_pD2DDriver->GetBrush(static_cast<DrawingColor>(m_uColorIndex)) ); } Any help or guidance is greatly appreciated. 回答1: Have a look at the Brush Interface. You can

Simple graphics API with transparency, polygons, reading image pixels?

一笑奈何 提交于 2019-12-12 21:03:29
问题 I need a simple graphics library that supports the following functionality: Ability to draw polygons (not just rectangles!) with RGBA colors (i.e., partially transparent), Ability to load bitmap images, Ability to read current color of pixel in a given coordinate. Ideally using JavaScript or Python. Seems like HTML 5 Canvas can handle #2 and #3 but not #1, whereas SVG can handle #1 and #2 but not #3. Am I missing something (about either of these two)? Or are there other alternatives? 回答1:

Graphics.TBitmap successfully decoded from a JPEG frame results in empty TDibSection after GetObject() call

泪湿孤枕 提交于 2019-12-12 21:03:10
问题 I am decoding JPEG frames to Graphics.TBitmap objects using the FastJpeg library (jpegdec.pas). The decode works fine and I print the bitmap to file for visual inspection using the TBitmap.SaveToFile() method and it looks great. I then call GetObject() using the TBitmap handle to get a TDibSection object. The TDibSection object returned does show the correct values for the top level fields (bmWidth, bmHeight, etc.) although bmBit is NIL and I find that surprising seeing as the SaveToFile()