想聽matika碎碎唸嗎? 你來對地方了!

星期六, 1月 16, 2010

Live wall paper

The source code of Nexus one live wallpaper(Galaxy)


這裡應該是用亂數函式產生Galaxy, 但是仍有定義Galaxy的直徑大小
*/
void createParticle(struct Stars_s *star, struct Particles_s *part, float scale) {
float d = fabsf(randomGauss()) * State->galaxyRadius * 0.5f + randf(64.0f);
float id = d / State->galaxyRadius;
float z = randomGauss() * 0.4f * (1.0f - id);
float p = -d * ELLIPSE_TWIST;

下面應該就是Java code
/**
* Initialize all the stars. Called from Java.
*/
void initParticles() {
if (State->isPreview == 1) {
angle = 0.0f;
}

struct Stars_s *star = Stars;
struct Particles_s *part = Particles;
int particlesCount = State->particlesCount;
float scale = State->galaxyRadius / (State->width * 0.5f);

int i;
for (i = 0; i < clear="none">createParticle(star, part, scale);
star++;
part++;
}
}

void drawSpace(float xOffset, int width, int height) {
bindTexture(NAMED_PFBackground, 0, NAMED_TSpace);
drawQuadTexCoords(
0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
width, 0.0f, 0.0f, 2.0f, 1.0f,
width, height, 0.0f, 2.0f, 0.0f,
0.0f, height, 0.0f, 0.0f, 0.0f);
}

過一陣子應該會有人釋出可在PC/mac上執行的live wallpaper桌面

Live桌面不是Gif動畫, 而是含有程式碼的, 可參考Processing.

沒有留言: