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


C++ Leaf::Draw方法代码示例

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


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

示例1: Divis

void Tree::Divis(const Point* begin, const Point* end, const int& color)
{
    double* dl = new double(begin->Range(end));
    if(*dl < kleafrate*size/33.3)
    {
        delete dl;
        return;
    }

    Point middle;

    double* rnd = new double(RND());

    if(begin->GetX() == end->GetX() || begin->GetY() == end->GetY())
    {
        int krnd = (*rnd <= 0.5) ? 1 : -1;

        if(begin->GetX() == end->GetX())
            middle.SetXY(begin->GetX() + ((begin->GetX() + krnd * *dl/2 > 0.0) ?
                                          krnd : -krnd) * *dl/2, min(begin->GetY(), end->GetY()) + *dl/2);

        if(begin->GetY() == end->GetY())
            middle.SetXY(min(begin->GetX(), end->GetX()) + *dl/2,
                         begin->GetY() + ((begin->GetY() + krnd * *dl/2 > 0.0) ?
                                          krnd : -krnd) * *dl/2);
    }
    else if(*rnd <= 0.5) middle.SetXY(begin->GetX(), end->GetY());
    else middle.SetXY(end->GetX(), begin->GetY());

    delete dl;

    double *chance = new double(center.Range(&sun)/middle.Range(&sun));

    if(sflowers != 0 && *rnd < 0.025 * *chance)
    {
        f = middle;
        f.Draw(color);
    }
    else
    {
        l = middle;
        if(*rnd < Fi / *chance / 0.8) l.Draw(color3);
        else l.Draw(color4);
    }

    delete chance;
    delete rnd;

    Divis(begin, &middle, color);
    Divis(&middle, end, color);
}
开发者ID:newmen,项目名称:seasons,代码行数:51,代码来源:TREE.CPP

示例2:

void
FallLeaves::Draw(BView* view, int32 frame)
{
	if (fBackBitmap->Lock()) {
		
		// Clear the offscreen buffer
		fBackView->FillRect(fBackView->Bounds());
		
		// Update and draw the leaves
		for (int32 i = fLeaves->CountItems() - 1; ; i--) {
			Leaf* leaf = fLeaves->ItemAt(i);
			if (leaf == NULL)
				break;
			leaf->Update(TICKS_PER_SECOND);
			leaf->Draw(fBackView);
			
			// If the leaf is dead, remove it
			if (leaf->IsDead()) {
				fZUsed[leaf->Z()] = false;
				fLeaves->RemoveItem(leaf);
				delete leaf;
			}
		}
		
		fBackBitmap->Unlock();
	}
	
	bool sort = false;
	
	// Add some new leaves if necessary
	// to replace any dead ones
	while (fLeaves->CountItems() < fAmount) {
		fLeaves->AddItem(_CreateLeaf(view, false));
		sort = true;
	}
	
	// Keep the leaves sorted by Z axis
	if (sort)
		fLeaves->SortItems(cmpz);
	
	view->DrawBitmap(fBackBitmap);
}
开发者ID:drcouzelis,项目名称:HaikuApiExamples,代码行数:42,代码来源:FallLeaves.cpp


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