@@ -485,22 +485,32 @@ CPColorBmp.prototype.createThumbnailFrom = function (that) {
485485 * - expandBy: 塗りつぶし範囲を拡張するピクセル数
486486 * - alpha255: 不透明度 (1-255)
487487 * - mergedData: 判定用に渡す全レイヤー合成結果 (Uint8ClampedArray)
488- * null の場合は現在のレイヤーを基準にする
488+ * 空のオブジェクトの場合は現在のレイヤーを基準にする
489+ *
490+ * @param {number } x - 塗りつぶしを開始するX座標
491+ * @param {number } y - 塗りつぶしを開始するY座標
492+ * @param {number } fillColor - 塗りつぶす色(0xRRGGBB 形式の数値)
493+ * @param {number } [expandBy=2] - 塗りつぶした領域を外側に拡張するピクセル数(縁取りの太さ)
494+ * @param {number } [alpha255=255] - 塗りつぶす色の不透明度(0〜255)
495+ * @param {Object } [fusion={}] - 統合画像の情報を含むオブジェクト
496+ * @param {Uint8Array|Uint8ClampedArray } [fusion.data] - 塗りつぶし対象の判定元として使用する画像データ。未指定の場合は自身の `data` を参照。
497+ * @returns {void }
489498 */
499+
490500CPColorBmp . prototype . floodFillWithBorder = function (
491501 x ,
492502 y ,
493503 fillColor ,
494504 expandBy = 2 ,
495505 alpha255 = 255 ,
496- fusion = null ,
506+ fusion = { } ,
497507) {
498508 if ( ! this . isInside ( x , y ) ) return ;
499509
500510 const w = this . width ;
501511 const h = this . height ;
502512 const data = this . data ; // 書き込み先
503- const srcData = fusion ? fusion . data : data ; // 判定元
513+ const srcData = fusion && fusion . data ? fusion . data : data ; // 判定元
504514 const BYTES = CPColorBmp . BYTES_PER_PIXEL ;
505515
506516 const fillR = ( fillColor >> 16 ) & 0xff ;
@@ -539,7 +549,9 @@ CPColorBmp.prototype.floodFillWithBorder = function (
539549
540550 // flood fill 本体
541551 while ( stack . length ) {
542- const { x : px , y : py } = stack . pop ( ) ;
552+ const { x : px , y : py } = /** @type {{x: number, y: number} } */ (
553+ stack . pop ( )
554+ ) ;
543555 if ( ! comparePixel ( px , py ) ) continue ;
544556
545557 Processed [ py * w + px ] = 1 ;
@@ -2087,8 +2099,9 @@ CPColorBmp.prototype.getNonTransparentBounds = function (initialBounds) {
20872099/**
20882100 * Returns a new canvas with a rotated version of the given canvas.
20892101 *
2090- * @param {HTMLCanvasElement } canvas
2102+ * @param {any } canvas
20912103 * @param {number } rotation - [0..3], selects a multiple of 90 degrees of clockwise rotation to be applied.
2104+ * @return {any }
20922105 */
20932106export function getRotatedCanvas ( canvas , rotation ) {
20942107 rotation = rotation % 4 ;
@@ -2165,7 +2178,7 @@ CPColorBmp.prototype.getAsCanvas = function (rotation) {
21652178 * Rotation is [0..3] and selects a multiple of 90 degrees of clockwise rotation to be applied, or 0 to leave
21662179 * unrotated.
21672180 *
2168- * @returns {string } - "Binary string" representation of the PNG file
2181+ * @returns {string|false } - "Binary string" representation of the PNG file
21692182 */
21702183CPColorBmp . prototype . getAsPNG = function ( rotation ) {
21712184 let canvas = this . getAsCanvas ( rotation ) ;
@@ -2182,6 +2195,7 @@ CPColorBmp.prototype.getAsPNG = function (rotation) {
21822195 * @returns {Buffer }
21832196 */
21842197CPColorBmp . prototype . getAsPNGBuffer = function ( rotation ) {
2198+ /** @type {any } */
21852199 let canvas = this . getAsCanvas ( rotation ) ;
21862200
21872201 // API provided by node-canvas for running on Node (browsers don't support this)
@@ -2233,7 +2247,7 @@ CPColorBmp.prototype.hasAlpha = function () {
22332247/**
22342248 * Create from a loaded HTML Image object
22352249 *
2236- * @param {HTMLImageElement } image
2250+ * @param {any } image
22372251 */
22382252CPColorBmp . createFromImage = function ( image ) {
22392253 var imageCanvas = createCanvas ( image . width , image . height ) ,
0 commit comments