rgba js shared function