دوستان سلام
احتیاج فوری به کمک شما دوستان عزیز دارم لطفا متن زیر رو با حوصله بخونید
salam.
yek tasvire voroodi ba format jpg ke shamele sheklhaye mosalas va dayere va yek chand zeli(polygon) k daraye pas zamineye sefid va dore ashkal range meshki bashad.karbar yeki az ashkale tasvir ra entekhab mikonad va ba mouse ruye yek noghteye delkhah az shekle entekhabi entekhab mikonad k an shekl shoroo be por shodan (rang shodan) mikonad va dar nahayat tasvire khorooji k namayesh dade mishavad an shekle entekhabi ra rangi (por shode) namayesh midahad.
b zabane c++ va ba Opengl bayad neveshte shavad.2ta algoritme por kardane ashkale hendesi boundery filled va scanline filled hastan. az tarighe poshte (stack) ham tashkhis midahad k shekl b range meshki reside k joze shekl nist va agar dar mohite sefid rang bashad joze shekl ast vabayad dar poshte gharar girad ta por shavad(rang shavad) albatte b jaye stack mishe az tabee bazgashty ham estefade kard.
y tamrine gerafikie. 2ta source code c++ ba opengl attach kardam (rasme bazi az ashkale hendesi va taghire range pas zamine)
rasme ashkale hendesi:
#include <glut.h>// also included gl.h, glu.h
void display() {
glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer
glBegin(GL_QUADS); // Each set of 4 vertices form a quad
glColor3f(0.4f, 0.4f, 0.4f); // Red
glVertex2f(-0.7f, -0.1f); // x, y
glVertex2f(-0.1f, -0.1f);
glVertex2f(-0.1f, 0.5f);
glVertex2f(-0.7f, 0.5f);
glEnd();
glBegin(GL_TRIANGLES); // Each set of 3 vertices form a triangle
glColor3f(0.0f, 1.0f, 0.0f); // Green
glVertex2f(0.2f, -0.3f);
glVertex2f(0.8f, -0.3f);
glVertex2f(0.5f, 0.2f);
glEnd();
glBegin(GL_POLYGON); // The vertices form one closed polygon
glColor3f(0.0f, 0.0f, 1.0f); // Blue
glVertex2f(0.2f, 0.3f);
glVertex2f(0.4f, 0.3f);
glVertex2f(0.5f, 0.5f);
glVertex2f(0.4f, 0.7f);
glVertex2f(0.2f, 0.7f);
glVertex2f(0.1f, 0.5f);
glEnd();
glFlush(); // Render now
}
// GLUT runs as a Console Application
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT
glutCreateWindow("2D Shapes"); // Create a window with the given title
glutDisplayFunc(display); // Register callback handler for window re-paint
glutMainLoop(); // Enter infinitely event-processing loop
return 0;
}
Taghire range pas zamine
#include <glut.h>// also included gl.h, glu.h
void display() {
glClearColor(1.0,0.2,0.3,1.0);
glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer
glBegin(GL_LINES); // Each set of 4 vertices form a quad
glColor3f(0.0f, 0.0f, 1.0f); // Red
glVertex2f(-0.6f, 0.2f); // x, y
glVertex2f(-0.2f, 0.77f);
glEnd();
glFlush(); // Render now
}
// GLUT runs as a Console Application
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT
glutCreateWindow("2D Shapes"); // Create a window with the given title
glutDisplayFunc(display); // Register callback handler for window re-paint
glutMainLoop(); // Enter infinitely event-processing loop
return 0;
}