// ๐Ÿงฉ ๋Œ€์‹œ๋ณด๋“œ ํƒ€์ผ์˜ ๊ฒฉ์ž ์œ„์น˜/ํฌ๊ธฐ(1x1 ~ 4x4)๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ฐ’ ๊ฐ์ฒด. // ์ „์ฒด ๋ฐฐ์น˜ ์บ”๋ฒ„์Šค๋Š” ๊ฐ€๋กœ 6์นธ ร— ์„ธ๋กœ 4์นธ์œผ๋กœ ๊ณ ์ •ํ•œ๋‹ค. // ๐Ÿ“ฑ [๊ธฐ๋Šฅ ๋ณด๋ฅ˜] ๋ฐ์Šคํฌํƒ‘์—์„œ๋Š” ์ž˜ ๋‚˜์˜ค์ง€๋งŒ, ํฐ์ฒ˜๋Ÿผ ํ™”๋ฉด์ด ์ž‘์€ ๊ธฐ๊ธฐ์—์„œ๋Š” // 6์นธ ๊ณ ์ • ๊ฒฉ์ž ๋•Œ๋ฌธ์— ํƒ€์ผ์ด ๋„ˆ๋ฌด ์ž‘์•„์ ธ ๋ ˆ์ด์•„์›ƒ์ด ๊นจ์ง„๋‹ค. // ์ž‘์€ ํ™”๋ฉด ๋Œ€์‘ ๋ฐฉ์•ˆ์„ ๋งˆ๋ จํ•˜๊ธฐ ์ „๊นŒ์ง€ ํŽธ์ง‘ ๊ธฐ๋Šฅ์„ ์ž„์‹œ๋กœ ๊บผ๋‘”๋‹ค. // (๋‹ค์‹œ ์ผœ๋ ค๋ฉด ์ด ๊ฐ’๋งŒ true๋กœ ๋ฐ”๊พธ๋ฉด ๋จ โ€” ๊ด€๋ จ ์ฝ”๋“œ๋Š” ๊ทธ๋Œ€๋กœ ๋‚จ๊ฒจ๋‘ ) const bool kTileEditingEnabled = false; const int kGridCols = 6; const int kGridRows = 4; const int kMinTileSize = 1; const int kMaxTileSize = 4; class TileRect { final int x; final int y; final int w; final int h; const TileRect({ required this.x, required this.y, required this.w, required this.h, }); factory TileRect.fromJson(Map json) => TileRect( x: (json['x'] as num).toInt(), y: (json['y'] as num).toInt(), w: (json['w'] as num).toInt(), h: (json['h'] as num).toInt(), ); Map toJson(String id) => { 'id': id, 'x': x, 'y': y, 'w': w, 'h': h, }; TileRect copyWith({int? x, int? y, int? w, int? h}) => TileRect(x: x ?? this.x, y: y ?? this.y, w: w ?? this.w, h: h ?? this.h); bool overlaps(TileRect other) { return x < other.x + other.w && x + w > other.x && y < other.y + other.h && y + h > other.y; } bool get isWithinCanvas => x >= 0 && y >= 0 && x + w <= kGridCols && y + h <= kGridRows && w >= kMinTileSize && h >= kMinTileSize && w <= kMaxTileSize && h <= kMaxTileSize; }