Infinite Progress And Rotation from shai`s

本文介绍了一种使用旋转图像作为无限进度指示器的方法,通过优化减少内存占用并提高透明度效果。利用特定角度的平台内置旋转能力,仅需两幅图像即可实现八帧动画的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   转载:http://hi.baidu.com/dunwin/blog/item/26abd4ca31c9a6f652664feb.html

 

 

 

 

 

 

When looking at the Makeover demo I posted last week one might assume the rotating wheel animation is a standard animation or gif. This is not the case although I could have gone with that approach I chose to use a different tool to achieve this effect.
I built an infinite progress component which displays a rotating image as an animation, this considerably reduces JAR and heap space usage for an animation that looks quite similar to the one produced by a static animation (which we create from GIF). The reason for this is in the way animations work, animations have no sense of rotation, they store the change to the image (as lines) and when the image rotates the animation sees the entire image as changed and produces a "key frame". Key frames are large both in storage and in memory, to hold a 32x32 pixel animation with 8 keyframes I would need approximately 32x32x8+1024 (1024 for palette). This might not seem big, but with increase in resolution the size rises quite a bit...
Rotation is not always efficient, in fact it can be just as inefficient as a keyframe since it needs to create a new image. However, LWUIT has a special optimization on MIDP (this doesn't not apply to LWUIT on CDC) which uses the platforms built in rotation abilities for square angles (90, 180 & 270) hence removing completely the overhead of the image. This isn't enough since rotating on square angles would produce a jumpy effect, which is why I rotate once to 45 degrees and then rotate 2 images in square angles only thus producing what seems to be 8 images but only paying the cost for 2 images.

Another significant advantage is that unlike animations I can make full use of translucency since the alpha channel isn't removed in these images, this allows for flowing rotation effects.

The rotate method currently makes many assumptions and is mostly useful for square images, however it works rather nicely for all angles which is something that currently plain MIDP doesn't support.

public class InfiniteProgressIndicator extends com.sun.lwuit.Label {
 private Image[] angles;
 private int angle;

 public InfiniteProgressIndicator(Image image) {
     Image fourtyFiveDeg = image.rotate(45);
     angles = new Image[] {image, fourtyFiveDeg, image.rotate(90), fourtyFiveDeg.rotate(90),
         image.rotate(180), fourtyFiveDeg.rotate(180), image.rotate(270), fourtyFiveDeg.rotate(270)};
     getStyle().setBgTransparency(0);
     setIcon(image);
     setAlignment(Component.CENTER);
 }
  
 public void initComponent() {
     getComponentForm().registerAnimated(this);
 }
  
 public boolean animate() {
     angle++;
     setIcon(angles[Math.abs(angle % angles.length)]);
     return true;
 }
}

 

标题基于SpringBoot+Vue的社区便民服务平台研究AI更换标题第1章引言介绍社区便民服务平台的研究背景、意义,以及基于SpringBoot+Vue技术的研究现状和创新点。1.1研究背景与意义分析社区便民服务的重要性,以及SpringBoot+Vue技术在平台建设中的优势。1.2国内外研究现状概述国内外在社区便民服务平台方面的发展现状。1.3研究方法与创新点阐述本文采用的研究方法和在SpringBoot+Vue技术应用上的创新之处。第2章相关理论介绍SpringBoot和Vue的相关理论基础,以及它们在社区便民服务平台中的应用。2.1SpringBoot技术概述解释SpringBoot的基本概念、特点及其在便民服务平台中的应用价值。2.2Vue技术概述阐述Vue的核心思想、技术特性及其在前端界面开发中的优势。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue如何有效整合,以提升社区便民服务平台的性能。第3章平台需求分析与设计分析社区便民服务平台的需求,并基于SpringBoot+Vue技术进行平台设计。3.1需求分析明确平台需满足的功能需求和性能需求。3.2架构设计设计平台的整体架构,包括前后端分离、模块化设计等思想。3.3数据库设计根据平台需求设计合理的数据库结构,包括数据表、字段等。第4章平台实现与关键技术详细阐述基于SpringBoot+Vue的社区便民服务平台的实现过程及关键技术。4.1后端服务实现使用SpringBoot实现后端服务,包括用户管理、服务管理等核心功能。4.2前端界面实现采用Vue技术实现前端界面,提供友好的用户交互体验。4.3前后端交互技术探讨前后端数据交互的方式,如RESTful API、WebSocket等。第5章平台测试与优化对实现的社区便民服务平台进行全面测试,并针对问题进行优化。5.1测试环境与工具介绍测试
### CSS Animation `blink` 属性的用法 为了创建闪烁效果,可以定义一个名为 `blink` 的动画并应用到目标元素上。通过设置 `.blink { animation: blink 1s steps(1, end) infinite; }`, 可以让元素按照指定的时间间隔不断改变透明度从而实现闪烁的效果[^1]。 具体来说: - `animation`: 定义了一个简写的动画属性组合。 - `blink`: 动画名称,在此案例中指定了一个使对象闪烁的关键帧序列。 - `1s`: 表示整个动画周期持续时间为一秒。 - `steps(1,end)`: 步骤函数用于控制动画进度曲线;这里意味着动画会在每一秒结束时突然跳转至下一状态而不是平滑过渡。 - `infinite`: 让动画无限循环播放直到被停止。 #### 关键帧 (`@keyframes`) 设置 要完成上述动画配置还需要声明相应的关键帧规则: ```css @keyframes blink { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } } ``` 这段代码描述了从完全可见(`opacity: 1`)变为不可见(`opacity: 0`)再恢复的过程,并且这个过程会每秒钟重复一次。 #### 实际应用场景中的HTML与CSS配合使用 下面是一个完整的例子展示如何利用这些样式来制作一个简单的网页组件使其具有闪烁特性: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Blinking Text Example</title> <style> .blink { animation: blink 1s steps(1, end) infinite; } @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } } </style> </head> <body> <p class="blink">This text will blink!</p> </body> </html> ``` 在这个实例里,任何带有类名`.blink`的文字都会每隔一秒钟消失然后再重新显现出来形成闪烁视觉效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值