generated from dellevin/template
基础epub阅读功能
This commit is contained in:
12
lib/utils/reader/coordinates_to_part.dart
Normal file
12
lib/utils/reader/coordinates_to_part.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
/// 将归一化坐标 (0-1) 映射到 3x3 九宫格区域 (0-8)
|
||||
///
|
||||
/// ```
|
||||
/// 0 1 2
|
||||
/// 3 4 5
|
||||
/// 6 7 8
|
||||
/// ```
|
||||
int coordinatesToPart(double x, double y) {
|
||||
final col = x < 0.33 ? 0 : (x < 0.66 ? 1 : 2);
|
||||
final row = y < 0.33 ? 0 : (y < 0.66 ? 1 : 2);
|
||||
return row * 3 + col;
|
||||
}
|
||||
Reference in New Issue
Block a user