1
0
mirror of https://github.com/rricharz/Tek4010.git synced 2026-02-26 08:53:35 +00:00

fixed ARDS vertical character positioning

This commit is contained in:
¨Rene Richarz
2019-04-29 10:15:32 +02:00
parent eb6d9da372
commit e2c2dffc7e
4 changed files with 17 additions and 13 deletions

2
ards.c
View File

@@ -59,7 +59,7 @@ static int x0 = -485, y0 = 450, x2, y2;
static void draw_char (cairo_t *cr, cairo_t *cr2, char ch)
{
tube_x0 = (int)(efactor * (x0 + 540));
tube_y0 = (int)(efactor * (y0 + 707)) - vDotsPerChar/2;
tube_y0 = (int)(efactor * (y0 + 707));
//fprintf (stderr, "[tube: %d,%d]", tube_x0, tube_y0);
tube_drawCharacter(cr, cr2, ch);
x0 += (int)(hDotsPerChar / efactor);

9
main.c
View File

@@ -2,15 +2,8 @@
*
* main.c
* provides a simple framework for basic drawing with cairo and gtk+ 3.0
* define main window in tek4010.h
* and cairo drawing in tek4010.c
*
* The framework provides functions to
* a function to draw using cairo
* a function to initialize your code
* a function to exit your code
* a peridicaly called function
* a function called if the mouse is clicked
* Version adapted for tek4010
*
* Copyright 2016,2019 rricharz
*

BIN
tek4010

Binary file not shown.

19
tube.c
View File

@@ -91,6 +91,7 @@ static long charCount = 0;
static long charResetCount = 0;
static long characterInterval = 0;
static int currentFontSize = 18;
static int currentCharacterOffset = 0;
long startPaintTime;
@@ -397,7 +398,7 @@ void tube_doCursor(cairo_t *cr2)
{
cairo_set_source_rgb(cr2, 0, CURSOR_INTENSITY, 0);
cairo_set_line_width (cr2, 1);
cairo_rectangle(cr2, tube_x0, windowHeight - tube_y0 - vDotsPerChar + 8,
cairo_rectangle(cr2, tube_x0, windowHeight - tube_y0 - vDotsPerChar + 6 + currentCharacterOffset,
hDotsPerChar - 3, vDotsPerChar - 3);
cairo_fill(cr2);
cairo_stroke (cr2);
@@ -479,19 +480,19 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
if (writeThroughMode) { // draw the write-through character
cairo_set_source_rgb(cr2, 0, WRITE_TROUGH_INTENSITY, 0);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr2, s);
}
else {
// draw the character
cairo_set_source_rgb(cr, 0, BLACK_COLOR + ((NORMAL_INTENSITY - BLACK_COLOR) * intensity) / 100, 0);
cairo_move_to(cr, tube_x0, windowHeight - tube_y0);
cairo_move_to(cr, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr, s);
// draw the bright spot
cairo_set_source_rgb(cr2, BRIGHT_SPOT_COLOR, BRIGHT_SPOT_COLOR, BRIGHT_SPOT_COLOR);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr2, s);
}
@@ -612,8 +613,18 @@ void tube_setupPainting(cairo_t *cr, cairo_t *cr2, char *fontName)
void tube_changeCharacterSize(cairo_t *cr, cairo_t *cr2,int charsPerLine, int charsPerPage, int fontSize)
{
int fontsize;
cairo_font_extents_t et;
hDotsPerChar = windowWidth / charsPerLine;
vDotsPerChar = windowHeight / charsPerPage;
leftmargin = 0;
currentFontSize = fontSize;
cairo_set_font_size(cr, currentFontSize);
cairo_set_font_size(cr2,currentFontSize);
if (argARDS) {
cairo_font_extents(cr, &et);
currentCharacterOffset =(int)et.ascent;
if (DEBUG) printf("Set vertical character offset for ARDS mode to %d\n", currentCharacterOffset);
}
else
currentCharacterOffset = 0;
}