int cmx, cmy; PointMC[] points; NumMC num1, num2; BFont f; void setup(){ background( 102 ); size( 500, 500 ); framerate( 30 ); noStroke(); smooth(); cmx = width / 2; cmy = height / 2; points = new PointMC[60]; int delta = 0; for( int i = 0; i < points.length; i++ ){ if( i % 10 == 0 ){ delta += 20; } points[i] = new PointMC( (int)( width/2+sin( (float)i/60.0f*PI*12 )*(230-delta) ), (int)( height/2+cos( (float)i/60.0f*PI*12 )*(230-delta) ), 0xc8c8c8, 5 ); } num1 = new NumMC( 212, 200 ); num2 = new NumMC( 257, 200 ); f = loadFont( "Futura-Bold.vlw.gz" ); } void loop(){ //スクリーンの初期化 background( 102 ); for( int i = 0; i < points.length; i++ ){ float ns = points[i].nexts-0.1; ns = ns < 5 ? 5 : ns; int nr = ( points[i].nextc >> 16 & 0xff ) -1; int ng = ( points[i].nextc >> 8 & 0xff ) -1; int nb = ( points[i].nextc & 0xff ) -1; if( nr < 0 ) nr = 0; if( ng < 0 ) ng = 0; if( nb < 0 ) nb = 0; if( points[i].nextc != 0xc8c8c8 ){ points[i].setParam( ( nr<<16 | ng<<8 | nb ), ns ); } } Date d = new Date(); int s = d.getSeconds(); if( s == 0 ){ for( int i = 0; i < points.length; i++ ){ points[i].setParam( 0xc8c8c8, 5 ); } } points[s].setParam( 0xb40000, 15 ); cmx += ( points[s].x - cmx ) * 0.2; cmy += ( points[s].y - cmy ) * 0.2; float xr = ( (float)cmx - (float)width / 2.0f ) / ( (float)width / 2.0f ); float yr = ( (float)cmy - (float)height / 2.0f ) / ( (float)height / 2.0f ); xr *= PI / 2.3f; yr *= PI / 2.3f; translate( width / 2, height / 2 ); rotateX( yr ); rotateY( -xr ); translate( -width / 2, -height / 2 ); noStroke(); for( int i = 0; i < points.length; i++ ){ points[i].paintSelf(); } num1.setNumber( (int)Math.floor( s/10 ) ); num2.setNumber( s%10 ); num1.paintSelf(); num2.paintSelf(); fill( color( 255, 255, 255 ) ); textFont( f, 35 ); text( "m5g", 220, 275 ); textFont( f, 12 ); text( "Copyright(c) 2004 nogami.", 194, 295 ); text( "All rights reserved.", 209, 307 ); } static boolean[][] NUMBER = { { false, true, true, false, true, false, false, true, true, false, false, true, true, false, false, true, false, true, true, false}, { false, true, true, false, false, false, true, false, false, false, true, false, false, false, true, false, false, false, true, false}, { false, true, true, false, true, false, false, true, false, false, true, false, false, true, false, false, true, true, true, true}, { true, true, true, false, false, false, false, true, true, true, true, true, false, false, false, true, true, true, true, false}, { true, false, true, false, true, false, true, false, true, false, true, false, true, true, true, true, false, false, true, false}, { true, true, true, true, true, false, false, false, true, true, true, false, false, false, false, true, true, true, true, false}, { false, true, true, false, true, false, false, false, true, true, true, false, true, false, false, true, false, true, true, false}, { true, true, true, true, true, false, false, true, false, false, true, false, false, true, false, false, true, false, false, false}, { false, true, true, false, true, false, false, true, false, true, true, false, true, false, false, true, false, true, true, false}, { false, true, true, false, true, false, false, true, false, true, true, true, false, false, false, true, false, true, true, false} }; class NumMC{ int x, y; PointMC[] points; NumMC( int x, int y ){ this.x = x; this.y = y; points = new PointMC[20]; int count = 0; for( int iy = 0; iy < 5; iy++ ){ for( int ix = 0; ix < 4; ix++ ){ points[count] = new PointMC( x+ix*10, y+iy*10, 0xc8c8c8, 5 ); count++; } } } void paintSelf(){ for( int i = 0; i < points.length; i++ ){ points[i].paintSelf(); } } void setNumber( int n ){ for( int i = 0; i < points.length; i++ ){ if( NUMBER[n][i] ){ points[i].setParam( 0x000000, 10 ); } else{ points[i].setParam( 0xc8c8c8, 5 ); } } } } class PointMC{ int x, y; color c, nextc; float s, nexts, deltas; PointMC( int x, int y, color c, float s ){ this.x = x; this.y = y; this.c = this.nextc = c; this.s = this.nexts = s; this.deltas = 0; } void setParam( color nextc, float nexts ){ this.nextc = nextc; this.nexts = nexts; } void paintSelf(){ int r = c >> 16 & 0xff; int g = c >> 8 & 0xff; int b = c & 0xff; int nr = nextc >> 16 & 0xff; int ng = nextc >> 8 & 0xff; int nb = nextc & 0xff; r += ( nr - r ) * 0.2; g += ( ng - g ) * 0.2; b += ( nb - b ) * 0.2; c = r<<16 | g<<8 | b; deltas += ( nexts - s ) * 0.4; deltas *= 0.8; s += deltas; fill( r, g, b ); float hs = s/2; ellipse( x-hs, y-hs, s, s ); } }