code format
This commit is contained in:
parent
1f3eb41b4e
commit
55dde8b646
1 changed files with 244 additions and 244 deletions
|
|
@ -64,7 +64,7 @@ function fillBitmapCapped(bitmap, rgba, rects_cap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapBitmapToBitmap (
|
function mapBitmapToBitmap(
|
||||||
/** @type {Bitmap} */src,
|
/** @type {Bitmap} */src,
|
||||||
/** @type {BoundingRectangle} */ rect_src,
|
/** @type {BoundingRectangle} */ rect_src,
|
||||||
/** @type {Bitmap} */ dst,
|
/** @type {Bitmap} */ dst,
|
||||||
|
|
@ -93,7 +93,7 @@ function mapBitmapToBitmap (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapBitmapToBitmapCapped (
|
function mapBitmapToBitmapCapped(
|
||||||
/** @type {Bitmap} */ src,
|
/** @type {Bitmap} */ src,
|
||||||
/** @type {BoundingRectangle} */ rect_src,
|
/** @type {BoundingRectangle} */ rect_src,
|
||||||
/** @type {Bitmap} */ dst,
|
/** @type {Bitmap} */ dst,
|
||||||
|
|
@ -163,7 +163,7 @@ function mapBitmapToAdapterCapped (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapBitmapToAdapter (
|
function mapBitmapToAdapter(
|
||||||
/** @type {Bitmap} */ src,
|
/** @type {Bitmap} */ src,
|
||||||
/** @type {BoundingRectangle} */ rect_src,
|
/** @type {BoundingRectangle} */ rect_src,
|
||||||
/** @type {CanvasAdapter} */ dst,
|
/** @type {CanvasAdapter} */ dst,
|
||||||
|
|
@ -253,10 +253,10 @@ const determinePuzzleInfo = (w, h, targetTiles) => {
|
||||||
tileSize = TILE_SIZE
|
tileSize = TILE_SIZE
|
||||||
const width = tiles_x * tileSize
|
const width = tiles_x * tileSize
|
||||||
const height = tiles_y * tileSize
|
const height = tiles_y * tileSize
|
||||||
const coords = coordsByNum({width, height, tileSize, tiles})
|
const coords = coordsByNum({ width, height, tileSize, tiles })
|
||||||
|
|
||||||
const tileMarginWidth = tileSize * .5;
|
const tileMarginWidth = tileSize * .5;
|
||||||
const tileDrawSize = Math.round(tileSize + tileMarginWidth*2)
|
const tileDrawSize = Math.round(tileSize + tileMarginWidth * 2)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width,
|
width,
|
||||||
|
|
@ -311,22 +311,22 @@ function getSurroundingTilesByIdx(puzzle, idx) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
function determinePuzzleTileShapes (info) {
|
function determinePuzzleTileShapes(info) {
|
||||||
const tabs = [-1, 1]
|
const tabs = [-1, 1]
|
||||||
|
|
||||||
const shapes = new Array(info.tiles)
|
const shapes = new Array(info.tiles)
|
||||||
for (let i = 0; i < info.tiles; i++) {
|
for (let i = 0; i < info.tiles; i++) {
|
||||||
shapes[i] = {
|
shapes[i] = {
|
||||||
top: info.coords[i].y === 0 ? 0 : shapes[i - info.tiles_x].bottom * -1,
|
top: info.coords[i].y === 0 ? 0 : shapes[i - info.tiles_x].bottom * -1,
|
||||||
right: info.coords[i].x === info.tiles_x -1 ? 0 : choice(tabs),
|
right: info.coords[i].x === info.tiles_x - 1 ? 0 : choice(tabs),
|
||||||
left: info.coords[i].x === 0 ? 0 : shapes[i - 1].right * -1,
|
left: info.coords[i].x === 0 ? 0 : shapes[i - 1].right * -1,
|
||||||
bottom: info.coords[i].y === info.tiles_y -1 ? 0 : choice(tabs),
|
bottom: info.coords[i].y === info.tiles_y - 1 ? 0 : choice(tabs),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return shapes
|
return shapes
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createPuzzleTileBitmaps (bitmap, tiles, info) {
|
async function createPuzzleTileBitmaps(bitmap, tiles, info) {
|
||||||
let img = await bitmap.toImage()
|
let img = await bitmap.toImage()
|
||||||
var tileSize = info.tileSize
|
var tileSize = info.tileSize
|
||||||
var tileMarginWidth = info.tileMarginWidth
|
var tileMarginWidth = info.tileMarginWidth
|
||||||
|
|
@ -423,7 +423,7 @@ async function createPuzzleTileBitmaps (bitmap, tiles, info) {
|
||||||
return bitmaps
|
return bitmaps
|
||||||
}
|
}
|
||||||
|
|
||||||
function srcRectByIdx (puzzleInfo, idx) {
|
function srcRectByIdx(puzzleInfo, idx) {
|
||||||
let c = puzzleInfo.coords[idx]
|
let c = puzzleInfo.coords[idx]
|
||||||
let cx = c.x * puzzleInfo.tileSize
|
let cx = c.x * puzzleInfo.tileSize
|
||||||
let cy = c.y * puzzleInfo.tileSize
|
let cy = c.y * puzzleInfo.tileSize
|
||||||
|
|
@ -435,7 +435,7 @@ function srcRectByIdx (puzzleInfo, idx) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const pointSub = (a, b) => ({x: a.x - b.x, y: a.y - b.y})
|
const pointSub = (a, b) => ({ x: a.x - b.x, y: a.y - b.y })
|
||||||
|
|
||||||
const pointAdd = (a, b) => ({x: a.x + b.x, y: a.y + b.y})
|
const pointAdd = (a, b) => ({x: a.x + b.x, y: a.y + b.y})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue