bdf2sfd

BDF to SFD converter, allowing to vectorize bitmap fonts
Log | Files | Refs | README | LICENSE

polygon.c (743B)


      1 /*
      2  * bdf2sfd 1.1.3
      3  * Copyright (c) 2019-2020, Frederic Cambus
      4  * https://github.com/fcambus/bdf2sfd
      5  *
      6  * Created:      2019-11-21
      7  * Last Updated: 2020-03-30
      8  *
      9  * bdf2sfd is released under the BSD 2-Clause license
     10  * See LICENSE file for details
     11  */
     12 
     13 #include <stdint.h>
     14 #include <stdio.h>
     15 
     16 void
     17 polygon(uint32_t row, uint32_t mask, uint32_t width,
     18     float x, float y, float xlength, float ylength) {
     19 	for (size_t column = 0; column < width; column++) {
     20 		if ((row & (mask >> column)) != 0) {
     21 			x = column * xlength;
     22 			fprintf(stdout, "%f %f m 1\n"
     23 					" %f %f l 1\n"
     24 					" %f %f l 1\n"
     25 					" %f %f l 1\n"
     26 					" %f %f l 1\n",
     27 					x, y,
     28 					x, y - ylength,
     29 					x + xlength, y - ylength,
     30 					x + xlength, y,
     31 					x, y);
     32 		}
     33 	}
     34 }