@@ -1372,6 +1372,16 @@ inline color colorVal(int r, int g, int b, int a=255) {
13721372 auto clamp8=[](int v){return v<0 ?0 :v>255 ?255 :v;};
13731373 return color ((unsigned int )(((clamp8 (a))<<24 )|((clamp8 (r))<<16 )|((clamp8 (g))<<8 )|(clamp8 (b))));
13741374}
1375+ // color() free functions -- match Processing Java
1376+ inline color color_ (int gray) { return colorVal (gray,gray,gray,255 ); }
1377+ inline color color_ (int gray, int a) { return colorVal (gray,gray,gray,a); }
1378+ inline color color_ (int r, int g, int b) { return colorVal (r,g,b,255 ); }
1379+ inline color color_ (int r, int g, int b, int a) { return colorVal (r,g,b,a); }
1380+ inline color color_ (float gray) { return colorVal ((int )gray,(int )gray,(int )gray,255 ); }
1381+ inline color color_ (float gray, float a) { return colorVal ((int )gray,(int )gray,(int )gray,(int )a); }
1382+ inline color color_ (float r, float g, float b) { return colorVal ((int )r,(int )g,(int )b,255 ); }
1383+ inline color color_ (float r, float g, float b, float a){ return colorVal ((int )r,(int )g,(int )b,(int )a); }
1384+
13751385
13761386// Color component extractors
13771387
@@ -2885,6 +2895,18 @@ template<typename T>
28852895void arrayCopy (const Array<T>& src, int srcPos, Array<T>& dst, int dstPos, int length) {
28862896 for (int i = 0 ; i < length; i++) dst[dstPos + i] = src[srcPos + i];
28872897}
2898+ // arrayCopy for std::vector
2899+ template <class T > inline void arrayCopy (const ::std::vector<T>& src, ::std::vector<T>& dst) {
2900+ dst = src;
2901+ }
2902+ template <class T > inline void arrayCopy (const ::std::vector<T>& src, int srcPos, ::std::vector<T>& dst, int dstPos, int length) {
2903+ for (int i=0 ;i<length;i++) dst[dstPos+i]=src[srcPos+i];
2904+ }
2905+ // arrayCopy for raw arrays
2906+ template <class T > inline void arrayCopy (const T* src, T* dst, int length) {
2907+ ::std::copy (src, src+length, dst);
2908+ }
2909+
28882910
28892911template <typename T>
28902912Array<T> concat (const Array<T>& a, const Array<T>& b) {
0 commit comments