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


C++ Rectf类代码示例

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


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

示例1: Rectf

void TextParticlesApp::mouseDrag( MouseEvent event )
{
	Rectf r	= Rectf( 0, 0, getWindowWidth(), getWindowHeight() );
	if ( r.contains( event.getPos() )) {
		mCamUi.mouseDrag( event );
	}
}
开发者ID:gregkepler,项目名称:Cinder-Samples,代码行数:7,代码来源:TextParticlesApp.cpp

示例2: Color

void Fluid2DTextureApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );

	// Update the positions and tex coords
	Rectf drawRect = getWindowBounds();
	int limX = mFluid2D.resX() - 1;
	int limY = mFluid2D.resY() - 1;
	float dx = drawRect.getWidth()/(float)limX;
	float dy = drawRect.getHeight()/(float)limY;
	
	for( int j = 0; j < mFluid2D.resY(); ++j ) {
		for( int i = 0; i < mFluid2D.resX(); ++i ) {
			vec2 P = vec2( i*dx, j*dy );
			vec2 uv = mFluid2D.texCoordAt( i, j );

			int idx = j*mFluid2D.resX() + i;
			mTriMesh->getPositions<2>()[idx] = P;
			mTriMesh->getTexCoords0<2>()[idx] = uv;
			
		}
	}

	mTex->bind();
	gl::bindStockShader( gl::ShaderDef().color().texture() );
	gl::draw( gl::VboMesh::create(*mTriMesh) );
	mTex->unbind();
	
	mParams.draw();	
}
开发者ID:andrewfb,项目名称:CinderFx,代码行数:32,代码来源:Fluid2DTextureApp.cpp

示例3: setClippingRegion

//----------------------------------------------------------------------------//
void NullGeometryBuffer::setClippingRegion(const Rectf& region)
{
    d_clipRect.top(ceguimax(0.0f, region.top()));
    d_clipRect.bottom(ceguimax(0.0f, region.bottom()));
    d_clipRect.left(ceguimax(0.0f, region.left()));
    d_clipRect.right(ceguimax(0.0f, region.right()));
}
开发者ID:OpenTechEngine-Libraries,项目名称:CEGUI,代码行数:8,代码来源:GeometryBuffer.cpp

示例4: rectToFit

	///////////////////////////////////////////////////////////
	//
	// TRANSFORMATIONS
	//
	// Fit src inside dst
	Rectf rectToFit( Rectf src, Rectf dst )
	{
		float sw = src.getWidth();
		float sh = src.getHeight();
		float sa = (sw / sh);	// aspect ratio
		float dw = dst.getWidth();
		float dh = dst.getHeight();
		float da = (dw / dh);	// aspect ratio
		// different ratio
		if (da > sa)
		{
			float scale = (dh / sh);
			float gap = (dw - (sw * scale)) / 2.0f;
			return Rectf( gap, 0, dw-gap, dh);
		}
		else if (da < sa)
		{
			float scale = (dw / sw);
			float gap = (dh - (sh * scale)) / 2.0f;
			return Rectf( 0, gap, dw, dh-gap );
		}
		// Same ratio
		else
			return dst;
	}
开发者ID:muglikar,项目名称:Cinder,代码行数:30,代码来源:qb.cpp

示例5: getValue

//----------------------------------------------------------------------------//
float UnifiedDim::getValue(const Window&, const Rectf& container) const
{
    switch (d_what)
    {
        case DT_LEFT_EDGE:
        case DT_RIGHT_EDGE:
        case DT_X_POSITION:
        case DT_X_OFFSET:
        case DT_WIDTH:
            return CoordConverter::asAbsolute(d_value, container.getWidth());
            break;

        case DT_TOP_EDGE:
        case DT_BOTTOM_EDGE:
        case DT_Y_POSITION:
        case DT_Y_OFFSET:
        case DT_HEIGHT:
            return CoordConverter::asAbsolute(d_value, container.getHeight());
            break;

        default:
            CEGUI_THROW(InvalidRequestException(
                "unknown or unsupported DimensionType encountered."));
            break;
    }
}
开发者ID:Toby91,项目名称:DDEngine,代码行数:27,代码来源:Dimensions.cpp

示例6:

void
TitleScreen::make_tux_jump()
{
  static bool jumpWasReleased = true;
  Sector& sector  = m_titlesession->get_current_sector();
  Player& tux = sector.get_player();

  m_controller->update();
  m_controller->press(Control::RIGHT);

  // Check if we should press the jump button
  Rectf lookahead = tux.get_bbox();
  lookahead.set_right(lookahead.get_right() + 96);
  bool pathBlocked = !sector.is_free_of_statics(lookahead);
  if ((pathBlocked && jumpWasReleased) || !tux.on_ground()) {
    m_controller->press(Control::JUMP);
    jumpWasReleased = false;
  } else {
    jumpWasReleased = true;
  }

  // Wrap around at the end of the level back to the beginning
  if (sector.get_width() - 320 < tux.get_pos().x) {
    sector.activate("main");
    sector.get_camera().reset(tux.get_pos());
  }
}
开发者ID:pelya,项目名称:supertux,代码行数:27,代码来源:title_screen.cpp

示例7: GetWorldRect

//----------------------------------------------------------------------------
bool SizeNode::IsIntersectSizeRange(const SizeNode *node) const
{
	Rectf worldRect = GetWorldRect();
	Rectf nodeWorldRect = node->GetWorldRect();

	return  worldRect.IsIntersect(nodeWorldRect);
}
开发者ID:PhoenixSteam,项目名称:Phoenix3D,代码行数:8,代码来源:PX2SizeNode.cpp

示例8: drawGrid

void drawGrid(const Rectf &bounds, float sx, float sy, const Vec2f &offset)
{
    float x1 = bounds.x1 - utils::math::boundf(bounds.x1 - offset.x, sx);
    float y1 = bounds.y1 - utils::math::boundf(bounds.y1 - offset.y, sy);

    int nx = int(ci::math<float>::ceil(bounds.getWidth() / sx)) + 1;
    int ny = int(ci::math<float>::ceil(bounds.getHeight() / sy)) + 1;

    vector<Vec2f> vertices;
    vertices.reserve((nx + ny) * 4);

    for (int iy = 0; iy < ny; iy++)
    {
        float y = y1 + iy * sy;
        vertices.emplace_back(bounds.x1, y);
        vertices.emplace_back(bounds.x2, y);
    }

    for (int ix = 0; ix < nx; ix++)
    {
        float x = x1 + ix * sx;
        vertices.emplace_back(x, bounds.y1);
        vertices.emplace_back(x, bounds.y2);
    }

    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, vertices.data());
    glDrawArrays(GL_LINES, 0, vertices.size());
    glDisableClientState(GL_VERTEX_ARRAY);
}
开发者ID:neshume,项目名称:new-chronotext-toolkit,代码行数:30,代码来源:GLUtils.cpp

示例9: getSize

void MultiSlider::setup()
{
	float numSliders = (float)mData.size();
	vec2 size = getSize();
	size.y = mSliderHeight = std::max( size.y - mPadding.mTop - mPadding.mBottom,
		( (float)FontSize::SMALL + mPadding.mBottom + mPadding.mTop ) );
	mSliderSpacing = mPadding.mTop;
	size.y = mSliderHeight * numSliders + mPadding.mTop * 2.0f + mPadding.mBottom * 2.0f;
	if( mData.size() > 1 ) size.y += mSliderSpacing * ( numSliders - 1.0f );
	setSize( size );

	vec2 hitRectSize = mHitRect.getSize();
	float width = hitRectSize.x - ( mPadding.mLeft + mPadding.mRight );
	Rectf rect = mHitRect;
	int index = 0;
	for( auto &it : mData ) {
		rect.y1 = mHitRect.y1 + mPadding.mTop + ( mSliderSpacing + mSliderHeight ) * index;
		rect.y2 = rect.y1 + mSliderHeight;

		rect.x1 = mHitRect.x1 + mPadding.mLeft;
		rect.x2 = rect.x1 + width;

		string sliderName = it.mKey;
		LabelRef label = Label::create( sliderName + "_LABEL", sliderName, FontSize::SMALL );
		mLabelsMap[sliderName] = label;
		addSubView( label );

		float labelHeight = label->getHeight();
		float offset = ( rect.getHeight() - labelHeight ) / 2.0f;
		label->setOrigin( vec2( rect.x1, rect.y1 + offset ) );
		index++;
	}
	View::setup();
}
开发者ID:rezaali,项目名称:Cinder-UI,代码行数:34,代码来源:MultiSlider.cpp

示例10: update

void ParticleSystem::update(Timer* timer )
{
	static float prevTime = (float) timer->getSeconds();
	float curTime = (float) timer->getSeconds();
	float dt = curTime - prevTime;
	prevTime = curTime;

	Rectf bounds = mBounds;
	float minX = -kBorder;
	float minY = -kBorder;
	float maxX = bounds.getWidth();
	float maxY = bounds.getHeight();

	// Avoid the borders in the remap because the velocity might be zero.
	// Nothing interesting happens where velocity is zero.
	float dx = (float)(mFluid->resX() - 4) / (float) bounds.getWidth();
	float dy = (float)(mFluid->resY() - 4) / (float) bounds.getHeight();
	for( int i = 0; i < numParticles(); ++i ) {
		Particle& part = mParticles.at( i );
		if( part.pos().x < minX || part.pos().y < minY || part.pos().x >= maxX || part.pos().y >= maxY ) {
			part.reset( newParticleVec(), Rand::randFloat( 0.0f, 1.0f ), mColor );
		}

		float x = part.pos().x * dx + 2.0f;
		float y = part.pos().y * dy + 2.0f;

		Vec2f vel = mFluid->velocity().bilinearSampleChecked( x, y, Vec2f( 0.0f, 0.0f ) );
		part.addForce( vel );

		part.update( mFluid->dt(), dt );
	}
}
开发者ID:chan48,项目名称:Cinder-TouchDesigner-TOP,代码行数:32,代码来源:Particles.cpp

示例11: getAverageFps

void SmilesApp::setup()
{	
    mSmileLimit = 4.0f;
    mSmileAverageNumOfFrames = 10;
    mCamIndex = 0;
    mFps = getAverageFps();
    
    try {
		mCapture = Capture( CAMWIDTH, CAMHEIGHT );
		mCapture.start();
	}
	catch( ... ) {
		console() << "Failed to initialize capture" << std::endl;
	}
    
    mSmileRect = Rectf(300,100,600,400);
    setupSmileDetector(mSmileRect.getInteriorArea().getWidth(), mSmileRect.getInteriorArea().getHeight());
    console()<< mSmileRect.getInteriorArea().getWidth() << mSmileRect.getInteriorArea().getHeight() << endl;
	mSmileThreshold = 0;
	mSmileAverageIndex = 0;
    
    mParams = params::InterfaceGl( "Parameters", Vec2i( 220, 170 ) );
    mParams.addParam( "FPS", &mFps,"", true );
    mParams.addSeparator();
	mParams.addParam( "SmileResponse", &mSmileResponse, "", true );
    mParams.addParam( "SmileThreshold", &mSmileThreshold, "", true );
    
    mParams.addParam( "mSmileLimit", &mSmileLimit );
    mParams.addParam( "mSmileAverageNumOfFrames", &mSmileAverageNumOfFrames );
    
}
开发者ID:redpaperheart,项目名称:CinderMPTSmilesDetector,代码行数:31,代码来源:SmilesApp.cpp

示例12:

	void X11Window::process_window_resize(const Rect &new_rect)
	{
		Rect old_client_area = client_area;
		client_area = new_rect;

		if (site)
		{
			if (old_client_area.left != client_area.left || old_client_area.top != client_area.top)
			{
				(site->sig_window_moved)();
			}

			if (old_client_area.get_width() != client_area.get_width() || old_client_area.get_height() != client_area.get_height())
			{
				Rectf rectf = client_area;
				rectf.left   /= pixel_ratio;
				rectf.top    /= pixel_ratio;
				rectf.right  /= pixel_ratio;
				rectf.bottom /= pixel_ratio;

				if (callback_on_resized)
					callback_on_resized(); // OpenGLWindowProvider::on_window_resized

				(site->sig_resize)(rectf.get_width(), rectf.get_height()); // TopLevelWindow_Impl::on_resize

				if (site->func_window_resize)
					(site->func_window_resize)(rectf);
			}
		}
	}
开发者ID:xubingyue,项目名称:ClanLib,代码行数:30,代码来源:x11_window.cpp

示例13: buildOrthographicProjectionMatrix

void Camera::buildOrthographicProjectionMatrix(Matrix4x4& mat, const Rectf& viewport, float size, float zNear, float zFar, bool flipY)
{
	const float wideSize = (size * viewport.width() ) / viewport.height();
	const float left = -wideSize;
	const float right = wideSize;
	const float top = flipY ? - size : size;
	const float bottom = flipY ? size : -size;
	const float far = -zFar;
	const float near = zNear;

	const float a = 2.0f / (right - left);
	const float b = 2.0f / (top - bottom);
	const float c = -2.0f / (far - near);

	const float tx = -(right + left) / (right - left);
	const float ty = -(top + bottom) / (top - bottom);
	const float tz = -(far + near) / (far - near);

	mat.set(
		a, 0, 0, 0,
		0, b, 0, 0,
		0, 0, c, 0,
		tx, ty, tz, 1,
		false);
}
开发者ID:SylerWang,项目名称:FunFashion,代码行数:25,代码来源:Camera.cpp

示例14: parent_rect

float CoordConverter::getBaseYValue(const Window& window)
{
    const Window* parent = window.getParent();

    const Rectf parent_rect(parent ?
        parent->getChildContentArea(window.isNonClient()).get() :
        Rectf(Vector2f(0, 0), window.getRootContainerSize())
    );

    const float parent_height = parent_rect.getHeight();
    float baseY = parent_rect.d_min.d_y;

    baseY += asAbsolute(window.getArea().d_min.d_y, parent_height);

    switch(window.getVerticalAlignment())
    {
        case VA_CENTRE:
            baseY += (parent_height - window.getPixelSize().d_height) * 0.5f;
            break;
        case VA_BOTTOM:
            baseY += parent_height - window.getPixelSize().d_height;
            break;
        default:
            break;
    }

    return alignToPixels(baseY);
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:28,代码来源:CoordConverter.cpp

示例15: update

void ParticleSoup::update()
{
	static float prevTime = (float)app::getElapsedSeconds();
	float curTime = (float)app::getElapsedSeconds();
	float dt = curTime - prevTime;
	prevTime = curTime;

	Rectf bounds = ci::app::getWindowBounds();
	float minX = -kBorder;
	float minY = -kBorder;
	float maxX = bounds.getWidth();
	float maxY = bounds.getHeight();

	// Avoid the borders in the remap because the velocity might be zero.
	// Nothing interesting happens where velocity is zero.
	float dx = (float)(mFluid->resX() - 4)/(float)bounds.getWidth();
	float dy = (float)(mFluid->resY() - 4)/(float)bounds.getHeight();
	for( int i = 0; i < numParticles(); ++i ) {
		Particle& part = mParticles.at( i );
		if( part.pos().x < minX || part.pos().y < minY || part.pos().x >= maxX || part.pos().y >= maxY ) {
			vec2 P;
			P.x = Rand::randFloat( bounds.x1 + 5.0f, bounds.x2 - 5.0f );
			P.y = Rand::randFloat( bounds.y1 + 5.0f, bounds.y2 - 5.0f );
			float life = Rand::randFloat( 2.0f, 3.0f );
			part.reset( P, life, mColor );
		}

		float x = part.pos().x*dx + 2.0f;
		float y = part.pos().y*dy + 2.0f;
		vec2 vel = mFluid->velocity().bilinearSampleChecked( x, y, vec2( 0.0f, 0.0f ) );
		part.addForce( vel );
		part.update( mFluid->dt(), dt );
	}
}
开发者ID:chaoticbob,项目名称:CinderFx,代码行数:34,代码来源:ParticleSoup.cpp


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