Documentation de la bibliothèque MLV-3.1.0

medium/07_time.c

Ce programme affiche différentes informations de temps.

#include <MLV/MLV_all.h>
#include <stdio.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[] ){
int elapsed_time;
int seconds, minutes, hours, day, month, year, day_of_the_week;
const char* days[7] ={
"Dimanche", "Lundi", "Mardi", "Mercredi","Jeudi", "Vendredi", "Samedi"
};
const char* months[12] ={
"Janvier", "Févier", "Mars", "Avril","Mai", "Juin", "Juillet",
"Août", "Septembre", "Octobre", "Novembre", "Décembre"
};
//
// Créé et affiche la fenêtre
//
MLV_create_window( "medium - 7 - time", "time", 640, 480 );
while( 1 ){
//
// On récupère le temps écoulé depuis le debut de l'éxécution du
// programme
//
elapsed_time = MLV_get_time();
//
// On affiche l'infomration obtenue
//
10, 120,
"Temps écoulé depuis le debut du programme : %d ms",
MLV_COLOR_GREEN, elapsed_time
);
//
// On récupère la date d'aujourd'hui et l'heure courante
//
&seconds, &minutes, &hours,
&day, &month, &year,
&day_of_the_week
);
//
// On affiche les jours
//
10, 240,
"Date : %s, %.2d %s %d",
days[day_of_the_week], day, months[month], year
);
//
// On affiche l'heure
//
10, 260,
"Heure : %d h %.2d : %.2d",
hours, minutes, seconds
);
//
// On met à jour l'affichage
//
}
//
// Ferme 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_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_free_window
void MLV_free_window()
Ferme la fenêtre de la bibliothèque MLV.
MLV_update_window
void MLV_update_window()
Met à jour l'affichage de la fenêtre.
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_COLOR_GREEN
#define MLV_COLOR_GREEN
Definition: MLV_color.h:931
MLV_get_date
int MLV_get_date(int *seconds, int *minutes, int *hours, int *day, int *month, int *year, int *day_of_the_week)
Donne la date du jour (seconde/heure/jour/mois/annee).
MLV_all.h
Fichier d'entête principal incluant tous les autres fichiers entêtes de la bibliothèque MLV.
MLV_clear_window
void MLV_clear_window(MLV_Color color)
Éfface la fenêtre et la remplace par un monochrome de la couleur donnée en paramètre.
MLV_get_time
int MLV_get_time()
Renvoie le nombre de millisecondes écoulées depuis le début de l'initialisation de la bibliothèque ML...
MLV_COLOR_BLACK
#define MLV_COLOR_BLACK
Definition: MLV_color.h:379