`
javalurker
  • 浏览: 22656 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

Text Transitions

阅读更多
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.text.Text;
import javafx.scene.text.TextOrigin;
import javafx.scene.text.Font;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;

def BASE_WIDTH = 800;
def BASE_HEIGHT = 600;
def MARGIN = 20;

var backgroundRect = Rectangle
{
x:        0
y:        0
width:    BASE_WIDTH
height:   BASE_HEIGHT

onMouseClicked: function(event) { t.playFromStart() }
}

var boundingRect = Rectangle
{
x:            MARGIN * 2
y:            BASE_HEIGHT * 2 / 3 - MARGIN
width:        BASE_WIDTH - MARGIN * 4
height:       BASE_HEIGHT - (BASE_HEIGHT * 2 / 3)
fill:         Color.rgb(255, 255, 255, 0.2)
stroke:       Color.WHITE
strokeWidth:  2
}

var displayedText = Text
{
x: boundingRect.x + MARGIN
y: boundingRect.y + MARGIN
wrappingWidth: boundingRect.width - MARGIN * 2
content: ""
font: Font { size: 36 }
textOrigin: TextOrigin.TOP
//stroke: Color.BLACK
fill: Color.WHITE
effect: DropShadow {}
}

def FINAL_TEXT = "I was trying to get the text to wrap, but the text layout engine would keep putting a character on the previous line until the full word was visible.";
var charCount = 0 on replace
{
var textToDisplay = FINAL_TEXT.substring(0, charCount);
displayedText.content = textToDisplay;
}

Stage
{
title:   "Text demo"
visible: true
scene:   Scene
{
width:   BASE_WIDTH
height:  BASE_HEIGHT
fill:    Color.BLACK
content:
[
backgroundRect,
boundingRect,
displayedText
]
}
}

var t = Timeline
{
keyFrames:
[
// In reality the speed would be per letter so the times would
// be computed dynamically.  I have an idea of how to do that.
// Initial experiments also suggest that the speed of displaying
// each letter should be relative to the width of the letter.
KeyFrame { time:  0s, values: charCount => 0 }
KeyFrame { time:  3s, values: charCount => FINAL_TEXT.length() }
]
};
t.play();
分享到:
评论

相关推荐

    文本过渡动画效果

    NRTextTransitions is a category in UIView that makes easier handling animated text transitions for UILabel, UITextView and UITextField. As the standard +[UIView animateWithDuration:animations:] is not...

    Android代码-Transitions-Everywhere

    Transitions Everywhere Backport of Android Transitions API. Animations backported to Android 4.0 . API compatible with ...text.setVisibility(visible ? View.VISIBLE : View.GONE); Article and sample ap

    Python 3 Using ChatGPT/GPT-4

    This book is intended primarily for ... Next, the text transitions to Generative AI, discussing its distinction from Conversational AI. Popular platforms and models, including ChatGPT, GPT-4, and thei

    到处无处不在的转换:在Jetpack Transitions Library之上的一组额外转换

    在平台中标记为@hide的内部过渡: Recolor , Rotate , ChangeText和Crossfade 。 另外两个过渡:缩放和翻译。 快速开始 如果您将29(Q)指定为targetSdkVersion则应使用此版本: dependencies { ...

    The Book of CSS3

    With real-world examples and a focus on results, The Book of CSS3 shows you how to transform ordinary text into stunning, richly detailed web pages fit for any browser. You'll master the latest ...

    CSS The Definitive Guide 4th Edition 2017年出版1088页

    speed development, avoid potential bugs, and add life and depth to your applications through layout, transitions and animations, borders, backgrounds, text properties, and many other tools and ...

    text-recognizer:PyTorch中的文本识别器,基于“全栈深度学习课程”中教授的项目和最佳实践,结合了Claudio Jolowicz的Hypermodern Python

    设置待定去做 创建字词 make_wordpieces.py build_transitions.py 将IAM目标编码为单词的转换 换能器损耗函数[]带单词的训练[]实现wandb回调进行日志记录[]实施每次点击费用[]窗口图像[]火车骨干[]伯特培训,如何?...

    CSS3伪三维径向圆形按钮,无JS及图片,纯HTML.rar

    text-shadow transitions gradients :nth-child() pseudo-class Opera浏览器和Firefox浏览器对于阴影使用的是box-shadow inset, 而Webkit浏览器(如谷歌浏览器)使用的是background:-webkit-gradient. 谷歌下个...

    FairyGUI-Unity-Plugin-3.4.0.zip

    - NEW: Transitions now support playing partially and pausing. - IMPROVED: Change the way of registering bitmap font. - FIXED: A GButton pivot issue. - FIXED: Correct text align behavior. 2.3.0 - NEW...

    Mastering CSS

    Rich begins your CSS training with a review of CSS best practices, such as using a good text editor to automate your authoring and setting up a CSS baseline. You then move on to create a responsive ...

    unity场景过渡进度条源码USplash Screen 1.5.7

    - Structure Array, you can create all the transitions you want. - Sample animations included. . - Adjustable time: FadeIn, Show, FadeOut, and next transition. - Fully Customizable.

    CSS The Definitive Guide 4th Edition

    If you’re a web designer or app developer interested in sophisticated page styling, improved accessibility, and saving time... borders, backgrounds, text properties, and many other tools and techniques.

    Learning Web Design: A Beginner’s Guide to HTML... ..., 5th Edition

    Transitions, Transforms, and Animation D19. More CSS Techniques D20. Modern Web Development Tools Part IV. JavaScript for Behavior D21. Introduction to JavaScript D22. Using JavaScript Part V. Web ...

    Architecting Modern Apps,Part 1

    See how technologies like Text Kit, Dynamics, and Auto Layout make it easy to build flexible, modern interfaces. Gain expanded control over your user interface with powerful new animation APIs to ...

    iOS7 Day-by-Day

    Day 21 :: Multi-column TextKit text rendering Day 22 :: Downloadable Fonts Day 23 :: Multipeer Connectivity Day 24 :: The End Each day's post will have an associated sample project so that you can see...

    HDI-Silverlight-source-Printing_CS

    <TextBlock x:Name="contentPresenter" Margin="7,0" HorizontalAlignment="Center" VerticalAlignment="Center" OpacityMask="{x:Null}" RenderTransformOrigin="0.5,0.5" Foreground="White" Text="{...

    Cocos2D_Game_Development_中文版(全)

     转换(Transitions):从一个场景移动到另外一个不同风格的场景  菜单(Menus):创建内部菜单  文本渲染(Text Rendering):支持标签和HTML标签动作  文档(Documents):编程指南 + API参考 + 视频教学 +...

    MPEG Video Wizard

    insert simple transitions with video special effect. 3. an integrated text and graphics title editor. 4. still image overlay for text and logo insertion. 5. two audio tracks for mixing voice and ...

    Cocos2d-html5-v2.0

     转换(Transitions):从一个场景移动到另外一个不同风格的场景 菜单(Menus):创建内部菜单   文本渲染(Text Rendering):支持标签和HTML标签动作   文档(Documents):编程指南 + API参考 + 视频教学 +...

    The Essential Guide to Flex 2 with ActionScript 3.0 源代码

    * Create transitions * Create data-driven applications with XML * Interface Flex with ColdFusion * Understand the power of states Flex 2 represents something of a revolution in web applications. It ...

Global site tag (gtag.js) - Google Analytics