Newer
Older
ubScopin / sample / src / text.cpp
@Christopher W. Olsen Christopher W. Olsen on 16 May 2019 996 bytes Sample
#include <inttypes.h>

#include "line.h"
#include "pecado.h"
#include "text.h"
#include "dac.h"

extern "C" char * charset0[256];

Text text;

void Text::Char(uint8_t c, int ox, int oy, int16_t scale)
{
  int x = ox;
  int y = oy;
  int blanco;
  char *coffs;
  uint8_t encoded;

  coffs = (char *) charset0[c - 0x20];

  for (int i = 0; (encoded = *coffs); coffs++, i++) {
    x = ox + (scale * ((encoded >> 4) & 007)) / 256;
    y = oy + (scale * ((encoded & 017) - 4)) / 256;
    blanco = encoded & 0200 ? 1 : 0;

    irotate(&x, &y, ox, oy, text_angle);
    if (i == 0 || !blanco) {
      xyz.SetZ(0);
      trazador.MoveTo(x, y);
    }
    else {
      xyz.SetZ(1);
      trazador.LineTo(x, y);
    }
  }


  xyz.SetZ(0);

  x = ox + (6 * scale) / 256;
  y = oy;
  irotate(&x, &y, ox, oy, text_angle);
  trazador.MoveTo(x, y);
}

void Text::Str(const char *s, int16_t scale, uint8_t angle)
{
  text_angle = angle;
  for (; *s != 0; s++) {
    Char(*s, trazador.X, trazador.Y, scale);
  }
}