fixed double height always being also double width

pull/2/head
Ondřej Hruška 7 years ago
parent f61d861883
commit d489e99194
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 7
      js/term/screen.js
  2. 19
      js/term/screen_renderer.js

@ -92,6 +92,13 @@ module.exports = class TermScreen extends EventEmitter {
this.screenAttrs = [] this.screenAttrs = []
this.screenLines = [] this.screenLines = []
// For testing TODO remove
this.screenLines[0] = 0b001
this.screenLines[1] = 0b010
this.screenLines[2] = 0b100
this.screenLines[3] = 0b011
this.screenLines[4] = 0b101
let selecting = false let selecting = false
let selectStart = (x, y) => { let selectStart = (x, y) => {

@ -212,7 +212,7 @@ module.exports = class CanvasRenderer extends EventEmitter {
const { ctx, width, height, padding } = this const { ctx, width, height, padding } = this
// is a double-width/double-height line // is a double-width/double-height line
if (this.screenLines[y]) cellWidth *= 2 if (this.screenLines[y] & 0b001) cellWidth *= 2
ctx.fillStyle = this.getColor(bg) ctx.fillStyle = this.getColor(bg)
let screenX = x * cellWidth + padding let screenX = x * cellWidth + padding
@ -281,29 +281,34 @@ module.exports = class CanvasRenderer extends EventEmitter {
let screenX = x * cellWidth + padding let screenX = x * cellWidth + padding
let screenY = y * cellHeight + padding let screenY = y * cellHeight + padding
const dblWidth = this.screenLines[y] & 0b001
const dblHeightTop = this.screenLines[y] & 0b010
const dblHeightBot = this.screenLines[y] & 0b100
if (this.screenLines[y]) { if (this.screenLines[y]) {
// is a double-width/double-height line // is a double-width/double-height line
cellWidth *= 2 if (dblWidth) cellWidth *= 2
ctx.save() ctx.save()
ctx.translate(screenX + 0.5 * cellWidth, screenY + 0.5 * cellHeight) ctx.translate(screenX + 0.5 * cellWidth, screenY + 0.5 * cellHeight)
ctx.scale(2, 1) if (dblWidth) ctx.scale(2, 1)
if (this.screenLines[y] & 0b10) { if (dblHeightTop) {
// top half // top half
ctx.scale(1, 2) ctx.scale(1, 2)
ctx.translate(0, cellHeight / 4) ctx.translate(0, cellHeight / 4)
} else if (this.screenLines[y] & 0b100) { } else if (dblHeightBot) {
// bottom half // bottom half
ctx.scale(1, 2) ctx.scale(1, 2)
ctx.translate(0, -cellHeight / 4) ctx.translate(0, -cellHeight / 4)
} }
ctx.translate((-screenX - 1.5 * cellWidth) / 2, -screenY - 0.5 * cellHeight) ctx.translate((-screenX - 1.5 * cellWidth) / 2, -screenY - 0.5 * cellHeight)
if (this.screenLines[y] & 0b110) { if (dblHeightBot || dblHeightTop) {
// characters overflow -- needs clipping // characters overflow -- needs clipping
// TODO: clipping is really expensive // TODO: clipping is really expensive
ctx.beginPath() ctx.beginPath()
if (this.screenLines[y] & 0b10) ctx.rect(screenX, screenY, cellWidth, cellHeight / 2) if (dblHeightTop) ctx.rect(screenX, screenY, cellWidth, cellHeight / 2)
else ctx.rect(screenX, screenY + cellHeight / 2, cellWidth, cellHeight / 2) else ctx.rect(screenX, screenY + cellHeight / 2, cellWidth, cellHeight / 2)
ctx.clip() ctx.clip()
} }

Loading…
Cancel
Save