-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe-transitions.js
125 lines (112 loc) · 3.32 KB
/
frame-transitions.js
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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
load("sbbsdefs.js");
// this version masks the entire sprite up front.
function maskFrame(theFrame,maskChar,maskAttr) {
var x, y, xl, yl;
xl = theFrame.data.length;
for (x=0; x<xl; x++) {
yl = theFrame.data[x].length;
for (y=0; y<yl; y++) {
var theChar = theFrame.data[x][y];
// If this character is an empty black space,
// then delete the character attributes in order
// to make it act as transparent.
if (theChar.ch == maskChar && theChar.attr == maskAttr) {
theFrame.data[x][y].ch = undefined;
theFrame.data[x][y].attr = undefined;
}
}
}
}
// Dissolve entire frame
function dissolve(theFrame,color,delay) {
if (typeof(color) === "undefined") { color = BLACK; }
if (typeof(delay) === "undefined") { delay = 1; }
var x, y, xl, yl, pixelArray = [];
xl = theFrame.width;
yl = theFrame.height;
for (x=0; x<xl; x++) {
for (y=0; y<yl; y++) {
pixelArray.push([x,y]);
}
}
while( pixelArray.length > 0 ) {
var randomIndex = Math.floor(Math.random() * pixelArray.length);
var randomPixel = pixelArray.splice(randomIndex, 1);
// ascii(219) = solid block; 5 = Magenta
theFrame.setData(randomPixel[0][0],randomPixel[0][1],ascii(219),color);
theFrame.cycle();
// cycle sprites if there are any, so they remain on top layer.
if (typeof Sprite !== 'undefined') {
Sprite.cycle();
}
if (delay > 0) {
mswait(delay);
}
}
}
//Dissolve, wiping down from top
function wipeDown(theFrame,wipeSize,color,delay) {
if (typeof(wipeSize) === "undefined") { wipeSize = 2; }
if (typeof(color) === "undefined") { color = BLACK; }
if (typeof(delay) === "undefined") { delay = 1; }
var x, y, xl, yl, p, pixelArray = [];
xl = theFrame.width;
yl = theFrame.height;
for (y=0; y<yl; y+=wipeSize) {
for (p=0;p<wipeSize; p++) {
pixelArray[p] = [];
for (x=0; x<xl; x++) {
pixelArray[p].push(x);
}
}
while( pixelArray[0].length > 0 ) {
for (p=0;p<wipeSize; p++) {
var randomIndex = Math.floor(Math.random() * pixelArray[p].length);
var randomPixel = pixelArray[p].splice(randomIndex, 1);
// ascii(219) = solid block; 5 = Magenta
theFrame.setData(randomPixel,y+p,ascii(219),color);
theFrame.cycle();
// cycle sprites if there are any, so they remain on top layer.
if (typeof Sprite !== 'undefined') {
Sprite.cycle();
}
if (delay > 0) {
mswait(delay);
}
}
}
}
}
//Dissolve, wiping right from left
function wipeRight(theFrame,wipeSize,color,delay) {
if (typeof(wipeSize) === "undefined") { wipeSize = 5; }
if (typeof(color) === "undefined") { color = BLACK; }
if (typeof(delay) === "undefined") { delay = 1; }
var x, y, xl, yl, p, pixelArray = [];
xl = theFrame.width;
yl = theFrame.height;
for (x=0; x<xl; x+=wipeSize) {
for (p=0;p<wipeSize; p++) {
pixelArray[p] = [];
for (y=0; y<yl; y++) {
pixelArray[p].push(y);
}
}
while( pixelArray[0].length > 0 ) {
for (p=0;p<wipeSize; p++) {
var randomIndex = Math.floor(Math.random() * pixelArray[p].length);
var randomPixel = pixelArray[p].splice(randomIndex, 1);
// ascii(219) = solid block; 5 = Magenta
theFrame.setData(x+p,randomPixel,ascii(219),color);
theFrame.cycle();
// cycle sprites if there are any, so they remain on top layer.
if (typeof Sprite !== 'undefined') {
Sprite.cycle();
}
if (delay > 0) {
mswait(delay);
}
}
}
}
}