mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-10-31 23:20:18 +08:00
二区的二区
This commit is contained in:
1 parent
cb0e6cb98e
commit
5f48eef6af
60 files changed
+2739
-1418
No files matched your search
@@ -204,67 +204,3 @@ export function getMapData(
|
||||
|
||||
return (bfsCache[floorId] = res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制小地图
|
||||
* @param ctx 画布
|
||||
* @param floorId 中心楼层
|
||||
* @param interval 楼层间距
|
||||
* @param border 边框粗细
|
||||
* @param noCache 是否不使用缓存
|
||||
*/
|
||||
export function drawFlyMap(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
floorId: FloorIds,
|
||||
offset: [number, number],
|
||||
size: [number, number],
|
||||
scale: number = 3,
|
||||
interval: number = 5,
|
||||
border: number = 1,
|
||||
noCache: boolean = false
|
||||
) {
|
||||
const data = getMapDrawData(floorId, interval, border, noCache);
|
||||
const [ox, oy] = offset;
|
||||
const [width, height] = size;
|
||||
const canvas = ctx.canvas;
|
||||
canvas.width = data.width * devicePixelRatio * scale;
|
||||
canvas.height = data.height * devicePixelRatio * scale;
|
||||
ctx.lineWidth = border * devicePixelRatio * scale;
|
||||
ctx.strokeStyle = '#fff';
|
||||
ctx.scale(scale, scale);
|
||||
// 绘制连线
|
||||
data.line.forEach(([x1, y1, x2, y2]) => {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x1, y1);
|
||||
ctx.lineTo(x2, y2);
|
||||
ctx.stroke();
|
||||
});
|
||||
for (const [id, [x, y]] of Object.entries(data.locs) as [
|
||||
FloorIds,
|
||||
LocArr
|
||||
][]) {
|
||||
drawThumbnail(ctx, id, scale, [x, y], offset, size);
|
||||
}
|
||||
}
|
||||
|
||||
function drawThumbnail(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
floorId: FloorIds,
|
||||
scale: number,
|
||||
pos: [number, number],
|
||||
offset: [number, number],
|
||||
size: [number, number]
|
||||
) {
|
||||
const [x, y] = pos;
|
||||
const [ox, oy] = offset;
|
||||
const [width, height] = size;
|
||||
const map = core.status.maps[floorId];
|
||||
if (
|
||||
ox + x * scale + (map.width * scale) / 2 < 0 ||
|
||||
ox + x * scale - (map.width * scale) / 2 > width ||
|
||||
oy + y * scale + (map.height * scale) / 2 < 0 ||
|
||||
oy + y * scale - (map.height * scale) / 2 > height
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ export default function init() {
|
||||
|
||||
async function showApp() {
|
||||
core.lockControl();
|
||||
|
||||
if (transition.value) {
|
||||
app.style.transition = 'all 0.6s linear';
|
||||
} else {
|
||||
|
||||
@@ -153,3 +153,13 @@ export function splitText(str: string[]) {
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 在下一帧执行某个函数
|
||||
* @param cb 执行的函数
|
||||
*/
|
||||
export function nextFrame(cb: (time: number) => void) {
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(cb);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user