graphics

Affine transformation

I am trying to solve the below problem. I don't have much knowledge in Affine transformations. Could someone help me answer this question: Find a 3x3 matrix representing a 2D affine transformation of homogeneous coordinates (i.e. every point [x,y] is represented as a column vector [x, y, 1]), which transforms a square [0,0],[1,0],[1,1],...

Sun Raster images: Why 1 byte row padding when width is odd?

This may be waaay to specific for SO, but there seems to be a dearth of info on the sun raster standard. (Even JWZ is frustrated by this!) Intro: The Sun raster standard says that rows of pixels have padding at the end such that the number of bits in a row is a factor of 16 (i.e. an even number of bytes). For example, if you had a 7-p...

How do I generate a contour graph?

How do I generate a contour graph like this: It's easy enough if the points are on a regular grid, but what if they aren't, like in my example? Is there a fairly simple algorithm to determine the color for each pixel? ...

OpenGL 3D Selection Question

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it registers a hit, but not anywhere else. That is, it is not registering depth, and if you clicked on it's square head, you could only regis...

Changing graphics when using iPhone Simulator

To increase productivity I'd like our external artists to be able to change graphics in our new iPhone game directly from the iPhone Simulator, so that he can experiment with various graphics without having the source code (for security and practical reasons). I've already provided him with the simulator, and he got a copy of the game f...

concept question about dll

My boss asks me to create a dll file using C++. The dll file needs to do the following: create a blank area in Window create some simple shapes (for an example, a rectangle) on the blank area control the locations of the shapes in the blank area I am new to C++, so please correct me if my understand is incorrect Dll is a binary file,...

Blackberry - how to resize image?

I wanted to know if we can resize an image. Suppose if we want to draw an image of 200x200 actual size with a size of 100 x 100 size on our blackberry screen. Thanks ...

Paint event handler stops executing after a few iterations

Hi, I've got a Windows Form that circulates through images which are displayed on the form as a slideshow. The way I'm doing this is to have a Panel control the size of the form it resides in, and add an event handler that draws an Image object that exists in memory. void panel_Paint(object sender, PaintEventArgs e) { if (_bShowImage...

What is equivalent to FuseKit or Tweenlite (for Flash) in Java?

I've seen another post on stackoverflow but was not really satisfied with the responses. I'm use to tweening using code in Flash. See FuseKit and Tweenlite. Are there java equivalents? This processing library is the closest that I've found. ...

Java Graphics Font - How to make sure the characters lie in particular area?

I have an Image. On the bottom portion of the image, I would like to create a colored strip say, of height 100. I am already done with creating the strip and I can basically write strings in that portion (e.g. copyright of the image etc). The following is my method. public static BufferedImage captionMyImage(BufferedImage sourceImage) {...

Drawing Vector Graphics Faster

In my application I want to draw polygons using Windows Create Graphics method and later edit the polygon by allowing the user to select the points of the polygon and allowing to re-position them. I use moue move event to get the new position of the point to get the new coordinates of the point being moved and use Paint event to re-draw...

Gwt Graphics and ClickHandler

Hi, I am using gwt graphics and gwt dnd for a program. I have a button which when clicked creates a circle at specified position on the panel and the circle is draggable. For dragging i have used gwt-dnd. I have also added a click handler to the circle which when click should print "ERD Circle". Here is the code layout: Button b = ne...

Ruby Support for SVG

Is there some library or helper to produce SVG graphics with Ruby? I googled a bit and found many, but all seem to be dusty and very incomplete… Does anyone know about some nice, reliable alternative? ...

why PaintComponent event in Java happen everytime I use its Graphics Event?

Consider this code: public class StateChartPanel extends JPanel { private LightContext LC; public StateChartPanel(LightContext lc){ LC=lc; } public void paintComponent( Graphics G ){ super.paintComponent( G ); LC.DrawStateChart((Graphics2D)G); } } StateChartPanel is a panel ...

How can I fill a GraphicsPath with overlapping curves?

Using .NET's System.Drawing.Graphics GDI stuff, I have a shape consting of two arrays of points. They are the red and green pixels in the image below. Now I am trying to fill the interior of this shape with a color. Drawing it as simple lines works just fine. Like this: g.DrawCurve(Pens.Red, points1); g.DrawCurve(Pens.Green, p...

C# GDI Invert Graphics flipped on the X axis

I am drawing a series of Points using the Graphics class. I am reading from a Point array. For whatever reason the rendered image is upside down (flipped on the X axis). Is there a simple way to tell the Graphics class to draw "upside down" ? Many thanks. ...

Draw a polygon in C

Hi, i need to draw a polygon of "n" sides given 2 points (the center and 1 of his vertex) just that i suck in math. I have been reading a lot and all this is what i have been able to figure it (i dont know if it is correct): Ok, i take the distance between the 2 points (radius) with the theorem of Pythagoras: sqrt(pow(abs(x - xc), 2) +...

How to select a line

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 ...

Given a start and end point, and a distance, calculate a point along a line

Looking for the quickest way to calculate a point that lies on a line a given distance away from the end point of the line: void calculate_line_point(int x1, int y1, int x2, int y2, int distance, int *px, int *py) { //calculate a point on the line x1-y1 to x2-y2 that is distance from x2-y2 *px = ??? *py = ??? } Thanks fo...

rotate shape java2d without losing its origin

protected void paintComponent(Graphics g) { Graphics2D gr = (Graphics2D) g.create(); // draw Original image super.paintComponent(gr); // draw 45 degree rotated instance int aci=-45; gr.transform(AffineTransform.getRotateInstance(Math.toRadians(aci))); super.paintComponent(gr); //translate rotated instanc...