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


C++ GuiText::setRelativePosition方法代码示例

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


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

示例1: setup

void PolynomialEvolutionApp::setup()
{
	ci::randSeed( (unsigned int)time( NULL ) );
	
	mSuitcase = new FontSuitcase();
	
	mSuitcase->addFamily( "Heuristica",
						 getAssetPath( "Heuristica-Regular.otf" ).string(),
						 getAssetPath( "Heuristica-Italic.otf" ).string(),
						 getAssetPath( "Heuristica-Bold.otf" ).string(),
						 getAssetPath( "Heuristica-BoldItalic.otf" ).string() );
	
	mScene = new GuiBase();
	mScene->setPosition( Vec2f( 0.0, 0.0 ) );
	mScene->setRelativeDimension( Vec2f( 1.0, 1.0 ) );
	
	mInfoLabel = new GuiText( "", "Heuristica", 14, FontStyle::BOLD, mSuitcase );
	mInfoLabel->setRelativePosition( Vec2f( 0.5, 0.97 ) );
	mInfoLabel->setTextColor( ColorA::white() );
	mInfoLabel->setHighlightColor( ColorA( 0.0, 0.0, 0.0, 0.5 ) );
	mScene->addChild( mInfoLabel );
	
	PolynomialDataRef tFormula(  new PolynomialData( -10.0, 10.0, true, true, ColorA( 0, 1, 0, 1 ) ) );
	tFormula->addComponent( 1.0, 2.0 );
	
	PolynomialDataRef tAssertFormulaA( new PolynomialData( -10.0, 10.0, true, false, ColorA( 1, 1, 0, 1 ) ) );
	tAssertFormulaA->addComponent( 2.0, 1.0 );
	tAssertFormulaA->addComponent( 2.0, 0.0 );
	
	PolynomialDataRef tAssertFormulaB( new PolynomialData( -10.0, 10.0, true, false, ColorA( 1, 1, 0, 1 ) ) );
	tAssertFormulaB->addComponent( 2.0, 1.0 );
	tAssertFormulaB->addComponent( -2.0, 0.0 );
	
	AssertionGroup tAssertGroup = AssertionGroup();
	
	AssertionRef tAssertA = AssertionRef( new Assertion() );
	tAssertA->setDataRhs( tAssertFormulaA );
	tAssertA->setParameterRange( -10.0, 10.0 );
	tAssertA->setType( IS_LESS );
	tAssertA->setMode( FOR_DERIVATIVE, FOR_FUNCTION );
	tAssertGroup.add( tAssertA );
	
	AssertionRef tAssertB = AssertionRef( new Assertion() );
	tAssertB->setDataRhs( tAssertFormulaB );
	tAssertB->setParameterRange( -10.0, 10.0 );
	tAssertB->setType( IS_GREATER );
	tAssertB->setMode( FOR_DERIVATIVE, FOR_FUNCTION );
	tAssertGroup.add( tAssertB );
	
	cout << tAssertGroup.getAssertionString( tFormula ) << endl;
	
	mPopulation = new PolynomialPopulation( tAssertGroup, 1000, 500, 0.1, 1.0 );
	
	{
		mPlotRef = new GuiPlot( "Heuristica", mSuitcase );
		mPlotRef->addInput( tFormula );
		mPlotRef->addInput( tAssertFormulaA );
		mPlotRef->addInput( tAssertFormulaB );
		mPlotRef->setXRange( -10.0, 10.0 );
		mPlotRef->setYRange( -10.0, 10.0 );
		mPlotRef->setFillColor( ColorA( 1, 0, 0, 1 ) );
		mPlotRef->setStrokeColor( ColorA( 1, 1, 0, 1 ) );
		mPlotRef->setStrokeWeight( 1.0 );
		mPlotRef->setRelativePosition( Vec2f( 0.5, 0.5 ) );
		mPlotRef->setRelativeDimension( Vec2f( 0.9, 0.9 ) );
		mScene->addChild( mPlotRef );
	}
}
开发者ID:Hebali,项目名称:CreativeEvolutionCourse,代码行数:68,代码来源:PolynomialEvolutionApp.cpp


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