As a response to WebAssembly initiative I am thinking about adding native inline C functions to Sciter.
// that is inline C function declared directly in script: function getAverageColor( image ) C { typedef struct { byte r; byte g; byte b; byte a; } rgba; rgba* pix = image_pixels(image); unsigned total = image_pixels_count(image); rgba* pix_end = pix + total; unsigned int r = 0, g = 0, b = 0, a = 0; for(; pix < pix_end; ++pix ) { r += pix->r; g += pix->g; b += pix->b; a += pix->a; } rgba out; out.r = r / total; out.g = g / total; out.b = b / total; out.a = a / total; return out; }
And so we can call that function in script when we will need to get maximum performance:
var img = new Image(w,h,element); var averageColor = getAverageColor(img);
Such functions will be translated on the fly into native code and so executed as fast as possible.
Huh?