Matrix effect funzionante, scie fluide, visualizza immagine colorando le lettere pixel per pixel, parametri settabili
This commit is contained in:
@@ -23,14 +23,24 @@ public class MatrixForm extends javax.swing.JFrame {
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(MatrixForm.class.getName());
|
||||
private int Maxcol=500;
|
||||
private Logo logo;
|
||||
private Color background=Color.black;
|
||||
private List <Colonna> colonne =new ArrayList<>();
|
||||
private boolean sovrapposizione=true;
|
||||
private int velocita=1;
|
||||
private Min_Max dissolvenza=null;//new Min_Max(0.01f, 0.02f);
|
||||
private Integer max_lettere=null;
|
||||
private Integer spazio=null;
|
||||
private Color c_lettere=new Color(0, 255, 0, 255);
|
||||
private Color c_colonna=null;
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form MatrixForm
|
||||
*/
|
||||
public MatrixForm() {
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
getContentPane().setBackground(Color.BLACK);
|
||||
getContentPane().setBackground(background);
|
||||
getContentPane().setLayout(null);
|
||||
// logo= new Logo("/home/mstc/Scaricati/io.jpg",new Point(400,100),75);
|
||||
logo= new Logo("/home/mstc/Scaricati/mondo2.png",new Point(400,100),200);
|
||||
@@ -58,16 +68,60 @@ public class MatrixForm extends javax.swing.JFrame {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
private boolean canPlaceColumn(int newX, int newWidth) {
|
||||
for (Colonna c : colonne) {
|
||||
int existingStart = c.getX();
|
||||
int existingEnd = c.getX() + c.getWidth();
|
||||
int newStart = newX;
|
||||
int newEnd = newX + newWidth;
|
||||
|
||||
if (newEnd > existingStart && newStart < existingEnd) {
|
||||
return false; // c’è sovrapposizione
|
||||
}
|
||||
}
|
||||
return true; // nessuna sovrapposizione
|
||||
}
|
||||
|
||||
private Colonna createNonOverlappingColumn() {
|
||||
int newWidth;
|
||||
int newX;
|
||||
int attempts = 0;
|
||||
if (!sovrapposizione){
|
||||
do {
|
||||
newWidth = randomPointX(); // larghezza casuale
|
||||
newX = (int) (Math.random() * (getWidth() - newWidth));
|
||||
attempts++;
|
||||
if (attempts > 100) {
|
||||
// evita loop infinito
|
||||
return null;
|
||||
}
|
||||
} while (!canPlaceColumn(newX, newWidth));
|
||||
}else{
|
||||
newX=randomPointX();
|
||||
}
|
||||
// Colonna c = new Colonna(newX, getHeight());
|
||||
Colonna c = new Colonna(newX, getHeight(),velocita,dissolvenza,max_lettere,spazio,c_colonna,c_lettere);
|
||||
colonne.add(c);
|
||||
this.add(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
private void aggiorna(){
|
||||
|
||||
repaint();
|
||||
|
||||
if (colonne.size()<Maxcol){
|
||||
Colonna c = new Colonna(randomPointX(), this.getHeight());
|
||||
this.add(c);
|
||||
colonne.add(c);
|
||||
}
|
||||
if (colonne.size() < Maxcol) {
|
||||
createNonOverlappingColumn();
|
||||
}
|
||||
|
||||
for (int i = colonne.size() - 1; i >= 0; i--) {
|
||||
Colonna c = colonne.get(i);
|
||||
if (c.isDead()) {
|
||||
this.remove(c);
|
||||
colonne.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = colonne.size() - 1; i >= 0; i--) {
|
||||
if (colonne.get(i).isDead()){
|
||||
this.remove(colonne.get(i));
|
||||
|
||||
Reference in New Issue
Block a user