Skip to content

Instantly share code, notes, and snippets.

View antic-ml's full-sized avatar

Mario Gianota antic-ml

View GitHub Profile
@antic-ml
antic-ml / BinaryDigitMosaic.pde
Created September 11, 2020 16:41
Creates a "binary digit mosaic" of a JPG file
/**
* Load a JPG image and convert it into a "binary digit mosaic"
*
* Author: Mario Gianota, September 2020
*/
PImage img; // Declare variable of type PImage
boolean once = false;
PFont myFont;
int x;
@antic-ml
antic-ml / BrowserOpen.java
Created September 6, 2020 18:11
Open the system's native web browser from Java and display a URL
/**
* Open the system's native web browser to display a URL.
*/
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class BrowserOpen {
@antic-ml
antic-ml / Hex2Dec.java
Created September 6, 2020 17:45
Convert hex to decimal
import java.text.NumberFormat;
public class Hex2Dec {
public static int hexToDec(String hex) {
String hexStr = hex.toUpperCase();
if( hexStr.startsWith(("0x")))
hexStr = hexStr.substring(2,hexStr.length()-1);
@antic-ml
antic-ml / Screenshot.java
Created September 6, 2020 17:36
Java program to capture the screen and save it out as a PNG
/**
* Grabs a shot of the screen and saves it out as a PNG file.
*/
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
@antic-ml
antic-ml / Wavelength2RGB.java
Created September 6, 2020 17:19
A Java program that converts a wavelength of light in nanometers to an RGB colour.
/**
* A Java program that converts a wavelength of light in nanometers to an RGB colour. See the main method for example
* usage.
*
* It uses linear interpolation over the "CIE 1964 standard observer" table and sRGB matrix + gamma correction
* to do the conversion.
*
*/
public class Wavelength2RGB {
static int