bdf2sfd

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

polygon.c (789B)


      1 /*
      2  * bdf2sfd 1.1.6
      3  * Copyright (c) 2019-2021, 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  * SPDX-License-Identifier: BSD-2-Clause
     13  */
     14 
     15 #include <stdint.h>
     16 #include <stdio.h>
     17 
     18 void
     19 polygon(uint32_t row, uint32_t mask, uint32_t width,
     20     float x, float y, float xlength, float ylength) {
     21 	for (size_t column = 0; column < width; column++) {
     22 		if ((row & (mask >> column)) != 0) {
     23 			x = column * xlength;
     24 			fprintf(stdout, "%f %f m 1\n"
     25 					" %f %f l 1\n"
     26 					" %f %f l 1\n"
     27 					" %f %f l 1\n"
     28 					" %f %f l 1\n",
     29 					x, y,
     30 					x, y - ylength,
     31 					x + xlength, y - ylength,
     32 					x + xlength, y,
     33 					x, y);
     34 		}
     35 	}
     36 }