C-Berry: Rechtecke zeichnen
Und weiter geht’s mit dem C-Berry-Display. Diesmal werden Rechtecke gezeichnet.
Genutzt wird der Befehl wie folgt:
tft_rect x1 y1 x2 y2 color modus
x1,y1: Ecke oben links, gültige Werte: x1 0…319, y1 0…239
x2,y2: Ecke unten rechts, gültige Werte: x2 0…319, y2 0…239
color: Farbe, mit der das Rechteck gezeichnet wird
modus: 0 – nicht gefüllt, 1 – gefüllt zeichnen
Auch hier ist es so, dass das Rechteck komplett gefüllt gezeichnet wird.
UPDATE:
Auch dieser Quellcode und die dazugehörige Datei zum Download sind aktualisiert. Es können jetzt auch ungefüllte Rechtecke gezeichnet werden.
Quellcode:
#include <stdio.h> #include <stdlib.h> #include "RAIO8870.h" #include "tft.h" int main (int argc, char *argv[]){ if(!bcm2835_init()){ printf("Kann Display nicht initalisieren. Abbruch!"); exit(1); } if( argc < 7 || argc > 7 ){ printf("tft_rect: Error, check arguments! Use x1 y1 x2 y2 color mode\n"); exit(1); } int x1=atoi(argv[1]); int y1=atoi(argv[2]); int x2=atoi(argv[3]); int y2=atoi(argv[4]); int col=atoi(argv[5]); int mode=atoi(argv[6]); if( x1 < 0 || x1 > 319 || x2 < 0 || x2 > 319){ printf("tft_rect: Error, check parameter x1/x2! x1,x2: 0...319\n"); exit(1); } if( y1 <0 || y1 > 239 || y2 < 0 || y2 > 239){ printf("tft_rect: Error, check parameter y1/y2! y1,y2: 0...239\n"); exit(1); } if( col < 0 || col > 255){ printf("tft_rect: Error, color out of range! color: 0...255!\n"); exit(1); } if( mode < 0 || mode > 1 ){ printf("tft_rect: Error, use mode=0 or mode=1!\n"); exit(1); } Draw_Square (x1, y1, x2, y2); Text_Foreground_Color ( col ); if( mode==0 ){ RAIO_StartDrawing ( SQUARE_NONFILL ); } else { RAIO_StartDrawing ( SQUARE_FILL ); } return 0; }
Und hier die Datei zum Runterladen.