mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-18 23:10:26 +00:00
parser/texture:: txp function
This commit is contained in:
parent
388ac890bf
commit
4dfa168ce4
18
textures.cpp
18
textures.cpp
@ -1676,6 +1676,16 @@ void texture_config::remap() {
|
||||
}
|
||||
}
|
||||
|
||||
#if CAP_TEXTURE
|
||||
texture_data txp;
|
||||
|
||||
EX double get_txp(ld x, ld y, int p) {
|
||||
if(txp.texture_pixels.empty()) return 0.5;
|
||||
color_t col = txp.get_texture_pixel(txp.twidth * x, txp.twidth * y);
|
||||
return part(col, p) / 255.;
|
||||
}
|
||||
#endif
|
||||
|
||||
int textureArgs() {
|
||||
using namespace arg;
|
||||
|
||||
@ -1696,6 +1706,14 @@ int textureArgs() {
|
||||
shift(); config.configname = args();
|
||||
}
|
||||
|
||||
else if(argis("-txpsize")) {
|
||||
shift(); txp.twidth = argi();
|
||||
}
|
||||
|
||||
else if(argis("-txpf")) {
|
||||
shift(); txp.readtexture(args());
|
||||
}
|
||||
|
||||
else if(argis("-txcl")) {
|
||||
PHASE(3); drawscreen();
|
||||
config.load();
|
||||
|
6
util.cpp
6
util.cpp
@ -219,6 +219,12 @@ cld exp_parser::parse(int prio) {
|
||||
dynamicval<cld> d(extra_params[name], val);
|
||||
return parsepar();
|
||||
}
|
||||
#if CAP_TEXTURE
|
||||
else if(eat("txp(")) {
|
||||
cld val = parsepar();
|
||||
return texture::get_txp(real(val), imag(val), int(real(extra_params["p"]) + .5)-1);
|
||||
}
|
||||
#endif
|
||||
else if(next() == '(') at++, res = parsepar();
|
||||
else {
|
||||
string number;
|
||||
|
Loading…
Reference in New Issue
Block a user