This java application written using Swing framework let you create bidimensional matrices animations.
Everything revolves around the idea of manipulating the animation through JavaScript code. You can interact with Java classes through JavaScript code thanks to Nashorn engine.
You should create a file called animation.js in the same folder where you're executing MatrixAnimator2D from. This is the file from where you'll interact with the application.
- A function called createAnimation with one parameter (the MatrixFrame instance).
function createAnimation(matrixFrame) {
var MatrixScene = Java.type("me.eduardwayland.matrixanimator.matrix.MatrixScene");
var matrixScene1 = new MatrixScene(java.awt.Color.GREEN);
var matrixScene2 = new MatrixScene(java.awt.Color.GRAY);
var y;
var x;
for (y = 0; y < matrixFrame.getRows(); y++) {
for (x = 0; x < matrixFrame.getCols(); x++) {
if (y % 2 == 0) matrixScene1.fillCell(y, x);
else matrixScene2.fillCell(y, x);
}
}
matrixFrame.addMatrixScene(matrixScene1);
matrixFrame.addMatrixScene(matrixScene2);
}
There are two available startup arguments: y(rows) and x(columns).
java -jar MatrixAnimator2D.jar <rows> <columns>