Skip to content

Commit

Permalink
Draw dashed lines through ratios
Browse files Browse the repository at this point in the history
  • Loading branch information
tisilent committed Nov 8, 2023
1 parent 58bb7fc commit 2861a4d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/browser/renderer/shared/TextureAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,14 @@ export class TextureAtlas implements ITextureAtlas {
nextOffset = computeNextVariantOffset(xChRight - xChLeft, lineWidth, nextOffset);
break;
case UnderlineStyle.DASHED:
this._tmpCtx.setLineDash([this._config.devicePixelRatio * 4, this._config.devicePixelRatio * 3]);
const lineRatio = 0.6;
const gapRatio = 0.3;
// End line ratio is approximately equal to 0.1
const xChWidth = xChRight - xChLeft;
const line = Math.floor(lineRatio * xChWidth);
const gap = Math.floor(gapRatio * xChWidth);
const end = xChWidth - line - gap;
this._tmpCtx.setLineDash([line, gap, end]);
this._tmpCtx.moveTo(xChLeft, yTop);
this._tmpCtx.lineTo(xChRight, yTop);
break;
Expand Down

0 comments on commit 2861a4d

Please sign in to comment.