Copyright © 2005, J de Silva
http:/ /,~,.w'.v. g .idnetwork . com/b-16. html
str i ng
string
array
Get the date/ time difference with PHP
$start
$end
2 * @param
3 * @return
34
*I
35 func tion get time difference( $start, $end)
36 {
37
38
39
40
41
42
43
44
-
{
if ( $uts [ ·end · ] >= $uts [ · btart · ] )
{
$diff
$uts[ end ] - $uts[ 'start ' ];
if ( $days=intval ( ( floor ($diff/ 86400 ) ) )
$diff = $diff % 86400 ;
45
if( $hours= intval ( ( floor ( $diff/ 3600 )))
46
47
48
49
50
$diff
170
171
172
173
174
175
176
so
181
$diff % 3600 ;
'minutes' =>$minutes ,
}
else
$uts [ '
' ] - $uts [ ',:1ta.rt' ] ;
if ( $days= intval (( floor ($diff/ 86400 )))
$diff = $diff % 86400 ;
if ( $hours= intval (( floor ($diff/ 3600 )))
$diff
$diff
=
$diff % 3600 ;
if ( $minutes=intv al (( floor ($diff/ 60 )))
$diff = $diff % 60 ;
$diff
intval ( $diff );
' =>$hours+ 24 ,
return ( a rray ( ·
' =>$days, '
}
e l se
{
trig9er_c~rror (
E:
USER WARNING );
}
return ( false ) ;
if ( $diff=@get_time_difference($start , $end )
{
global $time diff t x t;
$time diff txt = -:;-,l'irne Difi'erence: "
sp rl.ntf ( · %0:: d:
' , $di ff [ ' ltonr,; ' ] , $di ff [ rnirrntc,:; ' ] ) ;
echo "}L.i.r:i.e ......d.i.:ff.... LxL" . "" ;
177
11 8
179
=
if ( $minutes= i ntva l (( floor ($diff/ 60 )))
$diff = $diff % 60 ;
$diff
int.val ( $diff ) ;
return ( array ( 'days ' =>$days , 'h0urs' =>$hours,
51
52
53
54
55
56
157
158
159
160
161
162
163
164
165
166
167
168
169
-
$uts [ · ,2t art · ]
strtotirne ( $start ) ;
$uts [ ·e nd · ]
strtotine ( $end ) ;
if ( $uts[ 'start' ] ! ==- 1 && $uts[ · end' ]!==- 1
}
else
{
0~cvnJ0 =>$diff)
);
global $time diff txt ;
$tirne_diff_txt = -;;-fl(,u:c1: Error" ;
echo
:~~ tirne-- d.L f £ _ t.::i:t:t. ~~ • <.:1?>
f~
f~
!5
,6
'1
:0
9
0
Appendix II - ed-watch2.php - 3/3
i~ ;
}
print__ r
( $get_last_info_boorn);
= $test_tirne ;
$test_tirne_txt
:1
i2
13
14
i'.' :'/ .
$GM_lastirng_
arr = ~.r
-"-· _Y ,_(_._:.,·. ~J\;''" w~i.:.~.·'
,::._L_..· ~
. · ·,:~.l...-.•'.: l :· .~.. r ·,·_·,. .:,..._··. ."
"\:; .i.rn.q
be .i.q bL" , ":;:te;:,;t
,.. _._.: -..r··.~~
:'°· ,_,, .._
, 1 "' .. : .·,· : ,. ....·
= ~np '.ode ( "
$GM_lastirng_txt
'
"
" , $GM_lastirng_arr);
15
i6
17
18
19
)0
11
12
13
i4
i f ($get_link_info_boorn ( l ]! =$story_li nk){
:it: -~~C ;~~~:c=~~t: ~
15
16
17
18
«ed--}i nk-- '"'"' ;; :
L;~~~1!~:1!;:!!~;-;1i(A22END );
echo H, H;
e c ho "L.:i.nk
e cho H<1Jr
19
: H;
n
i
ID
ll
lz
l3
[4
5
6
7
8
9
0
g
p
24
25
~6
)7
~8
~9
'30
n
if($get_irngurl_info_boorn ( 2 ]!=$irng_url){
£.ile_put_contents ( " eci--:Lnqurl-Labt,tx t " , $GM_lastirng_txt);
(
" , $GM_lastirng_txt , FILE}s.FPFNI) );
'
" Irn3urL
t~·
H
;
Fclose ($file);
fclose ($file last) ;
fc:Lose ($file-link);
Fc l N\e ($file-link last);
fc l ose ($file=irnguil);
($file_irngurl_last);
32
1
//$timezone_ adjust = 2; //added for ES'l', hosting server is in Alberta
// $timezone txt"" "ES'I'";
/ /$ti.me zone .ad j usted = ( $test_Li.me ! hours 1 ) + ( $t .i .mezone adjust) ;
133
!34
135
116
1
137
~
" $te~_,,·
:_:/~~~~!~T;~:~~T~~sr~ar' ~" ;~~:r,:. .$:~Dt~7.~.ta.e~-yz~o~!r"'l,;e·.~:_r-a~-;'::.eu;:ds~·t;,e',~~ ..' , "$··;-:_e.·.'S,'t_ tirne [weekday]"'
~b
" $timezone txt");
I /$test ... tTme_ txt
•
•
~:
•
·J
·
"$t.est_time[month]",
"
"$ test_t i me[minute~]" , ": ", " $test_time [seconds]", "
.implode ("" , $test_t.i.me ... d.isplay);
echo
" .$irng_url;
" . $irng_alt;
' .$img_width ;
' . $irng_height;
,,~=~-~, ,~:
" .$headline_full;
' . $irng_date;
$irng_src = $irng_url; //$img_src is the URL for the image
e cho " " ;
e c h o $start. "
" .$end;
/*
Editorial . pde
*/
Appendix III - Editorial.pde - 1/12
/ /irng var
Pirnage q ;
Pirnage qfinal ;
Pirnage pageirng;
Pirnage rnaskedirng ;
PGraphics irngrnask ;
Pirnage title;
int titleheight ;
Pirnage rnattefinal ;
, PGraphics rnakePrespinirng ;
Pirnage prevprespinirng;
Pirnage prespinirng;
/ /nullirng
PGraphics nullgraphic;
//with title loc vars
int totalheight;
/ /peephole irng vars
Pirnage testpeepshadow ;
,a Pirnage testpeeprnask;
9 Pirnage rnaskedtestpeep ;
0
1 //irng vars
2 Pirnage holernask;
3 Pirnage holernasked;
4
5 //pin test vars
Pirnage
7 Pirnage
8 Pirnage
9 Pirnage
6
0
1
2
I!
15
16
n
pinshadowrnask;
pinshadowirng ;
pinrnask;
pinirng;
float resizeratio = 1.5;
float peepresizeratio = 0.44;
float centreirngratio = 0.37;
float pinresize = 0.5;
rn int displayx;
~9
int displayy;
50
1
2
//textFit var
PFont yayfont;
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
int textszvar = O;
float txtwidth;
float txtheight;
int txtarea;
int nextcharwidth;
int
int
int
int
int
rectfrarnew;
rectfrarneh;
rectfrarnewpad;
rectfrarnehpad;
frarnearea;
int
int
int
int
int
int
linewidth;
spacecounter = O;
charcounter
O;
linecounter = O;
displayline = O;
displace= O;
73
74
75
char(] tokchars;
int charlength;
76 String(] newlinetest = new String[l];
77 String[] newlinetrnp = new String[l];
78 String[] newline= new String[l];
79 String[] newlineprev = new String[l];
80 String linel, line2, line3, line4, lines , line6;
81 String spacer=" "
82
83
84
85
86
87
88
89
90
91
boolean endline = false;
//headline/irngalt input
String headline; //need to add one extra space to string
String irngalt;
String lines[] ;
String lines2[] ;
//headtext vars
int headtextsize = 48;
pfont headfont;
Appendix III - Editorial.pde - 2/12
//setup attributes
i nt windoww
1024;
int windowh = 768;
float qimgw;
fl oat qimgh;
//create new Frontpage object
// Frontpage page!= new Frontpage(PI/1296000, windoww/2, windowh/2);
frontpage page!;
// Frontpage page!= new Frontpage(O.l, windoww/2, windowh/2);
fl oat pinrotrate = 0 . 001*24;
// colour vars
color textfill = color(O, 255, O);
color midthres = color(l05);
color averagecolour;
color averagegray;
color bg = color(6);
Pimage bgimg;
// imgaverage vars
float qpixadder;
fl oat qpixaverage;
float qpixavgoffset
midthres;
// coloured rect vars
int colorrectw = 80;
int colorrecth = 80;
Pimage colorrect;
6 / /page vars
7 int pagew = 540;
8 int pageh = 430;
9 int headlineloc = 0-headtextsize;
O int rectframeloc;
1
2
3
4
5
6
// clock vars
int s;
// Values from O - 59
String sstring;
int mi;
// Values from O - 59
String mistring;
// Values from O - 23
7 int h;
8 String hstring;
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
59
60
61
62
63
64
65
66
67
68
69
)Q
71
72
//posted date vars
int postedhour;
int postedminute;
int totalSeconds;
String coordl, coord2;
float coordlx, coordly;
float coord2x, coord2y;
// pre-setup setup vars
int frate = 15;
float rotatecounter;
boolean prespin = true;
boolean prespun = false;
boolean readyrespin = false;
/ /folio vars
String folioleftl
"Al";
String folioleft2
"INTERNET EDITION>>
String folioright
"HALIFAX";
String fulldatestring;
PFont foliofont;
int foliosize
8;
int foliolead
10;
int foliobump
O;
int dayOfWeek;
String daystring;
int monthOfYear;
String mstring;
73
74
75
76
float[) skippos = new float[ 1 J;
float[) storeskiprate = new float[!];
float lastspin;
float respintrigger;
17 int respincounter;
78 int pretrigger;
1)9
iso int whichmask;
181 float centrebump;
182
83 String percentage;
Appendix III - Editorial.pde - 3/12
94
95 // hypontenuse var
96
87
98
89
90
91
92
93
94
95
96
97
98
float hypo;
i nt mattepad
= 15;
/ /calRotrate spin speed
/ /float avgupdate = 1 000 ;
f loat avgupdate ; //initial startups peed
f loat rotrateincr;
String avgupdateH ;
Str ing avgupdateM ;
/ /Refresh Update Image
int refreshcounter = O;
String[ ) refreshcheck ;
99
oo // RSS related
01
02
03
04
05
106
101
OB
109
10
111
11 2
113
11 4
11 5
11 6
11 7
118
11 9
20
121
122
123
124
12 5
126
127
128
129
130
131
l32
133
134
135
136
137
138
139
14 0
141
int lastimg;
int lastRSS;
//use (postedhour*60+postedrninute)*60
int coordlint ;
/ /Data store arrays of rotational bumps
int[ ] startpos ;
int[) storeskip;
/ /RSScol vars
int[] pubminutes;
/ /check RSSupdate
String lastpubDate;
int [) mdiff;
int newrndiff ;
String currentpubDate ;
/ /boolean FUN FUN FUN!!!
boolean tryRSS = true;
int tryloc
PFont
Bl ink
Bl ink
c olor
= O;
int RSSdate ;
int refreshRSScounter;
boolean startspin
= true;
boolean respin
false;
blinkfont;
blinkl;
// for refreshFrontpage
blink2 ;
// for RSSrefresh
blinkgrey
color(50);
void setup(){
size(windoww, windowh);
background(bg);
noStroke();
yayfont = loadFont("Dialog-125.vlw");
bg img = loadimage ( "bg2 . j pg" ) ;
blinkfont
= createFont("Times", 58);
//blinkspeed, blinklength, x, y, width, height, colorl(bg), color2
blinkl = new Blink(3, 2, width-10-30, 15, 5, 5, O, blinkgrey) ;
blink2 = new Blink(3, 2, width-10-30, 15, 5 , 5 , O, blinkgrey) ;
frameRate(frate);
calRotrate ( ) ;
14 2
14 3
displayx = windoww/2;
displayy = windowh/2;
//pagel = new Frontpage(rotrateincr, displayx, displayy);
//pagel = new Frontpage(0.001, windoww/2, windowh/2);
14 4
145
14 6
14 7
//retrieve image and headline info
lines= loadStrings("http://www.pudytong.ca/studiowk/ed-watch2/ed-imgurl-last.txt");
//lines= loadStrings("offlinedata . txt");
14 8
14 9
refreshFrontpage();
150
15 1
pagel.display();
15 2
153
154
155 vo id draw() {
156
//image display
15 7
pagel .display();
158
159
refreshRSScounter = refreshRSScounter + l;
160
if (refreshRSScounter >= lO*frate){
161
refreshRSScounter = O;
16 2
RSScheck(); //respin boolean inside this function
16 3
164
165
16 6
16 7
//<--refresh image
168
refreshcounter = refreshcounter + l; //HIDE to disable update for debugging
169
//println("RefreshCounter: "+ refreshcounter) ;
17 0
171
17 2
17 3
if (refreshcounter >= 20*frate ){
refreshcounter = O;
refreshcheck = loadStrings ("http://www. pudytong. ca/studiowk /ed-watch2/ed-imgurl-last. txt ");
274
//refreshcheck = loadStrings("offlinedata.tx t" );
AppendixIII - Editorial.pde - 4/12
275
println( "Frontpage Checked!");
276
277
blinkl.trigger();
//println(refreshcheck);
278
27 9
String[] matchstring = match(refreshcheck[2] , lines(2] );
2ao
201
if (matchstring == null) {
arrayCopy(refreshcheck, lines);
202
283
background(bg);
284
calRotrate ();
285
refreshFrontpage ();
z86
println( "Updating Frontpage ... ");
207
pagel .display();
288
I I --->
289
}
290
}
291
blinkl .display();
292
blink2 . display();
293
294
295
296 void calRotrate () {
297
// <--- loadstrings from "ed-info.txt", isolates "Time Difference" line,
298
II
converts all values to seconds
299
String[] loadEdinfo;
300
String(] loadtimediffs;
301
loadEdinfo = loadStrings("http://pudytong . ca/studiowk/ed-watch2/ed-info.txt");
302
303
loadtimediffs = new String [loadEdinfo.length/11];
30 4
305
int temploc = 0;
306
for (inti= 9; i < loadEdinfo.length; i = i+ll){
307
loadtimediffs(temploc] = loadEdinfo[i];
30 8
temploc = temploc + 1;
30 9
}
310
//println(loadEdinfo);
311
//println(loadtimediffs);
312
String(][] isolatetime = new String [loadtimediffs.length][];
313
String(] HHMM = new String [loadtimediffs.length];
31 4
int(] timedifftotal = new int[loadtimediffs.length];
315
316
for (inti= O; i < loadtimediffs.length; i++){
317
isolatetime[i] = splitTokens(loadtimediffs[i], " ");
318
HHMM[i] = isolatetime(i][2];
319
String[] tempsplitHHMM = splitTokens(HHMM[i], ":");
320
int tempdifftotal = int(tempsplitHHMM[0])*60+int(tempsplitHHMM[l]);
321
timedifftotal[i] = tempdifftotal*60;
322
}
323
//println( "HHMM: ");
32 4
//println(HHMM);
325
I /println( "Timedifftotal: ");
326
//println(timedifftotal);
327
// --->
328
329
II<--- weed out values< 5 minutes or 300 seconds, results in "avgeupdate"
330
int(] cleaneddiffs = new int( 0];
331
for (inti= O; i < timedifftotal . length; i++){
332
if(timedifftotal[i]>300){
333
cleaneddiffs = append(cleaneddiffs, timedifftotal[i]);
33 4
335
}
33 6
int diffsum = 0;
33 7
int samplerange = 10;
338
int tempcal = cleaneddiffs.length - samplerange - l;
339
for (inti= tempcal; i < cleaneddiffs.length; i++){
340
diffsum = diffsum + cleaneddiffs[i];
341
}
34 2
avgupdate = diffsum/(cleaneddiffs.length-tempcal);
34 3
//println(cleaneddiffs);
34 4
println( "Average Update: " + avgupdate);
345
346
//convert avgupdate into HHMM.fraction
347
float tempdivavg = avgupdate/3600;
348
String tempvalueof = String.valueOf(tempdivavg);
349
String tempsplitdecimal[] = splitTokens(tempvalueof, ".");
35 0
char ( ] tempcharcount = tempspli tdecimal ( 1] . toCharArray ( ) ;
351
avgupdateH = tempsplitdecimal[O];
352
float decimalbump = pow(lO , tempcharcount.length);
35 3
float minutefactor = float(tempsplitdecimal[l])/decimalbump;
35 4
float findminutes = 60*minutefactor;
355
int findminutes2 = round(findminutes);
35 6
avgupdateM = String . value0f(findminutes2);
357
358
println( "avgupdateM: " + avgupdateM);
35 9
println ( "findminutes: " + findminutes);
360
println( "minutefactor: " + minutefactor);
361
println( "decimalbump: " + decimalbump);
362
println( "avgupdateH: " + avgupdateH);
36 3
println( "tempcharcount: " + tempcharcount . length);
36 4
println( "int(tempdivavg): " + tempdivavg);
65
66
67
68
69
70
71
II--->
Appendix III - Editorial.pde - 5/12
int rotateacc = int(86400/avgupdate);
int rotratedivisor = frate*86400/rotateacc;
rotrateincr = 2*PI/rotratedivisor;
72
73
74
75
76
77
78
79
so
81
82
83
84
85
86
87
88
89
90
91
. 92
93
94
. 95
96
97
98
99
void refreshFrontpage(){
page!= new Frontpage(rotrateincr, displayx, displayy);
headline= lines[OJ;
imgalt = lines[3] +"
q = loadimage(lines[2]);
I I q = loadimage ( "offlineimg. jpg");
title= loadimage("title.png");
//rectframew = int(lines[2]);
//rectframeh = int(lines[3]);
qimgw = float(lines[SJ);
qimgh = float(lines[6]);
if ( q==null) {
println("loadimage is NULL!!!");
q = createimage(360, 240, ARGB);
q.loadPixels();
for (inti= O; i < q.width*q.height; i++){
q.pixels[i] = color(200);
}
q.updatePixels();
00
01
02
03
04
~05
06
07
OB
09
410
411
412
413
414
15
16
17
418
qimgw
360;
qimgh = 240;
rectframew = int(qimgw*resizeratio);
rectframeh = int(qimgh*resizeratio);
rectframewpad
rectframew-30;
rectframehpad = rectframeh-30;
makeFolio ( ) ;
//nail hole load+ resized to percentage of rectframe display GIVEN the
//dimensions of the mask and masked image are the same w/h ratio
int centreimgw = int(float(rectframew)*centreimgratio);
int centreimgh = int(float(rectframeh)*centreimgratio);
rectframeloc = rectframeh/2;
19
42 0
21
42 2
//println(qimgw);
//println(qimgh);
//println(rectframew);
23
42 4
42 5
42 6
42 7
42 8
42 9
q.resize(rectframew, rectframeh);
title.resize(rectframew, O);
titleheight = title.pixels.length/rectframew;
//println("title height: "+ titleheight);
totalheight = rectframeh+titleheight;
430
imgaverage ( ) ;
431
432
433
434
435
436
43 7
438
439
440
441
442
443
444
445
446
44 7
448
449
tokchars = imgalt.toCharArray();
charlength = tokchars.length;
makeqfinal();
getPostDate();
makeMatte();
String[] temp!= splitTokens(coordl, " ");
coordlint = int(templ[l]);
RSSstore ( ) ;
RSScol();
lastimg = (postedhour*60+postedminute)*60; //in secs?
pubminutes = reverse(pubminutes);
//<--goes to the last RSS feed that arrives AFTER the image was updated, so no reverse spin
println("pubminutes[OJ*60: "+ pubminutes[tryloc]*60);
println("lastimg: "+ lastimg);
45 O
451
452
453
454
455
println(pubminutes);
if(pubminutes[tryloc)*60-lastimg=pubm1nutes.length-l){
tryloc = 0;
tryRSS = false ;
'6
17
~8
~~
}
tryloc = tryloc + 1;
61
g
lastRSS = pubminutes[tryloc];
64
15
66
7
68
else
try loc = O;
lastRSS = pubminutes[O];
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
II-->
I lprintln( "lastRSS: " + lastRSS );
llprintln("lastimg: " + lastimg );
if(RSSdate ! =coordlint){
println( "RSSdate :
+ RSSdate );
lastRSS = lastRSS+24 ;
11
}
if(lastRSS * 60-lastimg>=O ){
llstartpos[mdiff.length] = lastRSS*60-lastimg ;
mdiff = append(mdiff, lastRSS*60-lastimg) ;
}
println( pubminutes: "+ pubminutes[l]) ;
println("LastRSS*60 : "+ lastRSS * 60);
println( "Lastimg: " + lastimg);
11
86
187
188
89
90
91
92
93
94
95
~9 6
97
98
99
00
501
02
503
504
505
506
507
50 8
509
510
511
51 2
51 3
51 4
515
51 6
51 7
51 8
51 9
52 0
52 1
52 2
523
52 4
525
526
527
52 8
52 9
530
53 1
532
53 3
53 4
535
536
537
538
539
54 0
startpos = new int[mdiff.length-tryloc];
int tempcounter = O;
for (inti= tryloc; i < mdiff.length; i++){
startpos[tempcounter] = mdiff[i];
tempcounter += 1;
}
startpos = reverse(startpos );
II<---!!! FIX THIS SHIT!!!
int allspinsum = O;
for (inti= O; i < startpos . length; i++ ){
allspinsum = allspinsum + startpos[i];
}
println( "AllSpinSum:
int templatestdeg = totalSeconds - allspinsum ;
startpos = append(startpos , templatestdeg);
println( Total Seconds:
+ totalSeconds) ;
println( Last Startpos: "+ startpos[startpos . length-1]);
11
11
11
II--->
storeskip = new int[startpos . length];
arrayCopy(startpos, storeskip);
llprintln ( Startpos :
llprintln ( startpos);
println( Storeskip: ");
println(storeskip);
11
54 2
54 4
545
546
11
);
11
startspin = true;
void imgaverage(){
qpixadder = 0.0;
for(int i = O; i < q.pixels.length; i++){
qpixadder += q.pixels[i];
qpixaverage = qpixadderlq . pixels.length;
11
println( Average Pixel Value:
11
+ qpixaverage);
qpixadder = O;
averagecolour = int(qpixaverage);
textfill = int(qpixaverage);
float grayrange = map(averagecolour, -16777216 , -1, O, 255);
grayrange = - (grayrange);
llprintln("Gray of Averagecolor : "+ grayrange);
averagegray = color(int(grayrange));
541
543
+ allspinsum);
11
void makeqfinal (){
PGraphics makeq;
Pimage qshaded;
Pimage qmask;
Pimage qmask2 ;
Appendix III - Editorial.pde - 6/12
f~
~9
0
1
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Pimage qmasked;
PGraphics makeq2;
Appendix III - Editorial.pde - 7/12
makeq = createGraphics(q.width, q.height, JAVA2D );
makeq.beginDraw();
makeq.background(255);
makeq.translate(q.width/2 , q.height/2 );
makeq.rectMode(CENTER);
makeq.imageMode(CENTER);
makeq.image(q, O, O);
//makeq.fill(O , 255, O);
makeq. fill ( 0);
makeq.rect(O, O, q .width, q.height);
makeq.resetMatrix();
makeq.endDraw();
//qmask: EDGES
qshaded = createimage(q.width, q.height , ARGB);
for(int i = O; i < q.pixels.length; i++){
qshaded.pixels[i] = makeq.pixels[i];
67
68
69
70
pi
72
73
74
75
76
77
78
79
qmask = loadimage( "qmask. jpg");
qmask.resize(rectframew , rectframeh) ;
qshaded.mask(qmask);
qmask2 = loadimage( "qmask2. jpg");
qmask2.resize(rectframew , rectframeh);
qmasked = q;
//qmasked = loadimage("offlineimg.jpg");
qmasked.resize(rectframew, rectframeh);
qmasked.mask(qmask2);
83
//makeMasks
maskedimg = createimage(q.width, q.height, ARGB);
maskedimg.copy(q, O, O, q.width, q.height, 0, 0 , q.width, q . height);
maskedimg.resize(int(qimgw*peepresizeratio), int(qimgh*peepresizeratio));
84
85
imgmask
BO
Bl
82
=
createGraphics(maskedimg.width, maskedirng.height, JAVA2D);
86
87
88
589
90
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
imgmask.beginDraw();
imgmask.translate(imgmask.width/2, imgmask.height/2 );
imgmask.rectMode(CENTER);
imgrnask.fill(255);
imgrnask.ellipse(O, 0, 35, 35);
imgmask.resetMatrix() ;
imgmask . endDraw();
maskedirng.mask(imgrnask );
makeq2 = createGraphics(q.width, q.height, JAVA2D);
makeq2.beginDraw();
makeq2.translate(q.width/2, q.height/2);
makeq2.imageMode(CENTER);
makeq2.irnage(qshaded, 0, O);
makeq2 . image(qmasked, O, O) ;
makeq2.resetMatrix();
rnakeq2.endDraw();
qfinal
=
createimage(q.width, q . height, ARGB);
for(int i = O; i < q.pixels.length; i++){
qfinal.pixels[i] = makeq2.pixels[i];
610
611
612
613
614
void getPostDate(){
String posteddatelong = lines(?];
String posteddatebreak[] = splitTokens(posteddatelong, " ");
String posteddatemerge[] = subset(posteddatebreak, O, 5);
618
/* debugging
619
for(int i = O; i < posteddatemerge.length; i++){
62 O
println(posteddatemerge(i]);
621
}
615
616
617
622
62 3
62 4
625
62 6
62 7
62 8
62 9
630
631
632
633
634
635
636
637
*I
char daychars(] = posteddatemerge[2].toCharArray();
daychars = shorten(daychars) ;
String daycleaned = new String(daychars);
println("Day Cleaned : "+ daycleaned);
char yrchars(] = posteddatemerge(3].toCharArray();
yrchars = shorten(yrchars);
String yrcleaned = new String(yrchars);
println(posteddatemerge);
coordl
coord2
=
posteddaternerge(l] +" "+ daycleaned;
yrcleaned;
String(] temptirneboom
println(ternptimeboorn);
splitTokens(posteddatemerge[4], ":");
638
639
640
641
642
64 3
644
64 5
64 6
64 7
648
64 9
65 0
651
652
65 3
65 4
65 5
656
65 7
65 8
659
66 0
661
662
663
664
665
66 6
66 7
66 8
66 9
670
671
672
67 3
67 4
67 5
67 6
677
678
67 9
680
681
682
683
684
685
686
68 7
Appendix III - Editorial. pde - 8/ 12
postedh~ur = in~(temptimeboom(O]);
postedminute = int(temptimeboom(l]);
println("Posted hour: "+ postedhour +" --- "+ "Posted minutes: "+ postedminute );
//calculate coordinates for date display
//calculate hypotenuse !!! many other functions depend on this cal
hypo= sqrt((rectframew*rectframew)+(rectframeh*rectframeh));
float mirads = map(postedminute, o, 60, O, TWO_PI) - HALF_PI;
//float hrads = map((postedhour-4) + norm(postedminute, O, 60), O, 24 , 0 , TWO PI* 2) - HALF PI·
float hrads = map(((postedhour-4) + norm(postedminute , O, 60)) , O, 24 , 0 , TWO-PI* 2) - HALF=PI;
println(mirads + " ... " + hrads);
coordlx
coordly
coord2x
coord2y
cos(mirads) * (hypo/2 + mattepad);
sin(mirads) * (hypo/2 + mattepad);
cos(hrads) * (hypo/2 + mattepad);
sin(hrads) * (hypo/2 + mattepad);
println(cos(mirads) * (hypo/2 + mattepad));
println(cos(hrads) * (hypo/2 + mattepad));
mi = minute();
// Values from O - 59
h = hour();
// Values from O - 23
int mdiffl = mi - postedminute;
int mcarry = O;
if (mdiffl
84 3
84 4
84 5
84 6
84 7
84 8
84 9
85 0
85 1
85 2
}
85 3
85 4
85 5
85 6
85 7
85 8
void RSScol(){
String[] splittimes;
String[] times;
int [ ] minutes;
859
// Download RSS feed of news stories from www . theglobeandmail.com
String url = "http://www.theglobeandmail.com/?service=rss";
//String url = "offlineRSS.xml";
XMLElement rss = new XMLElement(this, url);
// Get all elements
XMLElement[] pubDates = rss.getChildren("channel/item/pubDate");
86 0
861
86 2
86 3
86 4
86 5
86 6
splittimes = new String[pubDates.length];
times= new String[pubDates.length];
minutes= new int[pubDates.length];
mdiff = new int[pubDates.length];
86 7
86 8
86 9
870
871
//extracts each pubDate line
for (inti= O; i < pubDates.length; i++) {
splittimes[i] = pubDates[i].getContent();
//println("SplitTimesArray: "+ splittimes[i]) ;
87 2
87 3
87 4
87 5
87 6
877
87 8
87 9
880
88 1
882
88 3
...
88 4
88 5
886
88 7
88 8
889
89 0
891
892
//splits HH:MM from full pubDate string
for (inti= O; i < pubDates.length; i++) {
String[] tempToken = splitTokens(splittimes[i], " ");
times[i] = tempToken[4];
/ /println( "Times: " + times [ i]);
RSSdate = int(tempToken[l]);
//compares date of ed-img with the RSS feed to compensate for overnight
discrepency
//println( "RSSdate build: " + RSSdate);
}
//converts hours into minutes, adds total minutes
for (inti= O; i < pubDates.length; i++){ ,
String[] tempToken = splitTokens(times[i], ":");
89 4
int tempHtoM = int(tempToken(0])*60+(5*60); //adding 5*60 minutes convert into GMT
//compensation for date change with GMT
if(i==O && int(tempToken[O])>=l9){
RSSdate = RSSdate+l;
895
896
int tempTotalM = tempHtoM+int(tempToken[l]);
893
}
89 7
89 8
minutes[i] = tempTotalM;
89 9
90 0
90 1
90 2
90 3
//println( "Minutes : " + minutes[i]);
}
sort (minutes);
pubminutes = minutes;
90 4
905
90 6
90 7
90 8
90 9
//calculates differences of time between updates ! ! ! outputs seconds
for (inti= 1; i < pubDates.length; i++){
mdiff[i] = (minutes[i-l]-minutes[i])*60;
//println("Time differences (secs): "+ mdiff[i]);
91 0
91 1
91 2
91 3
91 4
}
mdiff = reverse(mdiff)
mdiff = shorten(mdiff )
mdiff = reverse(mdiff)
//println(mdiff);
Appendix III - Editorial.pde - 11/12
91 5
91 6
91 7
91 8 void RSScheck(){
91 9
92 0
blink2.trigger();
92 1
String url = "http://www.theglobeandrnail.com/?service=rss ";
//String url = "offlineRSS2.xml";
XMLElement rss = new XMLElement(this, url);
XMLElement currentpubDatexml = rss.getChild ( "channel/item/pubDate" );
currentpubDate = currentpubDatexml.getContent( );
92 2
92 3
92 4
925
92 6
92 7
92 8
92 9
930
93 1
93 2
933
93 4
935
93 6
93 7
93 8
93 9
94 0
94 1
942
94 3
94 4
945
94 6
94 7
94 8
94 9
95 0
95 1
95 2
95 3
95 4
95 5
95 6
95 7
95 8
95 9
960
961
RSScol();
String[] matchstring = match(lastpubDate, currentpubDate );
if (matchstring == null){
println("RSS changed!");
//isolate mdiff(secs) from lastpubdate and currentpubdate
String[] tempdatemerge = {lastpubDate, currentpubDate};
int[] tempdateint = new int[2];
for (inti= O; i < tempdatemerge.length; i++){
String[] tempToken = splitTokens(tempdatemerge[i], " ");
String temptimes = tempToken[4];
tempToken = spli tTokens ( temptimes, " : " ) ; .
int tempHtoM = int(tempToken[0])*60+(5*60);
//adding 5*60 minutes convert into GMT (secs)
int tempTotalM = tempHtoM+int(tempToken[l]);
tempdateint[i] = tempTotalM;
}
println( "tempdateint[O]: " + tempdateint[O]);
newrndiff = tempdateint[l]-tempdateint[O];
println( "LastPubDate(time): " + tempdateint[O]) ;
println("CurrentPubDate(time): "+ tempdateint[l]);
println("Newrndiff : "+ newrndiff);
if ( newrndiff>O) {
//<--goes to the last RSS feed that arrives AFTER the image was updated, so no reverse spin
tryloc = O;
I*
96 2
while(tempdateint[O]-mdiff[tryloc]*60>=0 && tryRSS==true){
println ( "tryloc: " + tryloc);
if(tryloc>=mdiff.length-1){
tryRSS = false;
tryloc = mdiff.length-1;
96 3
96 4
tryloc = tryloc + l;
}
965
}
96 6
96 7
*I
96 8
96 9
97 0
971
97 2
97 3
97 4
97 5
97 6
97 7
97 8
97 9
98 0
981
98 2
983
98 4
985
98 6
987
98 8
98 9
99 O
991
99 2
99 3
994
99 5
996
99 7
getPostDate ( ) ;
pubminutes = reverse(pubminutes);
println(pubminutes);
if(tempdateint[l]-pubminutes[tryloc]=pubminutes.length-1){
tryloc = mdiff.length-1;
tryRSS = false;
}
tryloc = tryloc + l;
}
}
else
tryloc = mdiff.length-1;
storeskip = reverse(storeskip);
for (inti= tryloc; i < mdiff.length-1; i++){
storeskip = append(storeskip, mdiff[i]);
println ( "Storedskip: " + i + " times");
}
storeskip = reverse(storeskip);
int allskipsum = O;
for (inti= O; i < storeskip.length ; i++){
allskipsum = allskipsum + storeskip[i];
}
println( "RSScheck
lastimg: " + lastimg);
println("RSScheck - totalSeconds : "+ totalSeconds);
println("RSScheck - StoreSkipSum: "+ allskipsum);
999
999
too 0
int templatestdeg
totalSeconds - allskipsum;
if (templatestdeg < O){
100 1
100 2
100 3
100 4
100 5
100 6
JOO 7
100 8
100 9
101 0
101 1
101 2
101 3
101 4
101 5
101 6
101 7
101 8
101 9
102 0
102 1
102 2
102 3
J02 4
! 102 5
templatestdeg
= O;
}
storeskip
= append ( storeskip , templatestdeg );
for ( int i = O; i < storeskip . length ; i++ ) {
println (" RSScheck Storeskip : "+ stores k ip [ i ]);
respin = true ;
lastpubDate = currentpubDate ;
//
! ! ! FIX THIS SHIET !!!
//int templastdeg = tota1Seconds - pubminutes ( 0 ]* 60 ;
//storeskip = append ( storeskip , templastdeg );
//println ( templastdeg );
//println ( "Storeskip : " );
//println(storeskip );
}
else
println ( "RSS UNchanged !" ) ;
//println ( "Storeskip:" );
//println(storeskip) ;
Appendix III - Editorial.pde - 12/12
1
I* Frontpage . pde ( class required b y "Editorial ")*/
Appendix III - Frontpage.pde - 1/3
2
class Frontpage {
float rectw = 1 30 ;
float recth = 1 15 ;
float rotdeg = O;
//++
7
float pinrotdeg = O;
8
float rotrate ;
9
int pageimgw = rectframew ;
10
int pageimgh = rectframeh ;
11
int pageimgadd ;
12
int growthmax ;
13
14
float roundcount ;
15
int roundcounter = O;
16
float fullrot = PI ;
17
18
//fade counter needs fi x ing/clearer documentation
19
float fadethres ;
20
float fadetrail;
21
float fadenum = O;
22
boolean rotoff = false ;
23
int rotoffcounter = O;
24
float skiprate;
25
3
4
5
6
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
float respinskiprate ;
int prespinlocs = O;
float noskipthres ;
float displaytop;
Frontpage(float c_rotrate , int c_displayx, int .c_displayy) {
rotrate = c rotrate;
displayx
displayx;
displayy = c=displayy ;
c
void display() {
//if (rotdeg > 2*PI ) {
O;
/ /rotdeg
/ /}
if(startspin == true){
translate(displayx, displayy);
rectMode(CENTER);
imageMode(CENTER);
image(qfinal, O, O);
resetMatrix();
for (inti= O; i < startpos.length; i++){
rotdeg = rotdeg + rotrate*startpos[i]*frate;
55
56
fillFadeTrail ();
57
58
59
60
translate(displayx , displayy) ;
rotate(rotdeg);
rectMode(CENTER) ;
imageMode(CENTER) ;
image(qfinal, O, O);
resetMatrix();
61
62
63
64
}
65
66
startspin = false;
67
68
69
70
71
72
73
74
75
76
if(respin == true){
rotdeg = 0;
translate(displayx, displayy) ;
rotate(rotdeg);
rectMode(CENTER);
imageMode(CENTER);
image(qfinal, O, O);
resetMatrix();
77
78
79
80
for (inti= O; i < storeskip.length; i++){
rotdeg = rotdeg + rotrate*storeskip[i]*frate;
81
82
83
fillFadeTrail();
translate(displayx , displayy);
rotate ( rotdeg) ;
rectMode(CENTER) ;
imageMode(CENTER) ; "
image(qfinal , O, O) ;
resetMatrix();
84
85
86
87
88
89
90
91
}
respin
=
false;
1
183
184
185
18 6
18 7
188
189
190
)91
)92
)93
)94
195
)9 6
)97
)9 8
)9 9
200
//text(headline, O, hypo/2+textszvar+70);
text(headline , 0, rectfrarneh/4-2*textszvar);
resetMatrix ();
void fillFadeTrail(){
rectMode(CORNER);
fill(bg, 40);
rect(O , O, width, height) ;
resetMatrix ();
void displayText(){
translate(displayx, displayy);
textAlign(CENTER );
fill(averagegray);
text(headline, 0, hypo/2 + rnattepad + 10);
resetMatrix();
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
void displayAvgupdate(){
translate(20, 20);
textAlign(LEFT);
fill ( blinkgrey) ;
text ( "Spin Speed: " +
avgupdateH + " : " + avgupdateM, 0, 0);
resetMatrix();
Appendix III - Frontpage.pde - 3/3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Blink . pde ( class required by "Editorial" )*/
Appendix IV - Blink.pde
class Blink{
//blink() vars
float blinkcounter = O;
int blinkend = O;
boolean blinkon = false;
float blinksp;
int blinklength, bx , by , bw , bh;
color cl , c2;
int blinkbump;
//blinkspeed, blinklength, x, y, width, height , colorl, color2
Blink(float blinksp_c, int blinklength_c, int bx c ,
int by c, int bw c, int bh c , color cl_c, color c2_c){
blinksp = blinksp c;
blinklength = blinklength c;
bx
bx c;
by
by=c;
bw
bh c;
bh
bh-c;
cl
cl-c;
c2
c2=c;
26
blinkbump
27
O;
28
blinksp = constrain(blinksp, O, frate-1);
29
30
textFont(blinkfont);
31
32
33
34
35
36
37
38
39
void display(){
if(blinkon==true){
float blinkthres = float(frate)/blinksp;
blinkcounter += 1;
int blinkendthres
blinklength*frate;
blinkend += 1;
40
41
42
43
44
45
46
47
48
49
if (blinkcounter >= blinkthres){
fill(cl);
blinkbump += 1;
blinkcounter = O;
}
else
50
51
52
53
fill(c2);
if (blinkbump >= 3){
blinkbump
O;
54
55
56
57
noStroke ( ) ;
//rectMode(CORNER);
ellipseMode(CORNER);
//textAlign(CENTER);
resetMatrix();
ellipse(bx+(blinkbump*bw*l.S), by, bw, bh);
//textSize(58);
//text(".", bx+(blinkbump*bw*l.5), by);
58
59
60
61
62
63
64
65
66
67
68
69
if (blinkend >= blinkendthres){
fill(c2);
for (int x = O; x < 4; x++){
ellipse(bx+(blinkbump*bw*l.5), by, bw, bh);
//textSize(58);
//text(".", bx+(x*bw*l.5), by);
70
71
72
73
74
75
blinkon = false;
blinkend = O;
76
77
78
blinkbump = 0;
79
80
}
81
82
83
84
85
86
87
88
}
void trigger(){
blinkon = true;
blinkbump = O;
1 / * Chronological.pde */
2
3 import blobDetection.*;
4 //Library found at http://v3ga . net/processing/BlobDetection/
5
6 BlobDetection theBlobDetection;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
PFont yayfont;
PFont crawlFont;
//define classes
EngravedText maintext;
Ghost lastheadline;
Ghost lastheadline2;
PGraphics testee;
Pimage testimg;
String[] headlinestringoffline = {
"CONSTANT ... INTERVALS",
"Health officials say they didn't expect high demand for HlNl shot",
" 'Mad Men, ' ' 3 0 Rock' aim to repeat as Emmy winners",
"Cabrera Bello shoots 60 to win Austian Open",
"Authorities: Insane killer likely planned getaway" ,
"Countdown to destruction at French migrant camp",
"Pakistan's security gains contrast Afghan turmoil",
"Medvedev: Israel not planning to strike Iran",
"Iran's leader says US nuke accusations wrong",
"Fleeing heat, bombs, Iraqis go north for holiday"
};
String[]
String[]
String[]
String[]
headlinestring;
headlinestringupdated;
headlinestringcheck;
splittitles; //used in RSScol();
String storeprevfirst;
String storeprevsecond;
int checkRSScounter = O;
int checkRSScountthres = 5; //<--this number already in seconds
boolean updateRSSon = false;
int headheight;
int headwidth;
int xmargins = 50;
int headtextsize = 94; //optimal
float txtheight;
int headtextlead;
72
float ybumpcounter;
int ybumpgap;
float xjitter = 0.0;
int frate = 15;
float scrollrate
687; //value must be >O //687 is width 1024-337(loc where scrolling stops) // last min change
so messy
float noisescale
O. 0;
float scrollratenoise;
float startscrollloc;
float scrollincr = scrollrate/(frate*60); // 60 seconds until headline reaches scrollstop;
boolean scrollon = true;
int jitterbackcounter = O;
int jitterbackstop = O;
boolean jitterbackon = false;
float fadenoisescale = 0.0;
float botfadenoise2 = 0.0;
float botfadeheight = 50;
float botfadeadd = 137;
boolean botfadeon = false;
int botfadeoncounter = O;
int linecounter;
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Appendix IV - Chronlogical.pde - 1/9
boolean fadeon
false;
int fadetime = 30;
int fadeamount = 25;
int fadecounter = O;
boolean nextline = false;
int nextlinecount = 0;
//bg()
float increment
=
0.01;
//<---white colour set
91
92
93
94
95
96
97
98
99
oo
Ol
02
03
04
05
06
07
OB
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
l51
l52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
float bgfloat = 227; //<-- gray
color bg = color(bgfloat);
int bgalpha = 2;
color textfill = color(255); //main fill
color textburn = color(O, 96); //highlight edge
color textburn2 = color(l2 , 5, O); //engraved shadow
int ghostalpha = 72;
//color ghostcolour = color(200 , 198, 173);
//color ghostcolour = color(l45, 145 , 141);
color ghostcolour = color(l20);
Appendix IV - Chronlogical.pde - 2/9
//--->
//<--- inverted colour set
/*
float bgfloat = 23; //<-- gray
color bg = color(bgfloat);
float bgalpha = 4;
color textfill = color(255); //main fill
color textburn = color(200, 123); //highlight edge
color textburn2 = color(O); //engraved shadow
int ghostalpha = 3;
color ghostcolour = color(47, 40, 7);
*I
//--->
color ghostfill = color(244, 240, O, ghostalpha);
color ghostburn = color(200, ghostalpha);
color ghostburn2 = color(200, ghostalpha);
int chipamount
=
2; //2 looks the best with this font size
ArrayList ghosts;
float[] ghostjitstore
int crawlcounter
=
new float[l];
O;
int scrollstop;
// for stall()
float lineloc;
II for RSSwrite()
int tempcatch;
II for RSScol() and RSScheck()
String lastpubDate;
String currentpubDate;
boolean newerpost = false;
String url;
XMLElement rss;
//speed vars
float startghostfreq
2.0, ghostfreq;
float startoverscrollfreq = 2.0, overscrollfreq;
float startjitterbackfreq = 50.0, jitterbackfreq;
float startlinefreq = 50, linefreq;
// for stall(); full sweep in how many (x) secs
float startlinestroke = 1, linestroke;
int waitcounter = O;
int waitmax = 10*60*frate;
boolean triggergfstore
true;
float waitcounterstore = 0.0;
void setup(){
size ( 1152, 870);
scrollstop = int(float(width)*0.33);
println(scrollstop);
background(bg);
//bg();
frameRate(frate);
//resets all speeds to startup speeds
scrollincr = scrollrate/(frate*60);
ghostfreq = startghostfreq;
overscrollfreq = startoverscrollfreq;
jitterbackfreq = startjitterbackfreq;
linefreq = startlinefreq;
// for stall(); full sweep in how many (x) secs
linestroke = startlinestroke;
lineloc
=
width;
//yayfont = loadFont("Times-Roman-48.vlw");
yayfont = createFont("Times-Bold", headtextsize);
//String[] fontList = PFont.list();
//println(fontList);
182
18 3
184
18 5
18 6
18 7
18 8
18 9
19 0
19 1
19 2
19 3
194
19 5
19 6
197
198
19 9
200
201
202
203
204
205
206
207
20 8
20 9
2 10
211
2 12
te x tFont ( yay font );
te x tSize ( headte x tsize );
t x theight = te x tAscent () +te x tDescent ();
headte x tlead = int ( t x theight * l . 2 );
te x tLeading ( headte x tlead );
crawlFont = createFont("Helv etica ", 8 );
//println ( "hedte x tsize: " + headtextsize );
//println ( "tx theight : " + t x theight );
RSScol ();
//stores first lastpubDate
XMLElernent lastpubDatexrnl = rss . getChild (" channel/itern/pubDate ");
lastpu bDate = lastpubDatexrnl . getConte n t ();
//lastpubDate = "Fri , 22 Jan 2010 23 : 38 -0500 ";
RSSwrite() ;
//headlinestring = headlinestringoffline ;
headlinestring = splittitles ;
storeprevfirst = headlinestring(O];
storeprevsecond = headlinestring[l ];
//te x theight(headlinestring ( ne x tlinecount ] ) ;
te x theight ( headlinestring [ O] );
startscrollloc = width+headheight/2 ;
yburnpcounter = startscrollloc;
noisescale = noisescale + 0.01 ;
scrollratenoise = noise( noisescale) * scrollrate;
// println("Scroll Rate Noise : "+ scrollratenoise) ;
213
214
215
216
217
218
219
//rnarblel.rnarblegen() ;
int ghostline = ne x tlinecount + l ;
if(ghostline < O){
ghostline
headlinestring . length-1 ;
220
221
2 22
2 23
2 24
2 25
22 6
2 27
rnainte x t = new EngravedTex t ();
ghosts= new ArrayList( );
for (inti= l; i < headlinestring.length ; i++ ){
float ghostjitterrand = randorn(l , 50) ;
ghosts . add(new Ghost(i , ghostjitterrand ));
22 8
22 9
2 30
2 31
2 32
2 33
2 34
2 35
2 36
2 37
2 38
2 39
24 0
2 41
2 42
2 43
2 44
2 45
2 46
2 47
2 48
2 49
250
251
252
253
254
255
256
257
258
259
2 60
2 61
2 62
2 63
2 64
2 65
2 66
2 67
2 68
2 69
2 70
271
2 72
//lastheadline = new Ghost(ghostline) ;
//lastheadline2 = new Ghost(ghostline);
//rnaintext.buildtrail();
//lastheadline . display() ;
//lastheadline2 . display ();
for (inti= ghosts . size()-1; i >= O; i--){
Ghost ghost= ( Ghost ) ghosts . get ( i );
ghost . display() ;
rnainte x t . foreground() ;
//println(ghostjitstore);
void draw ( ) {
float ghostrand
random( 0 , 100) ;
ca1Speeds();
checkRSScounter += l;
//if (scrollon = false && storeprevfirst ! = ) ;
if (yburnpcounter<=scrollstop){
scrollon = false ;
if (botfadeon==false){
botFade( );
botfadeoncounter += l ;
}
if (botfadeoncounter > 3 ){
botfadeon = true ;
//println("BotFadeOn : "+ botfadeon );
if (checkRSScounter >= checkRSScountthres * frate) {
check RSScounter = O;
Appendix IV - Chronlogical.pde - 3/9
27 3
2 74
2 75
2 76
2 77
2 78
2 79
2 80
2 81
2 82
2 83
2 84
2 85
2 86
2 87
2 88
2 89
2 90
2 91
2 92
2 93
2 94
2 95
296
2 97
2 98
2 99
300
301
302
303
304
305
306
307
308
309
310
//headlinestringcheck = headlinestringoffline;
RSScol( );
headlinestringcheck = splittitles;
println("RSS Checked !");
println("headlinestringcheck[O]: "+ headlinestringcheck[O]);
println (" storeprevfirst : "+ storeprevfirst) ;
RS Scheck ( ) ;
String[] matchstring = match(headlinestringcheck[O], storeprevfirst );
if(matchstring==null && newerpost==true){
println("RSS Both Changed! ");
lastpubDate = currentpubDate;
newerpost = false ;
updateRSSon = true;
updateRSS() ;
RSSwrite() ;
waitcounter = O;
//resets all speeds to startup speeds
scrollincr = scrollrate/(frate*60) ;
ghostfreq = startghostfreq;
overscrollfreq = startoverscrollfreq;
jitterbackfreq = startjitterbackfreq;
linefreq = startlinefreq;
// for stall(); full sweep in how many (x) secs
linestroke = startlinestroke ;
triggergfstore = true ;
println("Updating RSS ... ");
println( "headlinestring: ");
println(headlinestring);
println("GhostArrayList: "+ ghosts.size());
if (ybumpcounter<=scrollstop && scrollon==false){
if(ghostrand < ghostfreq){
int refreshghost = int(random(O, ghosts.size()));
Ghost ghost= (Ghost) ghosts . get(refreshghost) ;
ghost . display();
//println("Ghost Refresh: "+ refreshghost);
311
312
313
314
315
316
317
318
319
32 0
321
322
323
324
325
32 6
327
32 8
32 9
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
Appendix IV - Chronlogical. pde - 4/9
if(ghostrand < overscrollfreq){
float temprand = random(O, 87);
ybumpcounter = scrollstop - int(temprand) ;
maintext . foreground();
temprand = 5. 0-;
ybumpcounter = scrollstop + int(temprand);
maintext.foreground();
scrollon = true;
println( "OVERSCROLLED! ! ! ");
if(ghostrand <= jitterbackfreq){
// jitterback LONG
fadenoisescale = 0.0;
botfadenoise2 = 0.0;
botfadeoncounter = O;
botfadeon = false;
float temprand;
temprand = random(l20, 500);
jitterbackstop = int(temprand) ;
jitterbackon = true;
}
if(ghostrand > jitterbackfreq){
// jitterback SHORT
resetMatrix();
noStroke();
fill(bg, 120);
rectMode(CORNER);
rect(O, O, width, height);
resetMatrix();
float temprand;
temprand = 5.0;
ybumpcounter = scrollstop + int(temprand) ;
maintext . foreground();
scrollon = true;
}
if(ghostrand < l){
float temprand = random(O, 2000);
delay(int(temprand));
364
365
366
367
368
369
370
371
372
37 3
374
375
37 6
377
37 8
37 9
380
38 1
Appendix IV - Chronlogical. pde - 5/9
if (scrollon==true){
float lastcount = yburnpcounter+l;
yburnpcounter = yburnpcounter - scrollincr ;
//println (yburnpcounter);
if(yburnpcounter yburnpcounter ){
resetMatrix() ;
noStroke();
f i 11 ( bg, 8 ) ;
rectMode(CORNER);
rect(O, 0, width, height);
resetMatrix();
382
383
384
385
386
//println( "DING!!!");
387
388
if(ghostrand < ghostfreq){
389
int refreshghost = int(randorn(O, ghosts.size()));
390
Ghost ghost= (Ghost) ghosts.get(refreshghost);
391
ghost.display() ;
392
//println("Ghost Refresh: " + refreshghost);
393
394
I*
395
for (inti= ghosts.size()-1; i >= O; i--){
396
Ghost ghost= (Ghost) ghosts.get(i);
397
ghost.display();
39 8
}
399
*I
400
}
401
noisescale = noisescale + 0.06;
40 2
scrollratenoise = noise(noisescale) * scrollrate;
40 3
//xjitter = scrollratenoise ; //!! ! <--jitter control
404
//println("Scroll Rate Noise: "+ scrollratenoise) ;
40 5
40 6
rnaintext.foreground();
407
408
40 9
41 0
41 1
41 2
if(jitterbackon==true){
41 3
float ternprand = randorn(O, 120) ;
414
41 5
resetMatrix();
41 6
noStroke();
41 7
fill(bg , 200);
418
rectMode(CORNER);
41 9
rect(O, O, width, height);
420
resetMatrix();
42 1
42 2
yburnpcounter = yburnpcounter + int(ternprand);
42 3
rnaintext.foreground();
42 4
42 5
if (yburnpcounter > jitterbackstop){
42 6
jitterbackstop = O;
42 7
42 8
jitterbackon = false;
42 9
scrollon = true;
430
431
4 32
433
4 34
//crawl();
435
crawlcounter = crawlcounter + 1;
436
if (crawlcounter
headlinestring.length){
4 37
crawlcounter = O;
43 8
}
439
440
stall();
441
442 }
44 3
444 void textheight(String f_ternpheadlinestring){
44 5
44 6
headwidth = height-xrnargins*2;
44 7
44 8
String ternpheadlinestring = f_ternpheadlinestring;
44 9
45 0
String[] headtokens = splitTokens(ternpheadlinestring , " ");
451
452
String[] headtry = new String[l];
45 3
String[] headwtryternp = new String[l ];
454
String[] newline= new String [l];
\,.
455
45 6
45 7
45 8
45 9
46 0
461
462
463
464
465
466
467
468
46 9
470
471
4 72
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
String spacer=" ";
Appendix IV - Chronlogical. pde - 6/9
int
int
int
int
int spacecounter = O;
int wordcounter = O;
int ternporaryint = 214;
int linewidth = O;
int prevline = O;
int prevcounter = O;
boolean dontaddline
true;
linecounter = O;
//println(headstringMAX);
//println(headxburnp);
while(prevcounter+lheadwidth){
dontaddline = false;
}
else
509
510
511
512
51 3
514
515
516
51 7
518
519
52 0
521
52 2
52 3
52 4
52 5
526
527
528
52 9
530
531
532
533
534
dontaddline = true;
/ /println( "Newline: " + newline [ 0]);
//println("Linewidth: "+ linewidth);
//println("Headwidth: "+ (width-xrnargins*2));
spacecounter = spacecounter + 1 ;
wordcounter = wordcounter + 1;
headtry = append(headtry, spacer);
495
496
497
498
499
500
501
502
503
504
505
506
507
508
originalstringMAX = headtokens.length;
stringMAXcounter = O;
headstringMAX = headtokens.length;
ternpstringMAX = headstringMAX;
if(spacecounter+l>=ternpstringMAX){
linewidth = height+lO;
prevcounter = prevcounter+spacecounter;
//println("HeadTokens Length: "+ headtokens.length);
//println("HeadStringMAX: "+ headstringMAX);
//println("Original: "+ originalstringMAX);
//editing BU
//if(headtokens.length != ternpstringMAX){
if(spacecounter < originalstringMAX){
headtokens = subset(headtokens, spacecounter);
ternpstringMAX = headtokens.length;
stringMAXcounter = stringMAXcounter+ternpstringMAX-1;
//println("StringMAXcounter: "+ stringMAXcounter);
//println("TEMPSTRINGMAX : "+ ternpstringMAX);
//println("PrevCounter: "+ prevcounter);
//println("Don't Add Line: "+ dontaddline);
if(originalstringMAX-prevcounter == 1 && dontaddline==false){
linecounter = linecounter + 1;
}
linecounter = linecounter + 1;
spacecounter=O;
wordcounter=O;
linewidth=O;
headtry = new String[l];
newline[O] = "";
535
536
537
538
539
540
54 1
542
543
54 4
54 5
//println ("Linecounter #1:
" + linecounter);
headheight = linecounter*headtextlead;
//println ("Headheight: "+ headheight);
void botFade(){
for (inti= l; i<=height; i++){
fadenoisescale = fadenoisescale + 0.17;
botfadenoise2= botfadenoise2 + 0.08;
float botfadenoise = noise(fadenoisescale) * botfadenoise2;
float botfadeloc
width-botfadeheight-botfadenoise;
float tempmidnum
height/2;
float riserand
random(O, 17);
float leftrise
map(i+riserand, O, tempmidnum , botfadeadd, O);
float rightrise = map(i-riserand , tempmidnum, width, O, botfadeadd);
float rise= 0.0;
if (i <= tempmidnum){
rise= leftrise;
}
if (i > tempmidnum){
rise= rightrise;
/ /println ( Leftrise:
/ /println ( Rightrise:
11
11
11
11
+ leftrise);
+ rightrise);
resetMatrix();
for (int j = width; j >= botfadeloc-rise; j--){
float botfadealpha = map(j, botfadeloc-rise, width, 0, 179);
//stroke(O, 255, O, int(botfadealpha));
stroke(bg, botfadealpha);
point(j, i);
void crawl(){
resetMatrix();
noStroke();
fill(bg);
rectMode(CORNER);
rect(l5, height-12, width, 12);
textFont(crawlFont);
fill(O);
text(headlinestring[crawlcounter], 15, height-4);
resetMatrix();
void updateRSS(){
//background(bg);
headlinestring = new String[splittitles.length];
arrayCopy(splittitles, headlinestring);
storeprevfirst = headlinestring[OJ;
storeprevsecond = headlinestring[l];
textheight(headlinestring[O]);
startscrollloc = width+headheight/2;
ybumpcounter = startscrollloc;
nextlinecount = O;
maintext = new EngravedText();
ghosts.clear();
for (inti= l; i < headlinestring.length; i++){
float ghostjitterrand = random(l, 50);
5
5
7
B
9
D
ghosts.add(new Ghost(i, ghostjitterrand));
}
for (inti= ghosts.size()-!; i >= O; i--){
Ghost ghost= (Ghost) ghosts.get(i);
ghost.display();
1
2
3
4
5
5
7
maintext.foreground();
scrollon = true;
8
9
0
1
2
3
void stall ( ) {
float linetotal = linefreq*frate;
float lineincr = width/linetotal;
float randonum = random(O, lineincr);
lineincr = lineincr - randonum;
4
5
6
float randoline = random(O, width);
Appendix IV - Chronlogical.pde - 7/9
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
72 0
721
722
72 3
724
725
7 26
727
float randocl = random ( bgfloat , 255 );
strok e ( randocl );
// stroke ( O, 255 , O);
for ( int i = O; i < linestrok e ; i++ ) {
line ( lineloc-i , O, lineloc-i , height );
Appendix IV - Chronlogical.pde - 8/9
lineloc -= lineincr ;
if ( linelocpubDates.length){
tempcatch = int(pubDates.length);
}
if(splittitles.length= 5*60*frate){
float tempscrollrate = map(waitcounter, 5*60*frate, waitmax, scrollrate, 5000);
//println("tempscrollrate: "+ tempscrollrate);
scrollincr = tempscrollrate/(frate*60);
/*
if(linefreq>=0.5){
float templinefreq = map(waitcounter, 5*60*frate, 0.6*waitmax, startlinefreq, 0.5);
println("templinefreq: "+ templinefreq);
linefreq = templinefreq;
float templinestroke = map(waitcounter, 5*60*frate, 0.6*waitmax, startlinestroke, 5);
println("templinestroke: "+ templinestroke);
linestroke = templinestroke;
}
*I
}
if(waitcounter >= 7*60*frate && waitcounter<0.8*waitmax){
float tempjitterbackfreq = map(waitcounter, 7*60*frate, 0.8*waitmax, startjitterbackfreq, 10);
//println("tempjitterbackfreq: "+ tempjitterbackfreq);
jitterbackfreq = tempjitterbackfreq;
if(jitterbackfreq <= 50 && triggergfstore == true){
waitcounterstore = float(waitcounter);
triggergfstore = false;
}
if(jitterbackfreq <= 50){
float tempghostfreq = map(waitcounter, waitcounterstore, waitmax, startghostfreq, 30);
l/println("tempghostfreq: "+ tempghostfreq);
ghostfreq = tempghostfreq;
overscrollfreq = tempghostfreq;
1
/* EngravedText.pde ( class required by " Chronological ")*/
2
3
4
5
6
7
Appendix IV - EngravedText.pde - 1/2
class EngravedTe x t{
EngravedText( ){
graphictest ( ) ;
8
9
void display (){
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
so
51
52
53
54
55
void foreground(){
//yburnpcounter =
height/2;
resetMatrix();
translate(width/2, height/2);
irnageMode(CENTER);
noTint();
stroke ( bg);
//fill(bg, 30);
rectMode(CORNER);
//rect(O , O, width, height);
resetMatrix();
translate(yburnpcounter, height/2+xjitter);
rectMode(CENTER);
irnageMode(CENTER);
irnage(testirng, 0, 0, testirng.width, testirng.height);
resetMatrix();
void buildtrail(){
startscrollloc = width+headheight/2;
yburnpcounter = startscrollloc;
for(int i = O; i < height/2+headheight/2-l; i++){
resetMatrix();
translate(width/2, height/2);
irnageMode(CENTER);
//rnarblel.display();
noTint ();
stroke ( bg) ;
fill(bg, bgalpha);
rect(O, 0 , width, height);
resetMatrix();
translate(yburnpcounter, height/2);
rectMode(CENTER);
irnageMode(CENTER);
//stroke(O);
//rect(O, 0 , testirng .width, testirng.height);
irnage(testirng, 0, 0, testirng.width, testirng.height);
56
57
yburnpcounter
=
yburnpcounter -
l;
58
59
60
61
62
63
64
65
66
67
68
69
resetMatrix();
void graphictest(){
testee
=
createGraphics(height, width, JAVA2D);
85
testee.colorMode(ARGB);
testee.beginDraw();
testee.resetMatrix();
testee.background(bg);
testee.translate(testee.width/2, testee.height/2);
testee.scale(-1.0, 1.0);
testee . rotate(PI*0.5);
testee.rectMode(CENTER);
testee.textAlign(CENTER);
testee.textFont(yayfont);
testee.textLeading(headtextlead);
testee.fill(textburn2);
testee . text(headlinestring(nextlinecount] , O, O, -headwidth , headheight);
testee.fill(textfill);
testee.text(headlinestring(nextlinecount], 3, 3, -headwidth, headheight);
testee.fill(textburn);
testee.text(headlinestring(nextlinecount] , 0, O, -headwidth, headheight);
testee.resetMatrix();
testee.endDraw();
86
87
testirng
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
=
createirnage(testee.width, testee.height, ARGB);
88
89
90
91
testirng.loadPixels();
for(int i = O; i < testirng . pixels.length; i++){
92
93
testimg . pix els [ i ] = testee . pix els [ i ];
Appendix IV - EngravedText.pde - 2/2
94
95
96
97
98
99
1 00
1 01
1 02
1 03
10 4
10 5
for ( int x = O; x < testimg . width ; x ++ ){
for ( i n t y = O; y < testimg . heigh t ; y++ ){
if ( testee . pix els [x+y*testimg . width ] ==b g ){
testimg . pix els[ x +y *testimg . width ] = co l or ( O, O);
}
testimg . updatePix els ();
}
}
1
2
3
4
5
6
7
8
9
10
/* Ghost.pde ( class required by "Chronological")*/
Appendix IV - Ghost.pde - 1/2
class Ghost {
PGraphics ghostbuild ;
Pirnage ghostirng ;
Pirnage blobirng;
PGraphics blobbuild;
Pirnage blobchipirng;
PGraphics blobrnasked;
Pirnage blobrnaskedirng;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
int hline;
float ghostjitter;
Ghost(int c_nextlinecounter, float c_ghostjitter ){
hline = c nextlinecounter;
ghostjitter = C ghostjitter;
float ternpghostjitstore [] = ghostjitstore ;
ghostjitstore = append(ternpghostjitstore, ghostjitter);
textheight(headlinestring[hline]);
ghostbuild = createGraphics(width, height, JAVA2D);
ghostbuild.colorMode(ARGB);
ghostbuild.beginDraw();
ghostbuild.resetMatrix();
ghostbuild.background(bg);
ghostbuild.translate(width/2, height/2-ghostjitter);
ghostbuild.rectMode(CENTER);
ghostbuild.textAlign(CENTER);
ghostbuild.textFont(yayfont);
ghostbuild.textLeading(headtextlead);
ghostbuild.fill(textburn2);
ghostbuild.text(headlinestring[hline], O, O, headwidth, headheight);
ghostbuild.fill(textfill);
ghostbuild.text(headlinestring[hline], 2, 2 , headwidth, headheight);
ghostbuild.fill(textburn);
ghostbuild.tex t(headlinestring[hlineJ, O, 0, headwidth, headheight);
ghostbuild.resetMatrix();
ghostbuild.endDraw();
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ghostirng = createirnage(ghostbuild.width, ghostbuild.height, ARGB);
ghostirng.loadPixels();
for(int i = O; i < ghostirng . pixels.length; i++){
ghostirng.pixels[i] = ghostbuild.pixels[i];
for(int x = O; x < ghostirng.width; x++){
for(int y = O; y < ghostirng.height; y++){
if(ghostbuild.pixels[x+y*ghostirng.width]==bg){
ghostirng . pixels[x+y*ghostirng.width] = color(O, O);
if(ghostbuild.pixels[x+y*ghostirng.width]!=bg){
color ternpcolor = ghostbuild.pixels[x+y*ghostirng.width];
int ternpr = (ternpcolor >> 16) & OxFF;
// Faster way of getting red(argb)
int ternpg = (ternpcolor >> 8) & OxFF;
// Faster way of getting grcen(argb)
int ternpb = ternpcolor & OxFF;
// Faster way of getting blue(argb)
ghostirng.pixels[x+y*ghostirng.width] = color(ternpr, ternpg, ternpb, ghostalpha);
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
7
78
79
80
81
82
83
84
85
86
87
88
89
90
91
}
ghostirng.updatePixels();
blobirng = createirnage(ghostbuild.width , ghostbuild.height, ARGB);
blobirng.loadPixels();
for(int i = O; i < ghostbuild.pixels.length; i++){
blobirng.pixels[i] = ghostbuild.pixels[i];
}
blobirng.updatePixels();
theBlobDetection = new BlobDetection(blobirng . width, blobirng . height);
theBlobDetection . setPosDiscrirnination(false);
theBlobDetection.setThreshold(0.38f);
theBlobDetection.cornputeBlobs(blobirng.pixels) ;
ghostchip ( ) ;
void display(){
resetMatrix();
translate(scrollstop , height/2);
rotate(PI/2);
irnageMode(CENTER);
//irnage(ghostirng, 0 , 0 , ghostirng .width , ghostirng.height);
92
93
llimage(blobimg, O, O, blobimg.width, blobimg.height);
I I image ( blobchipimg, 0, O, blobchipimg. width, blobchipimg. height) ;
94
95
96
97
image(blobmaskedimg, O, O, ghostimg.width , ghostimg.height);
llimage(blobbuild, O, O, blobbuild.width, blobbuild.height); II<-- Nice Boohoo
resetMatrix();
98
99
lldrawBlobsAndEdges(false,true);
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
12 0
void ghostchip(){
blobbuild = createGraphics(width, height, JAVA2D);
blobbuild.colorMode(ARGB);
blobbuild.beginDraw();
blobbuild.resetMatrix();
blobbuild.background(O);
blobbuild.translate(widthl2, heightl2-ghostjitter);
blobbuild.rectMode(CENTER);
blobbuild.textAlign(CENTER);
blobbuild.textFont(yayfont);
blobbuild.textLeading(headtextlead);
blobbuild.fill(ghostalpha);
blobbuild.text(headlinestring[hline], O, O, headwidth, headheight);
blobbuild.resetMatrix();
noFill ();
Blob b;
EdgeVertex eA,eB;
for (int n=O ; n