Exemple #1
0
FX_BOOL color::convert(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
	v8::Isolate* isolate = GetIsolate(cc);
	int iSize = params.size();
	if (iSize < 2) return FALSE;
	CJS_Array aSource(isolate);
	if (!params[0].ConvertToArray(aSource)) return FALSE;

	CPWL_Color crSource;
	ConvertArrayToPWLColor(aSource, crSource);

	CFX_ByteString sDestSpace = params[1].ToCFXByteString();
	int nColorType = COLORTYPE_TRANSPARENT;

	if (sDestSpace == "T")
	{
		nColorType = COLORTYPE_TRANSPARENT;
	}
	else if (sDestSpace == "G")
	{
		nColorType = COLORTYPE_GRAY;
	}
	else if (sDestSpace == "RGB")
	{
		nColorType = COLORTYPE_RGB;
	}
	else if (sDestSpace == "CMYK")
	{
		nColorType = COLORTYPE_CMYK;
	}

	CJS_Array aDest(isolate);
	CPWL_Color crDest = crSource;
	crDest.ConvertColorType(nColorType);
	ConvertPWLColorToArray(crDest, aDest);
	vRet = aDest;

	return TRUE;
}
Exemple #2
0
	void TestFunc_for_each()
	{
		std::vector<long> aSource(10);
		std::vector<long> aTarget;

		std::generate(aSource.begin(), 
					  aSource.end(),
					  [](){
			static long counter = 0;
			++counter;
			return counter;
		});

		aTarget.reserve(aSource.size());

		for_each(aSource.begin(), aSource.end(), [&aTarget](long source) { aTarget.emplace_back(source + 1); });

		//std::cout << "Source:" << std::endl;
		//for_each(aSource.cbegin(), aSource.cend(), [](long source) { std::cout << source << std::endl; });
		std::cout << "Target:" << std::endl;
		for_each(aTarget.cbegin(), aTarget.cend(), [](long Target) { std::cout << Target << std::endl; });

	}