|
I assume you have a game loop in your project - if you do, then all you need to do is put a simple check into the loop to determine whether your game has paused or not. If you are in a pause, then the loop does no processing.
|
|
|
|
|
I am using graphics to create a speed meter.
To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width).
How is it possible to draw this line?
|
|
|
|
|
Hi,
a circle with radius r at the origin is represented by x*x + y*y = r*r
an ellips with big radius r at the origin is represented by x*x + a*a*y*y = r*r
where a (a factor larger than 1) is the ratio between the large radius (along the x-axis) and the small radius (along the y-axis).
So basically an ellips is a circle where you reduce y to y/a, and for each point (x,y) that would sit on the circle, the point (x, y/a) would sit at the corresponding location on the ellips.
To visualize: paint a circle on a sheet of paper, now tilt the sheet around a horizontal line: the circle becomes an ellips and all vertical dimensions shrink by the same factor.
Depending on what you want exactly, this might be all you need. When angles are involved, it gets a little bit more complex.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thank you for explaining this. Seems not to hard.
But my question is indeed about angles.
If you would like to take a gast look to this picture so you understand what I'm making:
http://technology.amis.nl/blog/wp-content/images/postReadSpeedSpeedo.jpg[^]
The thing I want to make is an arrow like that based on an angle. The shape of the arrow is not a big deal, it's about the angle and how to know the length of the arrow.
|
|
|
|
|
Well, that image shows a circle, if all you want to do is compress or stretch it in one dimension, then just do that by multiplying one coordinate by a constant factor. Give it a try in an app such as Photoshop by changing one component of the image size (uncheck "keep aspect ratio" or whatever they called it).
The one situation where you would need angle stuff is where you would want an arrow moving at a constant angular speed in the ellips (which would not then be a constant angular speed in the corresponding circle).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Yes, you're totaly true that I can use a photoshop-like program.
But I really want to calculate it on my own.
The picture is created by code, everything has to be configurable, for instance: the hight, the width, the amount of arrows and where the arrows point to.
The problem is that the width is not always equal to the height. So that's the only problem I have. I know it is possible because it's allready solved by microsoft (Graphics.drawPie).
I hope that you can tell me how to calculate this eclipse like with the only variables you have: the angle, the width, the height.
|
|
|
|
|
Still having a hang-over from mardi gras?
I explained how ellipses work. I gave you the math.
I suggested you look at your picture, when Photoshop stretches it, so you don't have to create or modify any code to see and maybe understand how a scale transform turns a circle into an ellipse.
By now you should realize all it takes is adding a scale factor to your Graphics code, either explicitly or by providing a ScaleTransform or Matrix.
For me this topic is closed.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Lol yeah it's the beer :P.
I didn't realize it was just about adding the scale factor , now I do.
And I thought you suggested to stretch the picture in photoshop, just for visualisation.
Thank you for your help
|
|
|
|
|
|
IF:
Xo, Yo - the center of the ellipse
Rx, Ry - the two radius'
alpha - is the angle in radians!!!
Calculate:
X = Xo + Rx*cos(alpha);
Y = Yo + Ry*sin(alpha);
Draw:
a line from (Xo,Yo) to (X,Y)
*In case you have a circle, then Rx=Ry = R of circle
|
|
|
|
|
Btw, if you want to implement as it was on the picture, I would highly recommend using a circle, because otherwise the length of the hands will vary, which is not realistic.
|
|
|
|
|
Hi all,
This is with reference to an old message posted by me which you can find here
http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^]
For the past one year this piece of code which Mr.Mark gave me; satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour mode. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.
|
|
|
|
|
How many bits per pixel (what's the pixel format)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
8 bit per pixel in RGB format.I have three arrays of unsigned char for each R,G and B values.
|
|
|
|
|
So do you mean 24 bits per pixel? There's no 8bpp RGB format for Windows bitmaps...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
To create the DIBSection, you can drop the palette and change the bmiHeader.biBitCount:
BITMAPINFO *bm = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO)];
bm->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bm->bmiHeader.biWidth = 176;
bm->bmiHeader.biHeight = 144;
bm->bmiHeader.biPlanes = 1;
bm->bmiHeader.biBitCount = 24;
bm->bmiHeader.biCompression = BI_RGB;
bm->bmiHeader.biSizeImage = 0;
bm->bmiHeader.biXPelsPerMeter = 0;
bm->bmiHeader.biYPelsPerMeter = 0;
bm->bmiHeader.biClrUsed = 0;
bm->bmiHeader.biClrImportant = 0;
BYTE *pBitmapBits;
HBITMAP hBitmap = ::CreateDIBSection(NULL, bm, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
if (hBitmap)
{
::DeleteObject(hBitmap);
}
delete[] (BYTE *)bm;
jossion wrote: I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays
The pixel data (pointed to by pBitmapBits) will now be a RGBTRIPLE struct for each pixel:
typedef struct tagRGBTRIPLE {
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} RGBTRIPLE;
You'll need to take the individual RGB component bytes from the arrays and
pack them in the RGBTRIPLE format - BGRBGRBGR...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I would suggest:
bm->bmiHeader.biHeight = -144;
instead of
bm->bmiHeader.biHeight = 144;
When height is positive, the bitmap is bottom-up oriented.
In 99% our bitmap sources are up-bottom oriented.
|
|
|
|
|
That's fine....as long as the OP remembers to adjust his/her
direct pixel access calculations accordingly
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i used the gluTessCallback() function to draw polygon, i can draw it in one computer, but can not draw in another computer, the two computer has diffrent graphic card. what is the matter, and how can resolve the question?
thanks
|
|
|
|
|
Hello ~
Can i ask Some question abo ut zedgraph here??
anyway this is my first question in code project ^^
and i can't english well plz comprehension my writing
let's start question
now My company Project Using Zedgraph.dll ver:5.1.4(maybe)
in the Project using zedgraph namespace
and i complete Drawing the Graph
only user X axis, Y axis
data is X[30] , T[30] <-- this data is ReadlTime data and Changing 3sec
Graph is Drawing but 3sec draw the Line, and 6sec draw the Line.. so on
Time is Gone...Line is so Many Many and i don't want it
for example)
0sec
3sec Draw the Line~~~~ Having data X[30] , T[30](data always chaging every
3sec)
and i want clear the line <-- this is i want
6sec Draw the Line~~~~ Having data X[30] , T[30](data always chaging every 3sec)
so on.....
how do i clear the Line ??
check this out my source
private void CreateGraph(double[] X, double[] T) //제드그래프 생성 (X,Y값을 가져옴)
{
GraphPane myPane = zgc.GraphPane;
// Set the titles and axis labels/;/l
myPane.Title.Text = "My Test Date Graph";
myPane.XAxis.Title.Text = "X";
myPane.YAxis.Title.Text = "Y";
// Make up some data points from the Sine function
PointPairList list = new PointPairList();
for (int i = 0; i < X.Length; i++)
{
list.Add(X[i], T[i]);
}
/*
for (double x = 0; x < 36; x++)
{
double y = Math.Sin(x * Math.PI / 15.0);
list.Add(x, y);
}
*/
// Generate a blue curve with circle symbols, and "My Curve 2" in the legend
LineItem myCurve = myPane.AddCurve("내부온도", list, Color.Blue,
SymbolType.Circle);
myCurve.Line.Fill = new Fill(Color.White, Color.Red, 45F);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Fill the axis background with a color gradient
myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
// Fill the pane background with a color gradient
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
// Calculate the Axis Scale Ranges
zgc.AxisChange();
Refresh();
|
|
|
|
|
You'll have a better chance getting an answer if you ask on either the official ZedGraph[^] site or the article here[^] on CodeProject.
Cheers,
Drew.
|
|
|
|
|
Hello friends,
Recenty i have started working on flash MX.
I have designed a flash registration page,after entering the details and clicking on the submit button i am redirecting it to a HTML page.HTML page is similar to the flash registration page.
This HTML page is hosted in sm application,through the getURL method i am passing all the field values to the HTML registartion page.These fields get populated in the HTML page.
In the hosted HTML page i have a submit button on clicking of this the user is redirected to the login page and the datas are stored in a database.
My problem is can i redirect to login page and also store the data in database.How can i use the HTML registartion page submit buttons action in action script so that i am redirected to loging page.
Can any one help me
Thanks in advance.
|
|
|
|
|
I’ve got problem with using GDI on top of OpenGL in Windows Vista. I’ve found that if GDI graphic would be drawn before any drawing operation of OpenGL than everything what was drawn by GDI would be cleared and would be drawn everything what was drawn by OpenGL before and after. It looks like OpenGL is drawn in separate buffer which after each calling of glFlush function drawn on a screen while clearing what was drawn by GDI. One of easiest solution of the problem is to draw any GDI objects after drawing OpenGL elements, but appears the same problem when the screen spitted on 4 sides. After drawing of one screen, drawing of OpenGL elements next screen clearing GDI objects previous screen. I tried to draw everything on the screen and the copy everything to memory buffer using CDC::BitBlt and then draw this buffer using OpenGL function glDrawPixels. But I found that GDI objects are drawn after exit from CView::OnDraw function, means catch of screen using CDC::BitBlt at the end of CView::OnDraw function do not include GDI objects.
Other case is to draw GDI objects to memory and the draw them by using OpenGL functions did not tested. I am trying to find much easiest way to solve the problem.
Please, help to solve the problem.
|
|
|
|
|
Hi,
Im using DirectX.AudioVideoPlayback.dll in my C# project to play both audio and video. But some problems are facing.
1. Video.Dispose() or Audio.Dispose() methods are not working correctly. Even I disposed the video object used it is not freeing all resources used. I tried to delete the file that is used by the video object to play video after disposing it. But windows shows that 'File is already in use'. It only freeing resource after closing the application. This is a major Issue.
2. Video.Ending event is not firing always.
Any help will be appreciated. Thanks in advance
Sibin Sunny
|
|
|
|