diff --git a/color.py b/color.py index a5f7588..aae5119 100644 --- a/color.py +++ b/color.py @@ -77,6 +77,23 @@ def get_color_from_value( return tuple(current_color) +def get_color_from_value(value: float, color_mapping: Dict[int, Tuple[int, int, int, int]]) -> Tuple[int, int, int, int]: + """ + 根据输入的值,从颜色映射字典中查找对应的颜色 + + Parameters: + value: 输入值 + color_mapping: 颜色映射字典 + + Returns: + Tuple[int, int, int, int]: RGBA颜色元组 + """ + # 找到小于等于输入值的最大分界值 + max_key = max([k for k in color_mapping if k <= value]) + + return color_mapping[max_key] + + # 使用示例: if __name__ == "__main__": # 生成原始序列 diff --git a/read_dat.py b/read_dat.py index af99c09..3c7071a 100644 --- a/read_dat.py +++ b/read_dat.py @@ -22,23 +22,33 @@ def read_binary_file(file_path): date = struct.unpack(" 335: - break - time_bytes = file.read(8) - time = struct.unpack(" 335: + # break + # time_bytes = file.read(8) + # time = struct.unpack("