2022-01-13 05:24:03 +01:00
|
|
|
function loadPalette(path) {
|
|
|
|
var pal = [];
|
|
|
|
|
|
|
|
if(path != "" && file_exists(path)) {
|
|
|
|
var _t = file_text_open_read(path);
|
|
|
|
var _index = 0;
|
2023-02-14 13:44:46 +01:00
|
|
|
var ext = string_lower(filename_ext(path));
|
2022-01-13 05:24:03 +01:00
|
|
|
while(!file_text_eof(_t)) {
|
|
|
|
var _w = file_text_readln(_t);
|
|
|
|
if(_w != "") {
|
|
|
|
switch(ext) {
|
|
|
|
case ".hex" :
|
|
|
|
var _r = string_hexadecimal(string_copy(_w, 1, 2));
|
|
|
|
var _g = string_hexadecimal(string_copy(_w, 3, 2));
|
|
|
|
var _b = string_hexadecimal(string_copy(_w, 5, 2));
|
2023-03-02 07:59:14 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
pal[_index++] = make_color_rgb(_r, _g, _b);
|
|
|
|
break;
|
|
|
|
case ".gpl" :
|
|
|
|
case ".pal" :
|
|
|
|
if(string_char_at(_w, 1) == "#") break;
|
|
|
|
var _c = string_splice(_w, " ");
|
2023-02-14 13:44:46 +01:00
|
|
|
if(array_length(_c) >= 3)
|
2023-05-30 11:09:15 +02:00
|
|
|
pal[_index++] = make_color_rgb(toNumber(_c[0]), toNumber(_c[1]), toNumber(_c[2]));
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
file_text_close(_t);
|
|
|
|
}
|
|
|
|
return pal;
|
|
|
|
}
|