Skip to content

Instantly share code, notes, and snippets.

@phivk
Created December 26, 2020 16:42
Show Gist options
  • Save phivk/e36410402fdeaa10cd26fb334c264080 to your computer and use it in GitHub Desktop.
Save phivk/e36410402fdeaa10cd26fb334c264080 to your computer and use it in GitHub Desktop.
gifloopcoder happy new year gif 2020-2021
function onGLC(glc) {
glc.loop();
// glc.size(400, 400);
// glc.setDuration(5);
// glc.setFPS(20);
// glc.setMode("single");
// glc.setEasing(false);
// glc.setMaxColors(256);
var list = glc.renderList,
width = glc.w,
height = glc.h;
var color_1 = "#FBD05F",
color_2 = "#EC4B6C",
color_3 = "#255279";
glc.styles.backgroundColor = color_3;
var unit = 400/17;
// zero
var zero = [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 1, 1, 0, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 0, 1, 1, 1, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
]
// one
var one = [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 1, 0, 0, 0, 0 ],
[ 0, 0, 1, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 1, 1, 1, 1, 1, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
]
// two
var two = [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 1, 1, 0, 0, 0 ],
[ 0, 0, 1, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ],
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ],
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 0, 0, 0, 0, 0 ],
[ 0, 0, 1, 1, 1, 1, 1, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
]
// list.addGrid({
// x: 0,
// y: 0,
// w: width,
// h: height,
// lineWidth: 1,
// gridSize: unit,
// })
function print_matrix(matrix, offset_x, offset_y) {
var scale_factor = 0.25;
for (var i = 0; i < 9; i++) {
for (var j = 0; j < 9; j++) {
var cell = matrix[i][j];
list.addCircle({
x: (offset_x + j) * unit,
y: (offset_y + i) * unit,
stroke: true,
strokeStyle: [color_1, color_2],
fill: false,
radius: [
cell? unit * scale_factor : unit,
cell? unit : unit * scale_factor,
],
lineWidth: 3,
});
}
}
}
function tween_matrices(matrix1, matrix2, offset_x, offset_y) {
var scale_factor = 0.25;
for (var i = 0; i < 9; i++) {
for (var j = 0; j < 9; j++) {
var cell1 = matrix1[i][j];
var cell2 = matrix2[i][j];
list.addCircle({
x: (offset_x + j) * unit,
y: (offset_y + i) * unit,
stroke: true,
strokeStyle: [color_1, color_2],
fill: false,
radius: [
cell1? unit * scale_factor : unit,
cell2? unit : unit * scale_factor,
],
lineWidth: 3,
});
}
}
}
print_matrix(two, 0, 0);
print_matrix(zero, 9, 0);
print_matrix(two, 0, 9);
tween_matrices(zero, one, 9, 9);
}
@phivk
Copy link
Author

phivk commented Dec 26, 2020

happy-new-year-2020-2021-3s-lossy140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment