// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader str_startswith (output vector res_t = 0,
                       output vector res_f = 0,
                       output vector res_t_m = 0,
                       output vector res_f_m = 0)
{
    string a = "0.24", b = format ("%g", P),  c = "0.48", d="0.64";
    string concat_str = concat(a,b,c,d);
    string substrm = "0.24";
    
    int temps = startswith(concat_str, substrm);
    
    res_t = vector((temps/0.3)*u+0.1, (-u-v), v*0.3);
    //  printf("%g\n", res_t);
    
    substrm = "88";
    temps = startswith(concat_str, substrm);
   
    res_f = vector((temps/0.2)*u+0.1, (-u-v), v*0.1);
    //  printf("%g\n", res_f);
         
    if(int(P[0]*64)%2) {
        string a = "0.25", b = format ("%g", P),  c = "0.50", d="0.75";
        string concat_str = concat(a,b,c,d);
        string substrm = "0.25";
        
        int temps = startswith(concat_str, substrm);
        
        res_t_m = vector((temps/0.3)*u+0.1, (-u-v), v*0.3);
        // printf("%g\n", res_t_m);
        
        substrm = "88";
        temps = startswith(concat_str, substrm);
        res_f_m = vector((temps/0.2)*u+0.1, (-u-v), v*0.1);
        //  printf("%g\n", res_f_m);
    }
}
