You know those great ideas that come up at the spur of the moment? They just go in here.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
codestash/loubi

120 lines
2.2 KiB

1 year ago
```java
int W = 1280;
int H = 720;
String ENGINE = P3D;
byte AA = 16;
byte FPS = 120;
void settings()
{
size(W,H,ENGINE);
smooth(AA);
}
void setup()
{
background(0);
frameRate(FPS);
DATE = createGraphics(W,H,ENGINE);
CLOCK = createGraphics(W,H,ENGINE);
}
void draw()
{
DATE();
TIME();
}```
```java
int YEAR = year();
int MONTH = month();
int DAY = day();
int MILLIS = millis();
PGraphics DATE;
PGraphics CLOCK;
float HOUR = map(hour()%12,0,TWO_PI,0,TWO_PI);
float MINUTE = map(minute(),0,TWO_PI,0,TWO_PI);
float SECOND = map(second(),0,60,0,TWO_PI);
float center = (W-H);
float angle_H = 0;
float x_H = cos(HOUR-HALF_PI)*center;;
float y_H = sin(HOUR-HALF_PI)*center;;
float angle_M = 0;
float x_M = cos(MINUTE-HALF_PI)*center;;
float y_M = sin(MINUTE-HALF_PI)*center;;
float angle_S = 0;
float x_S = cos(SECOND-HALF_PI)*center;
float y_S = sin(SECOND-HALF_PI)*center;
void DATE()
{
DATE.beginDraw();
{
DATE.background(0);
DATE.translate(W/2,H/2);
DATE.scale(1);
DATE.stroke(255);
DATE.textSize(MILLIS);
DATE.text("YEAR: "+YEAR+" MONTH: "+MONTH+" DAY: "+DAY,-W/2,H/2);
}
DATE.endDraw();
image(DATE,0,0);
}
void TIME()
{
angle_H = hour();
float len_H = FPS*2;
x_H = cos(angle_H)*len_H;
y_H = sin(angle_H)*len_H;
if(angle_H >= 360)
{angle_H = 0;}
angle_M = minute();
float len_M = FPS;
x_M = cos(angle_M)*len_M;
y_M = sin(angle_M)*len_M;
if(angle_M >= 360)
{angle_M = 0;}
angle_S = second();
float len_S = FPS/2;
x_S = cos(angle_S)*len_S;
y_S = sin(angle_S)*len_S;
if(angle_S >= 360)
{angle_S = 0;}
CLOCK.beginDraw();
{
CLOCK.background(255,ALPHA);
CLOCK.translate(W/2,H/2);
CLOCK.scale(1);
CLOCK.strokeWeight(MILLIS);
CLOCK.stroke(255,0,0);
CLOCK.noFill();
CLOCK.circle(0,0,W-H);
CLOCK.strokeWeight(HOUR);
CLOCK.stroke(255);
CLOCK.text("HOUR: "+HOUR,-W/2,0);
CLOCK.line(x_H,y_H,0,0);
CLOCK.strokeWeight(MINUTE);
CLOCK.stroke(255,255,0);
CLOCK.text("MINUTE: "+MINUTE,-W/2,16);
CLOCK.line(x_M,y_M,0,0);
CLOCK.strokeWeight(SECOND);
CLOCK.stroke(255,0,255);
CLOCK.text("SECOND: "+SECOND,-W/2,32);
CLOCK.line(x_S,y_S,0,0);
}
CLOCK.endDraw();
image(CLOCK,0,0);
}```