- core/animation → shared/animation - core/l10n → shared/l10n - core/constants/ascii_colors → shared/theme/ascii_colors - import 경로 업데이트
71 lines
1.8 KiB
Dart
71 lines
1.8 KiB
Dart
import 'package:asciineverdie/src/shared/animation/canvas/ascii_cell.dart';
|
|
|
|
/// ASCII 레이어 데이터 구조 (Canvas 렌더러용)
|
|
///
|
|
/// 2D 셀 배열과 위치/깊이 정보를 담는다.
|
|
class AsciiLayer {
|
|
const AsciiLayer({
|
|
required this.cells,
|
|
this.zIndex = 0,
|
|
this.offsetX = 0,
|
|
this.offsetY = 0,
|
|
this.opacity = 1.0,
|
|
});
|
|
|
|
/// 2D 셀 배열 [row][column]
|
|
final List<List<AsciiCell>> cells;
|
|
|
|
/// Z 순서 (낮을수록 뒤쪽)
|
|
final int zIndex;
|
|
|
|
/// X 오프셋 (스크롤/이동용)
|
|
final int offsetX;
|
|
|
|
/// Y 오프셋
|
|
final int offsetY;
|
|
|
|
/// 레이어 투명도 (0.0 ~ 1.0, 배경 레이어 등에서 사용)
|
|
final double opacity;
|
|
|
|
/// 레이어 높이 (줄 수)
|
|
int get height => cells.length;
|
|
|
|
/// 레이어 너비 (열 수)
|
|
int get width => cells.isEmpty ? 0 : cells.first.length;
|
|
|
|
/// 특정 위치의 셀 반환 (범위 밖이면 empty)
|
|
AsciiCell getCell(int row, int col) {
|
|
if (row < 0 || row >= height) return AsciiCell.empty;
|
|
if (col < 0 || col >= cells[row].length) return AsciiCell.empty;
|
|
return cells[row][col];
|
|
}
|
|
|
|
/// 빈 레이어 생성
|
|
factory AsciiLayer.empty({int width = 60, int height = 8, int zIndex = 0}) {
|
|
final cells = List.generate(
|
|
height,
|
|
(_) => List.filled(width, AsciiCell.empty),
|
|
);
|
|
return AsciiLayer(cells: cells, zIndex: zIndex);
|
|
}
|
|
|
|
/// 문자열 리스트에서 레이어 생성 (자동 색상)
|
|
factory AsciiLayer.fromLines(
|
|
List<String> lines, {
|
|
int zIndex = 0,
|
|
int offsetX = 0,
|
|
int offsetY = 0,
|
|
}) {
|
|
final cells = lines.map((line) {
|
|
return line.split('').map(AsciiCell.fromChar).toList();
|
|
}).toList();
|
|
|
|
return AsciiLayer(
|
|
cells: cells,
|
|
zIndex: zIndex,
|
|
offsetX: offsetX,
|
|
offsetY: offsetY,
|
|
);
|
|
}
|
|
}
|