Matrix effect funzionante, scie fluide, visualizza immagine colorando le lettere pixel per pixel

This commit is contained in:
2026-02-02 00:42:10 +01:00
commit d760535714
2 changed files with 191 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="3"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

View File

@@ -0,0 +1,156 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package matrix2;
import java.awt.Color;
import java.awt.Point;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.Timer;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
/**
*
* @author mstc
*/
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 List <Colonna> colonne =new ArrayList<>();
/**
* Creates new form MatrixForm
*/
public MatrixForm() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setExtendedState(JFrame.MAXIMIZED_BOTH);
getContentPane().setBackground(Color.BLACK);
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);
initComponents();
// col = new Colonna(30,this.getHeight());
// this.add(col);
// col.addChar('A');
// col.addRandomChar();
// Colonna c = new Colonna();
// this.add(c);
// colonne.add(c);
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
if (getHeight() <= 0) {
return;
}
resetColonne();
}
});
this.setVisible(true);
// === TIMER (30 FPS circa) ===
Timer timer = new Timer(1, e -> aggiorna());
timer.start();
}
private void aggiorna(){
repaint();
if (colonne.size()<Maxcol){
Colonna c = new Colonna(randomPointX(), this.getHeight());
this.add(c);
colonne.add(c);
}
for (int i = colonne.size() - 1; i >= 0; i--) {
if (colonne.get(i).isDead()){
this.remove(colonne.get(i));
colonne.remove(i);
}else{
if (colonne.get(i).getBoundsRect().intersects(logo.getBoundsRect())) {
// la colonna passa sopra al logo
Colonna c = colonne.get(i);
for(Lettera l:c.getLettere()){
if (logo.isLetterInsideLogo(l.getPositionGlobal(c.getLocation()), l.getSize())){
logo.modificaLettera(l,c.getLocation());
}
}
}
}
}
}
private int randomPointX(){
int min=0;
int max=this.getWidth();
return (int) (min + Math.random() * (max - min));
}
private void resetColonne() {
// colonne.forEach(this::remove);
// colonne.clear();
// calcolaColonne();
for (Colonna col:colonne){
col.setSize(col.getWidth(), this.getHeight());
col.setHeight(this.getHeight());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ReflectiveOperationException | javax.swing.UnsupportedLookAndFeelException ex) {
logger.log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> new MatrixForm().setVisible(true));
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}