Iabnduid

Páginas: 3 (660 palabras) Publicado: 10 de noviembre de 2012
/*
parabola2.cpp

Draws a parabola with horizontal axis (pg 52)
made up of line segments
*/

#include
#include

#include "resource.h"

// your path for this include may vary
#include"GraphicsFramework.h"


// Global variable to store the graphics framwork object
GraphicsFramework* PGraphics;

HWND HOutput = 0; // handle to the output control
HWND HDialog = 0;

//function to get the absolute value of an integer
int Abs(int x) {
if (x < 0) return -x;
else return x;
}

// function to get the sign (+1 or -1) of an integer
int Sign(int x) {
if (x < 0)return -1;
else return 1;
}
void DrawLine(int x2, int y2, int x1, int y1, unsigned int color)
{
COLORREF green = RGB(0, 255, 0); // green color to draw with
COLORREF purple =RGB(255, 0, 255); // purple color to draw with
int dy, dx, y, x;
// calculate changes in y and x between the points
dy = y2 - y1;
dx = x2 - x1;

// clear the scene and add an axisPGraphics->ClearScene(RGB(0, 0, 0));
PGraphics->AddAxis(RGB(150, 150, 150), 10);

if (Abs(dy) > Abs(dx)) {
// since there is a greater change in y than x we must
//loop in y, calculate x and draw
for (y=y1; y != y2; y += Sign(dy)) {
x = x1 + (y - y1) * dx / dy;
PGraphics->AddPoint(x, y, green);
}
}
else {// since there is a greater (or equal) change in x than y we must
// loop in x, calculate y and draw
for (x=x1; x != x2; x += Sign(dx)) {
y = y1 + (x - x1) * dy /dx;
PGraphics->AddPoint(x, y, green);
}
}
PGraphics->Draw();
return;

}
void DrawStuff() {
COLORREF green = RGB(0, 255, 0); // green color to draw withCOLORREF purple = RGB(255, 0, 255); // purple color to draw with

char str[32]; // string to store user input
int h, k; // parabola vertex
double a;...
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS