当前位置: 首页>>代码示例>>C++>>正文


C++ TConfig::RowWidth方法代码示例

本文整理汇总了C++中TConfig::RowWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ TConfig::RowWidth方法的具体用法?C++ TConfig::RowWidth怎么用?C++ TConfig::RowWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TConfig的用法示例。


在下文中一共展示了TConfig::RowWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Render

	void Render(uint frameTimeMS, double canvasWidth, double canvasHeight, const TConfig& config)
	{
		uint bottom = config.top + config.height;

		const double scaleMin = 0.5;
		const double scaleMax = 1.7;
		const double rotationMaximum = 0.5;// 0 - 1=90 deg.
		const double rotationSpeedX = 0.15;
		const double rotationSpeedY = 0.09;

		const double opacityMin = 0.3;
		const double opacityMax = 0.65;

		const double twinkleSpeed = 0.09;
		const double twinkleThreshold = 0.93;
		// these two will adjust the twinkle effect. it affects opacity of the square, and the color. both of these are 0-1.
		const double maxTwinkleOpacity = 0.5;
		const double twinkleBrightness = 0.5;

	 	if(config.xflip)
	 	{
	 		squareFieldXFlip(canvasWidth / 2);
	 	}
	 	else
	 	{
			canvasSave();
	 	}

		// when modulating envelopes, how much does x/y dimension affect the
		// envelope progression?
		// values 0-20 will be plasma-like; higher can start to look more sharp / twinkly
		double dimensionMult = 20;
		int previousRowWidth = -1;
		int rowWidth = -1;

	 	for(uint y = config.top; y < bottom; y += config.blockSizeY)
	 	{
	 		uint iy = (y - config.top) / config.blockSizeY;

	 		previousRowWidth = rowWidth;
	 		rowWidth = config.RowWidth(y, config.top, bottom, canvasWidth, canvasHeight);
	 		if(previousRowWidth == -1)
 				previousRowWidth = rowWidth;

	 		uint right = config.left + rowWidth;

	 		for(uint x = config.left; x < rowWidth; x += config.blockSizeX)
	 		{
	 			uint ix = (x - config.left) / config.blockSizeX;
				//squareFieldRenderSquare(0.5, 0.5, 0.5, 0.5, 0xff00ff, 0.5, 8);

	 			bool isOdd = ((ix & 1) == (iy & 1));// checkerboard

	 			if(!config.oddFillEnabled && isOdd)
					continue;
	 			if(!config.evenFillEnabled && !isOdd)
					continue;

				const TheModColorMixingTable<ColorMixingSteps>& fillColorTable(isOdd ? config.oddColorTable : config.evenColorTable);

	 			double xalphaVary = (config.opacityXEnv.height((dimensionMult * x) + frameTimeMS) + 1) / 2;
	 			double yalphaVary = (config.opacityYEnv.height((dimensionMult * y) + frameTimeMS) + 1) / 2;

	 			double userAlpha = config.Opacity(x, y, config.top, bottom, config.left, right, previousRowWidth, rowWidth, ix, iy);

				double aa = 1.0;// anti-alias damping
				if(((x - config.left) + config.blockSizeX) > rowWidth)
				{
					// "big" anti-alias this block.
					aa = double(rowWidth - (x - config.left)) / config.blockSizeX;
				}

 				double alpha = xalphaVary * yalphaVary * aa;

	 			// now scale alpha to opacityMin / Max
	 			double opacity = opacityMin + (alpha * (opacityMax - opacityMin));

				double blockScale = (scaleMin + ((scaleMax - scaleMin) * alpha * userAlpha));
				double thisBlockSizeX = blockScale * config.blockSizeX;

				// this is actually incorrect; for a true grid use blockSizeX / Y, but this gives a cool effect that things are sorta wavy / bulgy
				double xtrans = (double)x + ((double)thisBlockSizeX / 2);
				double ytrans = (double)y + ((double)config.blockSizeY / 2);

				double twinkleFactor = CachedRandEnvelope(ix, iy, twinkleSpeed).factor(frameTimeMS);
				TheModColor fillStyle;
				double finalOpacity;
				if(twinkleFactor < twinkleThreshold)
				{
					finalOpacity = opacity * userAlpha;
					fillStyle = fillColorTable.c1;
				}
				else
				{
					// scale it to 0-1
					twinkleFactor = (twinkleFactor - twinkleThreshold) / (1.0 - twinkleThreshold);

					double twinkleOpacity = twinkleFactor * maxTwinkleOpacity;

					finalOpacity = (1.0 - (opacity * userAlpha)) * twinkleOpacity;
//.........这里部分代码省略.........
开发者ID:thenfour,项目名称:TheMOD,代码行数:101,代码来源:layerNavBackground.hpp


注:本文中的TConfig::RowWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。