Documentation de la bibliothèque MLV-2.0.2

beginner/02_shapes.c

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_ellipse( 100, 20, 30, 10, MLV_COLOR_CYAN );
MLV_draw_rectangle( 10, 50, 40, 20, MLV_COLOR_BLUE );
MLV_draw_line( 120, 50, 160, 90 , MLV_COLOR_WHITE );
//
// 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
//
10, 120,
"Juste au dessus de cette ligne, il y a un pixel rouge.",
);
//
// Met à jour l'affichage.
//
//
// Attend 10 secondes avant la fin du programme.
//
//
// Fermer la fenêtre
//
return 0;
}
/*
* This file is part of the MLV Library.
*
* Copyright (C) 2010,2011,2012,2013 Adrien Boussicault, Marc Zipstein
*
*
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this Library. If not, see <http://www.gnu.org/licenses/>.
*/