Include a sound for capturing image and a button

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 84a3ce417c
commit 12d186a378
  1. BIN
      bin/screenshot.png
  2. BIN
      ding.wav
  3. BIN
      screenshot.png
  4. 10
      scripts/md5
  5. 53
      src/sig/ArcadeScreenshotHandler.java
  6. 27
      src/sig/engine/Panel.java
  7. 10
      utils/md5
  8. 2
      utils/search.sh

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

@ -1,5 +1,5 @@
build.sh:a833e7598ad65672a9c01306d244b49f -
clean.sh:96ce35f2d2dcb555421e00a6afda23ca -
commit.sh:21af1fa6f09d01679c9e11408967264a -
jar.sh:2ac636f584c43a1124affb9ea6bdc7bf -
lean.sh:3be7b8b182ccd96e48989b4e57311193 -
build.sh:de32fdf9f3ce9eb5d4ea9902ee48dbe0 *-
clean.sh:8aec15e447257f1c3a4e978f1b56a78e *-
commit.sh:a592fe2113538f8cf933907eeda13ddc *-
jar.sh:58c4f48f7e34425e55358a165a81c03b *-
lean.sh:3be7b8b182ccd96e48989b4e57311193 *-

@ -7,9 +7,17 @@ import java.awt.AWTException;
import java.awt.GraphicsEnvironment;
import javax.imageio.ImageIO;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sig.engine.Panel;
public class ArcadeScreenshotHandler {
@ -17,26 +25,53 @@ public class ArcadeScreenshotHandler {
public static final String PROGRAM_NAME="Sig's Java Project Template";
public static void main(String[] args) {
JFrame f = new JFrame(PROGRAM_NAME);
Panel p = new Panel(f);
JButton button = new JButton("Capture");
JLabel text = new JLabel("");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
BufferedImage img;
try {
img = CaptureScreen();
ImageIO.write(img,"png",Path.of("..","screenshot.png").toFile());
} catch (IOException e1) {
e1.printStackTrace();
}
playSound(Path.of("..","ding.wav"));
}
p.init();
});
f.add(p);
f.setSize(1280,720);
f.add(button);
//f.add(text);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
p.render();
try {
r = new Robot();
BufferedImage img = CaptureScreen();
ImageIO.write(img,"png",Path.of("screenshot.png").toFile());
} catch (AWTException | IOException e) {
} catch (AWTException e) {
e.printStackTrace();
}
}
public static void playSound(Path file) {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file.toFile());
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
// If you want the sound to loop infinitely, then put: clip.loop(Clip.LOOP_CONTINUOUSLY);
// If you want to stop the sound, then use clip.stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static BufferedImage CaptureScreen() throws IOException {
BufferedImage screenshot = r.createScreenCapture(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
//ImageIO.write(screenshot,"png",new File("screenshot.png"));

@ -108,33 +108,6 @@ public class Panel extends JPanel implements Runnable {
p[y*width+x]=(0<<16)+(0<<8)+0;
}
}
x_offset+=1;
y_offset=50;
FillPolygon(p,Color.WHITE,50,50,new Point[] {
new Point(135,2),
new Point(166,96),
new Point(265,97),
new Point(185,156),
new Point(215,251),
new Point(134,192),
new Point(54,251),
new Point(84,156),
new Point(4,97),
new Point(103,96),
});
FillPolygon(p,Color.BRIGHT_CYAN,x_offset,y_offset,new Point[] {
new Point(28,29),
new Point(78,103),
new Point(120,31),
new Point(123,221),
new Point(30,218),
});
//FillRect(p,Color.BRIGHT_RED,200,200,600,64);
final Color testAlpha = new Color(150,0,0,128);
FillCircle(p,testAlpha,150,150,100);
FillOval(p,Color.BRIGHT_GREEN,300,150,100,50);
}
public void FillRect(int[] p,Color col,double x,double y,double w,double h) {

@ -1,5 +1,5 @@
.coauthors:3785ad38663e5fc43e574914ad067294 -
define.sh:d6b20a25a04a60d94f466e48fa60ac69 -
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 -
search.sh:28d0ede8345514d80cc68cc756870002 -
.updateDirectories:0ede00461e947494545e694040787b3f -
.coauthors:3785ad38663e5fc43e574914ad067294 *-
.updateDirectories:0ede00461e947494545e694040787b3f *-
define.sh:d6b20a25a04a60d94f466e48fa60ac69 *-
main.sh:32a1f953ffca8584d1eb57c0ecd8a582 *-
search.sh:6eec52214a36f2114442c41ab9c04f72 *-

@ -37,6 +37,7 @@ function check() {
if [ "$g" != "md5" ]; then
if [ -f $1$g ];
then
if [ "$g" != ".coauthors" ]; then
echo "++Redownload $1$g..."
if [ -f "$1$g" ]; then
#Read the 2nd line and see if it has a special directory.
@ -58,6 +59,7 @@ function check() {
echo "===Could not find directory, assuming regular scripts directory exists."
curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output scripts/$g
fi
fi
else
echo "++==Downloading $1$g..."
curl -H 'Cache-Control: no-cache, no-store' https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g --output $1$g

Loading…
Cancel
Save