Documentation de la bibliothèque MLV-3.1.0

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 );
MLV_draw_triangle( 180, 50, 200, 50, 190, 70, MLV_COLOR_YELLOW );
MLV_draw_filled_triangle( 220, 50, 240, 50, 230, 70, MLV_COLOR_YELLOW );
//
// 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/>.
*/
MLV_COLOR_PINK
#define MLV_COLOR_PINK
Definition: MLV_color.h:1327
MLV_create_window
void MLV_create_window(const char *window_name, const char *icone_name, unsigned int width, unsigned int height)
Créé une fenêtre dont la taille, et les différents noms sont passés en paramètres.
MLV_draw_filled_circle
void MLV_draw_filled_circle(int x, int y, int radius, MLV_Color color)
Dessine un disque plein dont le centre et le rayon sont passés en paramètres.
MLV_COLOR_BROWN
#define MLV_COLOR_BROWN
Definition: MLV_color.h:1207
MLV_COLOR_WHITE
#define MLV_COLOR_WHITE
Definition: MLV_color.h:373
MLV_draw_rectangle
void MLV_draw_rectangle(int x, int y, int width, int height, MLV_Color color)
Dessine un rectangle dont la taille, la couleur et la position du sommet Nord-Ouest sont données en p...
MLV_draw_point
void MLV_draw_point(int x, int y, MLV_Color color)
Dessine un point dont les coordonnées sont passées en paramètres. Cette fonction est identique à MLV_...
MLV_COLOR_MAGENTA
#define MLV_COLOR_MAGENTA
Definition: MLV_color.h:1387
MLV_free_window
void MLV_free_window()
Ferme la fenêtre de la bibliothèque MLV.
MLV_COLOR_YELLOW
#define MLV_COLOR_YELLOW
Definition: MLV_color.h:1069
MLV_draw_line
void MLV_draw_line(int x1, int y1, int x2, int y2, MLV_Color color)
Dessine une ligne.
MLV_COLOR_RED
#define MLV_COLOR_RED
Definition: MLV_color.h:1297
MLV_update_window
void MLV_update_window()
Met à jour l'affichage de la fenêtre.
MLV_draw_filled_polygon
void MLV_draw_filled_polygon(const int *vx, const int *vy, int nb_points, MLV_Color color)
Dessine un polygone plein à partir d'une liste de sommets.
MLV_wait_seconds
void MLV_wait_seconds(int seconds)
Le programme s'intérompt pendant un nombre de secondes.
MLV_COLOR_PURPLE
#define MLV_COLOR_PURPLE
Definition: MLV_color.h:1459
MLV_draw_filled_rectangle
void MLV_draw_filled_rectangle(int x, int y, int width, int height, MLV_Color color)
Dessine un rectangle plein dont la taille, la couleur et la position du sommet Nord-Ouest sont donnée...
MLV_draw_text
void MLV_draw_text(int x, int y, const char *text, MLV_Color color,...)
Imprime un texte donné à une position et une couleur données.
MLV_draw_circle
void MLV_draw_circle(int x, int y, int radius, MLV_Color color)
Dessine un cercle à une position et un rayon spécifiés en paramètres.
MLV_draw_polygon
void MLV_draw_polygon(const int *vx, const int *vy, int nb_points, MLV_Color color)
Dessine un polygone à partir d'une liste de sommets.
MLV_COLOR_GREEN
#define MLV_COLOR_GREEN
Definition: MLV_color.h:931
MLV_draw_filled_triangle
void MLV_draw_filled_triangle(int ax, int ay, int bx, int by, int cx, int cy, MLV_Color color)
Dessine un triangle plein.
MLV_all.h
Fichier d'entête principal incluant tous les autres fichiers entêtes de la bibliothèque MLV.
MLV_draw_filled_ellipse
void MLV_draw_filled_ellipse(int x, int y, int radius_x, int radius_y, MLV_Color color)
Dessine une ellipse pleine.
MLV_draw_bezier_curve
void MLV_draw_bezier_curve(const int *vx, const int *vy, int nb_points, MLV_Color color)
Dessine une courbe de Bézier à partir d'une liste de sommets.
MLV_COLOR_BLUE
#define MLV_COLOR_BLUE
Definition: MLV_color.h:631
MLV_draw_triangle
void MLV_draw_triangle(int ax, int ay, int bx, int by, int cx, int cy, MLV_Color color)
Dessine un triangle (vide).
MLV_draw_ellipse
void MLV_draw_ellipse(int x, int y, int radius_x, int radius_y, MLV_Color color)
Dessine une ellipse.
MLV_COLOR_CYAN
#define MLV_COLOR_CYAN
Definition: MLV_color.h:775