本文整理汇总了C++中ImageActor类的典型用法代码示例。如果您正苦于以下问题:C++ ImageActor类的具体用法?C++ ImageActor怎么用?C++ ImageActor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageActor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHeightForWidth
float GetHeightForWidth( Actor actor, float width )
{
Vector3 size = actor.GetCurrentSize();
float height = 0.f;
TextActor textActor = TextActor::DownCast( actor );
if( textActor )
{
Font font = textActor.GetFont();
if( !font )
{
font = Font::New();
}
size = font.MeasureText( textActor.GetText() );
}
ImageActor imageActor = ImageActor::DownCast( actor );
if( ( imageActor ) && ( imageActor.GetImage() ) )
{
Image image = imageActor.GetImage();
size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), 0.f );
}
height = size.height / ( size.width / width );
return height;
}
示例2: UtcDaliSwirlDefaultValuesEffect
static void UtcDaliSwirlDefaultValuesEffect()
{
ToolkitTestApplication application;
Toolkit::SwirlEffect effect = Toolkit::SwirlEffect::New(true);
DALI_TEST_CHECK( effect );
BitmapImage image = CreateBitmapImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
actor.SetShaderEffect( effect );
Stage::GetCurrent().Add( actor );
application.SendNotification();
application.Render();
// Gets converted to opengl viewport coordinates
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetAnglePropertyName().c_str(),
0.0f ) );
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetCenterPropertyName().c_str(),
Vector2(0.5f, 0.5f) ) );
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetRadiusPropertyName().c_str(),
1.0f ) );
}
示例3: UtcDaliRippleCustomValuesEffect
static void UtcDaliRippleCustomValuesEffect()
{
ToolkitTestApplication application;
Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
DALI_TEST_CHECK( effect );
BitmapImage image = CreateBitmapImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
effect.SetAmplitude( 0.5f );
effect.SetCenter( Vector2( 10.0f, 10.0f ) );
effect.SetTime( 2.0f );
actor.SetShaderEffect( effect );
Stage::GetCurrent().Add( actor );
application.SendNotification();
application.Render();
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetAmplitudePropertyName().c_str(),
0.5f ) );
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetCenterPropertyName().c_str(),
Vector2( 10.0f, 10.0f ) ) );
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetTimePropertyName().c_str(),
2.0f ) );
}
示例4: UtcDaliObjectRegistrySignalImageActorCreated
int UtcDaliObjectRegistrySignalImageActorCreated(void)
{
TestApplication application;
ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
static const char* TestImageFilename = "icon_wrt.png";
Image image = ResourceImage::New(TestImageFilename);
bool verified = false;
TestImageActorCallback test(verified);
Dali::RefObject* objectPointer = NULL;
TestObjectDestroyedCallback test2(verified, objectPointer);
registry.ObjectCreatedSignal().Connect(&application, test);
registry.ObjectDestroyedSignal().Connect(&application, test2);
{
ImageActor actor = ImageActor::New(image);
DALI_TEST_CHECK( test.mSignalVerified );
verified = false;
objectPointer = actor.GetObjectPtr();
}
DALI_TEST_CHECK( test.mSignalVerified );
END_TEST;
}
示例5: NewItem
/**
* Create an Actor to represent a visible item.
* @param itemId
* @return the created actor.
*/
virtual Actor NewItem(unsigned int itemId)
{
// Create an test actor for this item
ImageActor actor = CreateSolidColorActor(Color::RED);
actor.SetSize(64.0f, 64.0f);
return actor;
}
示例6: UtcDaliShearEffectCustomValues
static void UtcDaliShearEffectCustomValues()
{
ToolkitTestApplication application;
Toolkit::ShearEffect effect = Toolkit::ShearEffect::New();
DALI_TEST_CHECK( effect );
BitmapImage image = CreateBitmapImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
const float angleXAxis(10.0f);
const float angleYAxis(22.5f);
const Vector2 centerValue(50.0f, 100.0f);
effect.SetAngleXAxis( angleXAxis );
effect.SetAngleYAxis( angleYAxis );
effect.SetCenter( centerValue );
actor.SetShaderEffect(effect);
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleXAxisPropertyName().c_str(), angleXAxis ) );
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleYAxisPropertyName().c_str(), angleYAxis ) );
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), ToScreenPosition(centerValue) ) );
}
示例7: UtcDaliSpotCustomValuesEffect
int UtcDaliSpotCustomValuesEffect(void)
{
ToolkitTestApplication application;
Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
DALI_TEST_CHECK( effect );
BitmapImage image = CreateBitmapImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
effect.SetCenter( Vector2(480.0f, 800.0f) );
effect.SetRadius( 5.0f );
actor.SetShaderEffect( effect );
Stage::GetCurrent().Add( actor );
application.SendNotification();
application.Render();
// Gets converted to opengl viewport coordinates
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetCenterPropertyName().c_str(),
Vector2(480.0f, 800.0f) ) );
DALI_TEST_CHECK(
application.GetGlAbstraction().CheckUniformValue(
effect.GetRadiusPropertyName().c_str(),
5.0f ) );
END_TEST;
}
示例8: UtcDaliImageActorUseImageAlpha04
int UtcDaliImageActorUseImageAlpha04(void)
{
TestApplication application;
tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
RenderTask task = taskList.GetTask( 0u );
task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
application.SendNotification();
application.Render(0);
ImageActor actor = ImageActor::New( image );
application.SendNotification();
application.Render(0);
actor.SetBlendMode( BlendingMode::ON );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
actor.SetSize(100, 50);
application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
END_TEST;
}
示例9: GetNaturalSize
Vector3 GetNaturalSize( Actor actor )
{
Vector3 size = actor.GetCurrentSize();
const float depth = size.depth;
// Get natural size for TextActor.
TextActor textActor = TextActor::DownCast( actor );
if( textActor )
{
Font font = textActor.GetFont();
if( !font )
{
font = Font::New();
}
size = font.MeasureText( textActor.GetText() );
size.depth = depth;
}
// Get natural size for ImageActor.
// TODO: currently it doesn't work as expected.
ImageActor imageActor = ImageActor::DownCast( actor );
if( ( imageActor ) && ( imageActor.GetImage() ) )
{
Image image = imageActor.GetImage();
size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
}
return size;
}
示例10: UtcDaliIrisEffectCustomValues
static void UtcDaliIrisEffectCustomValues()
{
ToolkitTestApplication application;
Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
DALI_TEST_CHECK( effect );
BitmapImage image = CreateBitmapImage();
ImageActor actor = ImageActor::New( image );
actor.SetSize( 100.0f, 100.0f );
const float radiusValue(23.0f);
const Vector2 centerValue(0.2f, 0.7f);
const float blendFactorValue(10.0f);
effect.SetRadius( radiusValue );
effect.SetCenter( centerValue );
effect.SetBlendFactor( blendFactorValue );
actor.SetShaderEffect(effect);
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
TestGlAbstraction& gl = application.GetGlAbstraction();
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
}
示例11: DoApply
static void DoApply( ImageActor actor, const std::string& maskImage, const Vector2& maskSize, Vector4 maskBorder )
{
const char* ALPHA_MASK_VERTEX_SHADER_SOURCE =
"uniform vec2 uImageSize; \n"
"uniform vec2 uMaskSize; \n"
"varying vec2 vMaskTexCoord; \n"
" \n"
"void main() \n"
"{ \n"
" gl_Position = uMvpMatrix * vec4(aPosition, 1.0); \n"
" \n"
" // Ignore mask UVs for image \n"
" \n"
" highp vec2 halfImageSize = uImageSize * 0.5; \n"
" vTexCoord = (aPosition.xy + halfImageSize) / uImageSize; \n"
" \n"
" // UVs were calculated for image size, so convert for mask size \n"
" \n"
" highp vec2 halfMaskSize = uMaskSize * 0.5; \n"
" highp vec2 halfSizeDelta = halfImageSize - halfMaskSize; \n"
" \n"
" highp vec2 maskPosition = aPosition.xy; \n"
" maskPosition.x -= halfSizeDelta.x * sign(aPosition.x); \n"
" maskPosition.y -= halfSizeDelta.y * sign(aPosition.y); \n"
" \n"
" vMaskTexCoord = (maskPosition + halfMaskSize) / uMaskSize; \n"
"} \n";
const char* ALPHA_MASK_FRAGMENT_SHADER_SOURCE =
"varying vec2 vMaskTexCoord; \n"
" \n"
"void main() \n"
"{ \n"
" highp vec4 mask = texture2D(sEffect, vMaskTexCoord); \n"
" gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(1,1,1,mask.a); \n"
"} \n";
ShaderEffect maskEffect = ShaderEffect::New( ALPHA_MASK_VERTEX_SHADER_SOURCE,
ALPHA_MASK_FRAGMENT_SHADER_SOURCE,
GeometryType( GEOMETRY_TYPE_IMAGE ),
ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
maskEffect.SetEffectImage( Image::New( maskImage ) );
maskEffect.SetUniform( "uImageSize", Vector2(0,0) /*Constrained to actor size*/ );
maskEffect.ApplyConstraint( Constraint::New<Vector2>( maskEffect.GetPropertyIndex("uImageSize"),
Source(actor, Actor::SIZE),
NinePatchMaskEffectSizeConstraint() ) );
maskEffect.SetUniform( "uMaskSize", maskSize );
// Actor must provide nine-patch style geometry for this effect to work
actor.SetStyle( ImageActor::STYLE_NINE_PATCH );
actor.SetNinePatchBorder( maskBorder );
actor.SetShaderEffect( maskEffect );
}
示例12: UtcDaliImageActorPropertyIndices
int UtcDaliImageActorPropertyIndices(void)
{
TestApplication application;
Actor basicActor = Actor::New();
ImageActor imageActor = ImageActor::New();
Property::IndexContainer indices;
imageActor.GetPropertyIndices( indices );
DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() );
DALI_TEST_EQUALS( indices.size(), imageActor.GetPropertyCount(), TEST_LOCATION );
END_TEST;
}
示例13: UtcDaliImageActorSetImage
int UtcDaliImageActorSetImage(void)
{
TestApplication application;
ImageActor actor = ImageActor::New(Image());
DALI_TEST_CHECK(actor);
actor.SetImage( Image() );
DALI_TEST_CHECK(!actor.GetImage());
END_TEST;
}
示例14: UtcDaliDisplacementEffectTestSetProperty
// Positive test case for a method
int UtcDaliDisplacementEffectTestSetProperty(void)
{
ToolkitTestApplication application;
tet_infoline("UtcDaliDisplacementEffectTestSetProperty");
Toolkit::DisplacementEffect effect = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::DISPLACED);
DALI_TEST_CHECK( effect );
ImageActor actor = ImageActor::New( Image::New(TEST_IMAGE_FILE_NAME) );
actor.SetSize( 100.0f, 100.0f );
actor.SetShaderEffect( effect );
Stage::GetCurrent().Add( actor );
Toolkit::DisplacementEffect effect2 = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::FIXED);
DALI_TEST_CHECK( effect );
ImageActor actor2 = ImageActor::New( Image::New(TEST_IMAGE_FILE_NAME) );
actor2.SetSize( 100.0f, 100.0f );
actor2.SetShaderEffect( effect2 );
Stage::GetCurrent().Add( actor2 );
Vector3 testVector3 = Vector3(45.0f, 55.0f, 65.0f);
float testFloat = 0.623f;
effect.SetLightDirection(testVector3);
effect.SetAmbientLightColorProperty(testVector3);
effect.SetDiffuseLightColorProperty(testVector3);
effect.SetStateProperty(testFloat);
effect.SetLightingMultiplierProperty(testFloat);
effect.SetHeightScaleProperty(testFloat);
effect2.SetFixedNormalProperty(testVector3);
application.SendNotification();
application.Render(0);
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightDirectionPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetAmbientLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetDiffuseLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetStatePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightingMultiplierPropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetHeightScalePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
Vector3 normalizedVector3(testVector3);
normalizedVector3.Normalize();
DALI_TEST_EQUALS( effect2.GetProperty( effect2.GetPropertyIndex( effect2.GetFixedNormalPropertyName() ) ).Get<Vector3>(), normalizedVector3, TEST_LOCATION );
END_TEST;
}
示例15: UtcDaliImageActorImageProperty
int UtcDaliImageActorImageProperty(void)
{
TestApplication application;
Image image = Image::New( "MY_PATH" );
ImageActor imageActor = ImageActor::New( image );
Stage::GetCurrent().Add( imageActor );
application.SendNotification();
application.Render();
Property::Value imageMap = imageActor.GetProperty( ImageActor::IMAGE );
DALI_TEST_CHECK( imageMap.HasKey( "filename" ) );
DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
END_TEST;
}