Ce programme montre comment il est possible de dessiner les figures géométriques suivantes :
#include <MLV/MLV_all.h> // // Attention ! // Pour pouvoir compiler ce programme sous windows et sous macintosh, // il faut, pour la déclaration du main, respecter strictement la syntaxe // suivante : // int main(int argc, char *argv[]){ // // Créé et affiche la fenêtre // MLV_create_window( "beginner - 2 - shapes", "shapes", 640, 480 ); // // Dessine des cercles, ellipses, rectangles, lignes et points // MLV_draw_circle( 20, 20, 10, MLV_COLOR_PURPLE ); MLV_draw_filled_circle( 50, 20, 10, MLV_COLOR_BROWN ); MLV_draw_ellipse( 100, 20, 30, 10, MLV_COLOR_CYAN ); MLV_draw_filled_ellipse( 170, 20, 30, 10, MLV_COLOR_PINK ); MLV_draw_rectangle( 10, 50, 40, 20, MLV_COLOR_BLUE ); MLV_draw_filled_rectangle( 70, 50, 40, 20, MLV_COLOR_GREEN ); MLV_draw_line( 120, 50, 160, 90 , MLV_COLOR_WHITE ); MLV_draw_point( 10, 110, MLV_COLOR_RED ); // // Dessine une courbe de Bézier avec ses sommets // int coordonnee_x[4] = { 10, 50, 90, 130 }; int coordonnee_y[4] = { 150, 190, 150, 190 }; MLV_draw_bezier_curve( coordonnee_x, coordonnee_y, 4, MLV_COLOR_RED ); MLV_draw_circle( coordonnee_x[0], coordonnee_y[0], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee_x[1], coordonnee_y[1], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee_x[2], coordonnee_y[2], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee_x[3], coordonnee_y[3], 3, MLV_COLOR_GREEN ); //Dessine un polygone avec ses sommets int coordonnee1_x[4] = { 200, 240, 320, 280 }; int coordonnee1_y[4] = { 150, 190, 190, 150 }; MLV_draw_filled_polygon( coordonnee1_x, coordonnee1_y, 4, MLV_COLOR_BLUE ); MLV_draw_polygon( coordonnee1_x, coordonnee1_y, 4, MLV_COLOR_RED ); MLV_draw_circle( coordonnee1_x[0], coordonnee1_y[0], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee1_x[1], coordonnee1_y[1], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee1_x[2], coordonnee1_y[2], 3, MLV_COLOR_GREEN ); MLV_draw_circle( coordonnee1_x[3], coordonnee1_y[3], 3, MLV_COLOR_GREEN ); // // Affiche du texte // MLV_draw_text( 10, 120, "Juste au dessus de cette ligne, il y a un pixel rouge.", MLV_COLOR_MAGENTA ); // // Met à jour l'affichage. // MLV_actualise_window(); // // Attend 10 secondes avant la fin du programme. // MLV_wait_seconds( 10 ); // // Fermer la fenêtre // MLV_free_window(); return 0; }