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


C++ CLayer::GetDensityColor方法代码示例

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


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

示例1: DrawLayers

void DrawLayers(HDC hdc, int x, int y, int width, int height, int type)
{
	double maxHeight = CSnow::current()->getSnowHeight();
	double temperatureRange = 40;//max(abs(bottomTemperature - topTemperature), abs(topTemperature));
	if(temperatureRange == 0)temperatureRange = 1;

	if (maxHeight == 0)
		return;

	HBRUSH brush;
	int h;
	int topT, bottomT;
	int rightMargin = 40;
	RECT rect;
	CLayer *layer;

	
	HPEN pen = CreatePen(0, 1, 0);
	//HPEN boldPen = CreatePen(0, 3, 0);
	HPEN oldPen = (HPEN)SelectObject(hdc, pen);
	HPEN dotPen = CreatePen(PS_DASH, 1, RGB(0,0,0));

	LOGFONT lFont;
	ZeroMemory(&lFont, sizeof(lFont));
	lFont.lfHeight = 16;
	lFont.lfWeight = FW_BOLD;
	wcscpy_s(lFont.lfFaceName, WINDOW_FONT);
	HFONT font = CreateFontIndirect(&lFont);
	HFONT oldFont = SelectFont(hdc, font);
		
	SetBkMode(hdc, TRANSPARENT);

	int dy = 0;
	for (int l = 0; l < CSnow::current()->getLayersNum(); l++) {
		layer = CSnow::current()->getLayer(l);
		//if (type)h = height*CSnow::current()->getLayer(l)->GetHeight(t)/maxHeight;
		//else h = height*CSnow::current()->getLayer(l)->GetDensity(t)/maxHeight;
		h = (int)(height*layer->GetHeight()/maxHeight);

		if (h == 0)
			continue;

		//draw layer
		brush = CreateSolidBrush((type) ? layer->GetParticleColor() : layer->GetDensityColor());
		rect.left = x; rect.right = x + width - rightMargin;
		rect.top = y + height - dy - (int)h; rect.bottom = y + height - dy;
		FillRect(hdc, &rect, brush);
		DeleteObject(brush);

		//draw layer temperature
		topT = (int)((width - rightMargin)*layer->GetTopTemperature()/temperatureRange);
		bottomT = (int)((width - rightMargin)*layer->GetBottomTemperature()/temperatureRange);
		SelectObject(hdc, dotPen);
		SetBkMode(hdc, OPAQUE);
		MoveToEx(hdc, x + width - rightMargin + topT - 1, rect.top, NULL);
		LineTo(hdc, x + width - rightMargin + bottomT - 1, rect.bottom);
		SetBkMode(hdc, TRANSPARENT);
		SelectObject(hdc, pen);

		if(layer->GetSelection()) {
			HPEN boldPen = CreatePen(0, 3, ((type) ? layer->GetParticleSelectionColor() : 0));
			SelectObject(hdc, boldPen);
			MoveToEx(hdc, rect.left + 1, rect.top + 1, NULL);
			LineTo(hdc, rect.left + 1, rect.bottom - 1);
			LineTo(hdc, rect.right - 2, rect.bottom - 1);
			LineTo(hdc, rect.right - 2, rect.top + 1);
			LineTo(hdc, rect.left + 1, rect.top + 1);
			SelectObject(hdc, pen);
			DeleteObject(boldPen);
		}
		
		MoveToEx(hdc, x + width - rightMargin + 10, rect.top, NULL);
		LineTo(hdc, x + width - rightMargin + 10, rect.bottom);
		
		TEXTMETRIC tMetric;
		GetTextMetrics(hdc, &tMetric);
		if (h > tMetric.tmHeight/2) {
			SetTextAlign(hdc, TA_LEFT);
			SetTextColor(hdc, 0x0);
			TextOut(hdc, x + width - rightMargin + 14, (rect.bottom + rect.top)/2 - tMetric.tmHeight/2, layer->ToString(CLayer::HEIGHT, 4).c_str(), layer->ToString(CLayer::HEIGHT, 4).size());
			SetTextAlign(hdc, TA_CENTER);
			SetTextColor(hdc, 0xffffff);
			TextOut(hdc, (x + width - rightMargin)/2, (rect.bottom + rect.top)/2 - tMetric.tmHeight/2, layer->ToString((type) ? CLayer::PARTICLE : CLayer::DENSITY, 4).c_str(), layer->ToString((type) ? CLayer::PARTICLE : CLayer::DENSITY, 4).size());
		}
		
		dy += h;
		MoveToEx(hdc, x, y + height - dy, NULL);
		LineTo(hdc, x + width - rightMargin + 16, y + height - dy);

		//draw grid
		MoveToEx(hdc, x, y + height - dy + 3, NULL);
		LineTo(hdc, x, y + height - dy - 3);
		MoveToEx(hdc, x + (width - rightMargin)/4, y + height - dy + 3, NULL);
		LineTo(hdc, x + (width - rightMargin)/4, y + height - dy - 3);
		MoveToEx(hdc, x + (width - rightMargin)/2, y + height - dy + 3, NULL);
		LineTo(hdc, x + (width - rightMargin)/2, y + height - dy - 3);
		MoveToEx(hdc, x + (width - rightMargin)/4*3, y + height - dy +3, NULL);
		LineTo(hdc, x + (width - rightMargin)/4*3, y + height - dy - 3);
		MoveToEx(hdc, x + (width - rightMargin) - 1, y + height - dy + 3, NULL);
		LineTo(hdc, x + (width - rightMargin) - 1, y + height - dy - 3);
//.........这里部分代码省略.........
开发者ID:Sergiomi,项目名称:white_monster,代码行数:101,代码来源:SnowModelLayers.cpp


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