ABITXOUUKIF3XVFXVOQ5YI7N43TS5OEVNEFUQ5Q7J4QEILFG3IPAC
FYOPJXOXY2PCMDDI6XXXWNOVFSW6FN2WMKYW6YIPUUCWE2VOCQAQC
CWOSQTC4HIBTZMMASA34RVBLPT2FRCVGEOIYUZXISNKMDNILV3WQC
QMNTEX7P7FCFXDGERWFX556BVBYZXKJERGQ2GWT24ALQBXAELXTQC
5AMZXFS5GBD6DS64Q5RTY55U7LQDMDW776UHZK4HQPPXWSMO3MAQC
E742MTJAS6KZGXIFVCZMKREGQK34LA45VBIT4E7ODBL7J64FKJFAC
7ML3OFE732OG2ZBZWETBMMZTATOAJGOMNUEIV4GEJI56JX3P7NJQC
6AXPZL5PQMW5P6BPRTGWO3AOWAU5OC33UYBY3TVOHUVQXCRVVTPQC
IGYI5RVVRFQUQBDH6KQ2MH6ADCZ455Z634BRXKLCEYFF4ZKQ3TMQC
ALMG52BOHW6WB6H7DF742GHU6VWUEPQFLWNFYU3PQBDSD4HQ7VJAC
ROQCAPZJPLENWBMHRK7DNH3CIMZRHPBMVBBKT7NQXRIFHEDZ5JHQC
4IXWCEHMWCEXNCDYUV3H44UPQ7R4HKS3RWRWII7LU4PA6ZZRAS3AC
ZM2EMAZOPZDZ2VUIE6NGAXS2OM7MYNWTMHIKM7KPIKSYXXR4D4CQC
2ABZP2KNBJEMIR46B5UM7JXNYLM7CTFA5YA7VFQIS5JYYH4W5PYAC
native.colourize_heightmap.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
colourize_heightmap = native.colourize_heightmap
}
}
}
#[no_mangle]
pub extern "C" fn colourize_heightmap(target: *mut f64, source: *const f64, width: u32, height: u32) {
const SEA_LEVEL: f64 = 0.1;
let target = unsafe {
std::slice::from_raw_parts_mut(target, (width as usize) * (height as usize) * 3)
};
let source = unsafe {
std::slice::from_raw_parts(source, (width as usize) * (height as usize))
};
for y in 0 .. (height as usize) {
let rowstart_s = y * (width as usize);
let snow_line = {
let y = (y as f64) / (height as f64);
y * (1. - y) * 2.
};
for x in 0 .. (width as usize) {
let ix = rowstart_s + x;
let s = source[ix];
let (r,g,b) = if s > snow_line {
(1.,1.,1.)
} else if s > SEA_LEVEL {
let o = 0.9 * s;
(o,0.9,o)
} else {
(0.,0.,0.9)
};
let ixt = ix * 3;
target[ixt] = r;
target[ixt + 1] = g;
target[ixt + 2] = b;
def colourize_heightmap(source):
shape = source.shape
n = numpy.zeros((shape[0],shape[1],3), numpy.float64)
source = tf.cast(source, tf.float64).numpy()
helpers.colourize_heightmap(ctypes.cast(ctypes.c_voidp(n.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.cast(ctypes.c_voidp(source.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]))
return tf.constant(n)