void FMovieSceneColorTrackInstance::Update(EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance) { for (auto ObjectPtr : RuntimeObjects) { UObject* Object = ObjectPtr.Get(); if ( Object != nullptr ) { if ( ColorType == EColorType::Slate ) { FSlateColor ColorValue = PropertyBindings->GetCurrentValue<FSlateColor>( Object ); FLinearColor LinearColor = ColorValue.GetSpecifiedColor(); if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, LinearColor ) ) { FSlateColor NewColor( LinearColor ); PropertyBindings->CallFunction<FSlateColor>( Object, &NewColor ); } } else if ( ColorType == EColorType::Color ) { // We assume the color we get back is in sRGB, assigning it to a linear color will implicitly // convert it to a linear color instead of using ReinterpretAsLinear which will just change the // bytes into floats using divide by 255. FColor SrgbColor = PropertyBindings->GetCurrentValue<FColor>( Object ); FLinearColor LinearColorValue = SrgbColor; bool bConvertBackToSRgb = true; if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, LinearColorValue ) ) { // Light components have to be handled specially here because their set function takes two values, the linear color // and whether or not the linear color needs to be converted back to sRGB. All other other set function cases should // follow the sequencer convention of having a single parameter of the correct type, which in this case is an FColor // already in sRGB format. ULightComponent* LightComponent = Cast<ULightComponent>( Object ); if ( LightComponent != nullptr ) { LightComponent->SetLightColor( LinearColorValue, bConvertBackToSRgb ); } else { FColor SRgbColorValue = LinearColorValue.ToFColor( bConvertBackToSRgb ); PropertyBindings->CallFunction<FColor>( Object, &SRgbColorValue ); } } } else { FLinearColor ColorValue = PropertyBindings->GetCurrentValue<FLinearColor>( Object ); if ( ColorTrack->Eval( UpdateData.Position, UpdateData.LastPosition, ColorValue ) ) { PropertyBindings->CallFunction<FLinearColor>( Object, &ColorValue ); } } } } }
void AFloatingText::SetOpacity( const float NewOpacity ) { const FLinearColor NewColor = FLinearColor( 0.6f, 0.6f, 0.6f ).CopyWithNewOpacity( NewOpacity ); // @todo vreditor: Tweak brightness const FColor NewFColor = NewColor.ToFColor( false ); check( TextComponent != nullptr ); // if( NewOpacity >= 1.0f - KINDA_SMALL_NUMBER ) // @todo vreditor ui: get fading/translucency working again! // { if( TextComponent->GetMaterial( 0 ) != MaskedTextMaterial ) { TextComponent->SetTextMaterial( MaskedTextMaterial ); } // } // else // { // if( TextComponent->GetMaterial( 0 ) != TranslucentTextMaterial ) // { // TextComponent->SetTextMaterial( TranslucentTextMaterial ); // } // } if( NewFColor != TextComponent->TextRenderColor ) { TextComponent->SetTextRenderColor( NewFColor ); } check( LineMaterialMID != nullptr ); static FName ColorAndOpacityParameterName( "ColorAndOpacity" ); LineMaterialMID->SetVectorParameterValue( ColorAndOpacityParameterName, NewColor ); }
bool UGAAbilityBase::LineTraceSingleByChannelFromCamera(float Range, ETraceTypeQuery TraceChannel, bool bTraceComplex, FHitResult& OutHit, EDrawDebugTrace::Type DrawDebugType, bool bIgnoreSelf, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime) { FVector Start = FVector::ZeroVector; if (OwnerCamera) { Start = OwnerCamera->GetComponentLocation(); } else { FRotator UnusedRot; POwner->GetActorEyesViewPoint(Start, UnusedRot); } FVector End = (POwner->GetBaseAimRotation().Vector() * Range) + Start; ECollisionChannel CollisionChannel = UEngineTypes::ConvertToCollisionChannel(TraceChannel); static const FName LineTraceSingleName(TEXT("AbilityLineTraceSingle")); FCollisionQueryParams Params(LineTraceSingleName, bTraceComplex); bool bHit = World->LineTraceSingleByChannel(OutHit, Start, End, CollisionChannel, Params); #if ENABLE_DRAW_DEBUG if (DrawDebugType != EDrawDebugTrace::None) { bool bPersistent = DrawDebugType == EDrawDebugTrace::Persistent; float LifeTime = (DrawDebugType == EDrawDebugTrace::ForDuration) ? DrawTime : 0.f; // @fixme, draw line with thickness = 2.f? if (bHit && OutHit.bBlockingHit) { // Red up to the blocking hit, green thereafter ::DrawDebugLine(World, Start, OutHit.ImpactPoint, TraceColor.ToFColor(true), bPersistent, LifeTime); ::DrawDebugLine(World, OutHit.ImpactPoint, End, TraceHitColor.ToFColor(true), bPersistent, LifeTime); ::DrawDebugPoint(World, OutHit.ImpactPoint, 16, TraceColor.ToFColor(true), bPersistent, LifeTime); } else { // no hit means all red ::DrawDebugLine(World, Start, End, TraceColor.ToFColor(true), bPersistent, LifeTime); } } #endif return bHit; }
void FColorStructCustomization::OnSetColorFromColorPicker( FLinearColor NewColor ) { FString ColorString; if( bIsLinearColor ) { ColorString = NewColor.ToString(); } else { // Handled by the color picker const bool bSRGB = false; FColor NewFColor = NewColor.ToFColor(bSRGB); ColorString = NewFColor.ToString(); } StructPropertyHandle->SetValueFromFormattedString( ColorString, bIsInteractive ? EPropertyValueSetFlags::InteractiveChange : 0 ); }
bool UPaperGroupedSpriteComponent::UpdateInstanceColor(int32 InstanceIndex, FLinearColor NewInstanceColor, bool bMarkRenderStateDirty) { if (PerInstanceSpriteData.IsValidIndex(InstanceIndex)) { FSpriteInstanceData& InstanceData = PerInstanceSpriteData[InstanceIndex]; InstanceData.VertexColor = NewInstanceColor.ToFColor(/*bSRGB=*/ false); if (bMarkRenderStateDirty) { MarkRenderStateDirty(); } return true; } else { return false; } }
void UBasicVolumeComponent::DrawDebugOctree(const FLinearColor& Color, float Duration, float Thickness) { if (m_octree.IsValid()) { m_octree->Traverse([=](FSparseOctreeNode* node) -> ETraverseOptions { if (node->m_hasChildren) { return ETraverseOptions::Continue; } UVoreealBlueprintLibrary::DrawDebugRegion(this, this->GetComponentTransform(), node->m_bounds, Color.ToFColor(true), Duration, Thickness); return ETraverseOptions::Skip; }); } }
void SColorGradientEditor::DrawGradientStopMark( const FGradientStopMark& Mark, const FGeometry& Geometry, float XPos, const FLinearColor& Color, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FSlateRect& InClippingRect, ESlateDrawEffect::Type DrawEffects, bool bColor, const FWidgetStyle& InWidgetStyle ) const { static const FSlateBrush* WhiteBrush = FEditorStyle::GetBrush("WhiteBrush"); static const FSlateBrush* ColorStopBrush = FEditorStyle::GetBrush("Sequencer.Timeline.ScrubHandleDown"); static const FSlateBrush* AlphaStopBrush = FEditorStyle::GetBrush("Sequencer.Timeline.ScrubHandleUp"); static const FLinearColor SelectionColor = FEditorStyle::GetSlateColor("SelectionColor").GetColor( InWidgetStyle ); const float HandleSize = 13.0f; bool bSelected = Mark == SelectedStop; if( bSelected ) { // Show selected stops above other stops ++LayerId; } // Draw a box for the non colored area FSlateDrawElement::MakeBox ( OutDrawElements, LayerId, Geometry.ToPaintGeometry( FVector2D( XPos-HandleRect.Left, HandleRect.Top ), FVector2D( HandleRect.Right, HandleRect.Bottom ) ), bColor ? ColorStopBrush : AlphaStopBrush, InClippingRect, DrawEffects, bSelected ? SelectionColor : FLinearColor::White ); // Draw a box with the gradient stop color FSlateDrawElement::MakeBox ( OutDrawElements, LayerId+1, Geometry.ToPaintGeometry( FVector2D( XPos-HandleRect.Left+3, bColor ? HandleRect.Top+3.0f : HandleRect.Top+6), FVector2D( HandleRect.Right-6, HandleRect.Bottom-9 ) ), WhiteBrush, InClippingRect, DrawEffects, Color.ToFColor(false) ); }
void SPropertyEditorColor::SetColor(FLinearColor NewColor) { const TSharedRef< FPropertyNode > PropertyNode = PropertyEditor->GetPropertyNode(); UProperty* Property = PropertyNode->GetProperty(); check(Property); FReadAddressList ReadAddresses; PropertyNode->GetReadAddress( false, ReadAddresses, false ); if( ReadAddresses.Num() ) { GEditor->BeginTransaction( NSLOCTEXT("UnrealEd", "SetColorProperty", "Set Color Property") ); PropertyNode->NotifyPreChange(Property, PropertyUtilities->GetNotifyHook()); for( int32 AddrIndex = 0; AddrIndex < ReadAddresses.Num(); ++AddrIndex ) { const uint8* Addr = ReadAddresses.GetAddress(AddrIndex); if( Addr ) { if( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_Color ) { *(FColor*)Addr = NewColor.ToFColor(false); } else { check( Cast<UStructProperty>(Property)->Struct->GetFName() == NAME_LinearColor ); *(FLinearColor*)Addr = NewColor; } } } FPropertyChangedEvent ChangeEvent(Property, EPropertyChangeType::ValueSet); PropertyNode->NotifyPostChange( ChangeEvent, PropertyUtilities->GetNotifyHook() ); GEditor->EndTransaction(); } }
int32 UPaperGroupedSpriteComponent::AddInstanceWithMaterial(const FTransform& Transform, UPaperSprite* Sprite, UMaterialInterface* MaterialOverride, bool bWorldSpace, FLinearColor Color) { const int32 NewInstanceIndex = PerInstanceSpriteData.Num(); const FTransform LocalTransform(bWorldSpace ? Transform.GetRelativeTransform(ComponentToWorld) : Transform); FSpriteInstanceData& NewInstanceData = *new (PerInstanceSpriteData)FSpriteInstanceData(); SetupNewInstanceData(NewInstanceData, NewInstanceIndex, LocalTransform, Sprite, MaterialOverride, Color.ToFColor(/*bSRGB=*/ false)); MarkRenderStateDirty(); UNavigationSystem::UpdateNavOctree(this); return NewInstanceIndex; }
void FSequencerFolderNode::OnColorPickerPicked(FLinearColor NewFolderColor) { MovieSceneFolder.SetFolderColor(NewFolderColor.ToFColor(false)); }
void ULog::K2_PrintStringOverTime(const FString& InString, float Duration, FLinearColor TextColor) { GEngine->AddOnScreenDebugMessage(-1, Duration, TextColor.ToFColor(true), InString); return; }
void UVisualLoggerKismetLibrary::LogBox(UObject* WorldContextObject, FBox Box, FString Text, FLinearColor ObjectColor, FName CategoryName) { #if ENABLE_VISUAL_LOG const ELogVerbosity::Type DefaultVerbosity = ELogVerbosity::Log; FVisualLogger::GeometryShapeLogf(WorldContextObject, FLogCategoryBase(*CategoryName.ToString(), DefaultVerbosity, DefaultVerbosity), DefaultVerbosity, INDEX_NONE, Box, FMatrix::Identity, ObjectColor.ToFColor(true), *Text); #endif }
void UVisualLoggerKismetLibrary::LogLocation(UObject* WorldContextObject, FVector Location, FString Text, FLinearColor Color, float Radius, FName CategoryName) { #if ENABLE_VISUAL_LOG const ELogVerbosity::Type DefaultVerbosity = ELogVerbosity::Log; FVisualLogger::GeometryShapeLogf(WorldContextObject, FLogCategoryBase(*CategoryName.ToString(), DefaultVerbosity, DefaultVerbosity), DefaultVerbosity, INDEX_NONE, Location, Radius, Color.ToFColor(true), *Text); #endif }
int32 SColorBlock::OnPaint( const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const { const FSlateBrush* GenericBrush = FCoreStyle::Get().GetBrush( "GenericWhiteBox" ); const ESlateDrawEffect::Type DrawEffects = ESlateDrawEffect::None; FLinearColor InColor = Color.Get(); if (ColorIsHSV.Get()) { InColor = InColor.HSVToLinearRGB(); } if (IgnoreAlpha.Get()) { InColor.A = 1.f; } const FColor DrawColor = InColor.ToFColor(bUseSRGB.Get()); if( ShowBackgroundForAlpha.Get() && DrawColor.A < 255 ) { // If we are showing a background pattern and the colors is transparent, draw a checker pattern const FSlateBrush* CheckerBrush = FCoreStyle::Get().GetBrush("ColorPicker.AlphaBackground"); FSlateDrawElement::MakeBox( OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), CheckerBrush, MyClippingRect, DrawEffects ); } // determine if it is HDR const float MaxRGB = FMath::Max3(InColor.R, InColor.G, InColor.B); if (MaxRGB > 1.f) { FLinearColor NormalizedLinearColor = InColor / MaxRGB; NormalizedLinearColor.A = InColor.A; const FColor DrawNormalizedColor = InWidgetStyle.GetColorAndOpacityTint() * NormalizedLinearColor.ToFColor(bUseSRGB.Get()); FLinearColor ClampedLinearColor = InColor; ClampedLinearColor.A = InColor.A * MaxRGB; const FColor DrawClampedColor = InWidgetStyle.GetColorAndOpacityTint() * ClampedLinearColor.ToFColor(bUseSRGB.Get()); TArray<FSlateGradientStop> GradientStops; GradientStops.Add( FSlateGradientStop( FVector2D::ZeroVector, DrawNormalizedColor ) ); GradientStops.Add( FSlateGradientStop( AllottedGeometry.Size * 0.5f, DrawClampedColor ) ); GradientStops.Add( FSlateGradientStop( AllottedGeometry.Size, DrawNormalizedColor ) ); FSlateDrawElement::MakeGradient( OutDrawElements, LayerId + 1, AllottedGeometry.ToPaintGeometry(), GradientStops, (AllottedGeometry.Size.X > AllottedGeometry.Size.Y) ? Orient_Vertical : Orient_Horizontal, MyClippingRect, DrawEffects ); } else { FSlateDrawElement::MakeBox( OutDrawElements, LayerId + 1, AllottedGeometry.ToPaintGeometry(), GenericBrush, MyClippingRect, DrawEffects, InWidgetStyle.GetColorAndOpacityTint() * DrawColor ); } return LayerId + 1; }