private Color calculateColour(PColorSpace colorSpace, float s,
                                  float t0, float t1) {

        // find colour at point 1
        float t = parametrixValue(s, t0, t1, extend);
        // find colour at point 
        float[] input = new float[1];
        input[0] = t;

        if (function != null) {

            float[] output;
            int length = function.length;
            // simple 1 in N out function
            if (length == 1){
                output = function[0].calculate(input);
            }else{
                // vector of function for each colour component, 1 in 1 out.
                output = new float[length];
                for (int i= 0; i < length; i++ ){
                    output[i] = function[i].calculate(input)[0];
                }
            }

            if (output != null) {
                if (!(colorSpace instanceof DeviceN)) {
                    output = PColorSpace.reverse(output);
                }
                return colorSpace.getColor(output);
            } else {
                return null;
            }

        } else {
            logger.fine("Error processing Shading Type 3 Pattern.");
            return null;
        }

    }