gpt4 book ai didi

wpf - WPF中的星球大战文字效果

转载 作者:行者123 更新时间:2023-12-04 00:12:19 25 4
gpt4 key购买 nike

我们公司的高管已要求在我们的应用程序中为我们的“关于”框集成“星球大战爬行”样式的积分屏幕,我的任务是在一周内完成。

我不知道从哪里开始。我有一种感觉 DoubleAnimation 是我想要查看的地方,但是我如何让文本爬上屏幕并变成一个点是我有点迷失的地方以及如何淡出文本并移动到屏幕中间(如星球大战位)。

这在 WPF 中容易做到还是应该让动画继续?问题是我们的文本会根据安装的版本和用户而变化。

最佳答案

这是我为您整理的快速样本。它使用 3D 并且似乎表现不佳。但它有效!

<Window
x:Class="StarWars.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="480" Width="640" Background="Black">

<Viewport3D ClipToBounds="True" Width="Auto" Height="Auto">
<Viewport3D.Triggers>
<EventTrigger RoutedEvent="Viewport3D.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Translation"
Storyboard.TargetProperty="OffsetY"
To="10"
Duration="0:1:0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Viewport3D.Triggers>
<Viewport3D.Camera>
<PerspectiveCamera
FarPlaneDistance="100"
NearPlaneDistance="1"
FieldOfView="30"
LookDirection="0,25,-13"
UpDirection="0,1,0"
Position="0,2,1.5" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<Model3DGroup.Children>
<AmbientLight Color="#FF808080" />
<GeometryModel3D>
<GeometryModel3D.Transform>
<TranslateTransform3D
x:Name="Translation"
OffsetY="3" />
</GeometryModel3D.Transform>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1,-2,0 1,-2,0 1,1,0 -1,1,0"
TriangleIndices="0 1 2 0 2 3"
TextureCoordinates="0,1 1,1 1,0 0,0"
Normals="0,0,1 0,0,1" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<TextBlock
Foreground="Yellow"
FontFamily="Consolas"
TextAlignment="Center">
Lorem ipsum dolor sit amet,<LineBreak/>
consectetur adipiscing elit.<LineBreak/>
Integer malesuada, massa<LineBreak/>
vitae suscipit dictum, purus<LineBreak/>
dolor volutpat arcu, ac<LineBreak/>
tincidunt erat mauris sed nisi.<LineBreak/>
Sed ac eros ac augue<LineBreak/>
ullamcorper sodales sed id leo.<LineBreak/><LineBreak/>
Suspendisse nibh enim,<LineBreak/>
hendrerit vitae pretium et,<LineBreak/>
gravida in tortor. Lorem ipsum<LineBreak/>
dolor sit amet, consectetur<LineBreak/>
adipiscing elit. Maecenas<LineBreak/>
condimentum enim eu tellus<LineBreak/>
feugiat mollis ac ut arcu.<LineBreak/>
Ut fringilla tempus volutpat.<LineBreak/>
Duis elementum convallis<LineBreak/>
tincidunt.<LineBreak/><LineBreak/>

Mauris lacus tortor,<LineBreak/>
tristique nec congue at,<LineBreak/>
adipiscing sed eros.<LineBreak/><LineBreak/>

In volutpat eros id nunc<LineBreak/>
hendrerit eget aliquet nisi<LineBreak/>
lacinia.<LineBreak/><LineBreak/>

Suspendisse et lorem augue, non eleifend est.
</TextBlock>
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
</Model3DGroup.Children>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</Window>

关于wpf - WPF中的星球大战文字效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3157341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com