import type { NumOrString } from "@thi.ng/api" ; import { peek } from "@thi.ng/arrays/peek" ; import type { Canvas } from "./canvas.js" ; import { charCode } from "./utils.js" ; param canvas param x param y param len param s param e param m export const hline = ( canvas , x , y , len , s ? , e ? , m ? , format = canvas . format ) => { const { x1 , y1 , x2 , y2 } = peek ( canvas . clipRects ) ; if ( len < 1 || y < y1 || y >= y2 || x >= x2 ) return ; _hvline ( canvas . data , x , y , 1 , canvas . width , x1 , x2 , len , format , peek ( canvas . styles ) . hl , s , e , m ) ; } ; param canvas param x param y param len param s param e param m export const vline = ( canvas , x , y , len , s ? , e ? , m ? , format = canvas . format ) => { const { x1 , x2 , y1 , y2 } = peek ( canvas . clipRects ) ; if ( len < 1 || x < x1 || x >= x2 || y >= y2 ) return ; _hvline ( canvas . data , y , x , canvas . width , 1 , y1 , y2 , len , format , peek ( canvas . styles ) . vl , s , e , m ) ; } ; const _hvline = ( buf , a , b , astride , bstride , amin , amax , len , format , style , s ? , e ? , m ? ) => { a |= 0 ; b |= 0 ; len |= 0 ; let idx ; if ( a < amin ) { len += a - amin ; a = amin ; idx = a * astride + b * bstride ; } else { idx = a * astride + b * bstride ; buf [ idx ] = charCode ( s !== undefined && len > 1 ? s : style , format ) ; idx += astride ; a ++ ; len -- ; } len -- ; m = charCode ( m != undefined ? m : style , format ) ; for ( let i = 0 ; i < len && a < amax ; i ++ , a ++ , idx += astride ) { buf [ idx ] = m ; } if ( len >= 0 && a < amax ) { buf [ idx ] = charCode ( e !== undefined ? e : style , format ) ; } } ;