Le module graphique permet de dessiner en mémoire des graphiques à l’aide de procédures telles que drawString, drawLine,… et de sauvegarder le « dessin » dans un fichier jpg.
Programme de demonstration
Java
Résultat : demo.jpg
Procédures et fonctions disponibles
Le module graphique est implementé dans le fichier source bc/awtswing/cbgraphique.bcj. create(graphique graphe,int largeur,int hauteur)exception proc setColor(graphique graphe,int r,int g,int b) proc setStroke(graphique graphe,int stroke) proc setFont(graphique graphe,string fonteProprietes)exception fonteProprietes: name=monospaced;style=normal;size=12; style : n g i gi normal,gras,italique,gras_italique proc drawString(graphique graphe,string data,int x,int y) proc drawLine(graphique graphe,int x1,int y1,int x2,int y2) proc drawOval(graphique graphe,int x,int y,int w,int h) proc drawCircle(graphique graphe,int x,int y,int r) proc drawRect(graphique graphe,int x,int y,int w,int h) proc drawRoundRect(graphique graphe,int x,int y,int w,int h,int arcWidth,int arcHeight) proc drawImage(graphique graphe,string cheminImage,int x,int y,int w,int h) Si w==0 et h==0 l'image n'est pas redimensionnée proc drawPolyline(graphique graphe,int[] xPoints,int[] yPoints) Draws a sequence of connected lines defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. The figure is not closed if the first point differs from the last point. proc drawPolygon(graphique graphe,int[] xPoints,int[] yPoints) Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. This method draws the polygon defined by nPoint line segments, where the first nPoint - 1 line segments are line segments from (xPoints[i - 1], yPoints[i - 1]) to (xPoints[i], yPoints[i]), for 1 <= i <= nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different. proc fillRect(graphique graphe,int x,int y,int w,int h) proc fill3DRect(graphique graphe,int x,int y,int w,int h,boolean bRaised) proc fillRoundRect(graphique graphe,int x,int y,int w,int h,int arcWidth,int arcHeight) proc fillOval(graphique graphe,int x,int y,int w,int h) proc fillCircle(graphique graphe,int x,int y,int r) proc fillPolygon(graphique graphe,int[] xPoints,int[] yPoints) Fills a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. This method draws the polygon defined by nPoint line segments, where the first nPoint - 1 line segments are line segments from (xPoints[i - 1], yPoints[i - 1]) to (xPoints[i], yPoints[i]), for 1 <= i <= nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different. proc save(graphique graphe,string cheminImage)exception cheminImage doit avoir le suffixe .jpg proc drawLigneHori(graphique g,int ligne,int largeur,string libelle,int r,int gg,int b)