Minuscule Java Graphics Library

Welcome to the home page of the Minuscule Java Graphics Library.

The Minuscule library is developed and maintained by Augustin Zidek. If you have any queries, suggestions, bug reports or donations :-), please contact me at (deobfuscate the email address first): minuscule[at]zidek[dot]eu. If you are lucky, you might even get the feature you would like implemented overnight.


What is Minuscule

  • Simple Java library for rapid prototyping of algorithms with graphic output
  • Free and open source (see downloads)
  • Initialises canvas in just two lines of code
  • Creates a canvas with zoom and drag-and-move abilities for you
  • Saves your time (and swearing) if you want to try something with graphics quickly
  • Small (less than 40 kB) and fast tool, follows the KISS principle
  • Highly customizable, feel free to download and modify for your needs
  • Its author is open for new ideas and suggestions (see contact details above)

What is Minuscule not (per se)

  • It is not a game engine
  • It is not a replacement for OpenGL or any other proper big graphics library
  • It is not 3D graphics library

Download

This is only archive page, use download link for the old versions at the main page.
Adding library into build path

After downloading, you must add the downloaded JAR file into your build path, see for instance this tutorial for Eclipse SDK. Or you can download the source code and use it directly by copying the contents of the archive into the folder where you other packages are stored.


Short tutorial with examples

Using Minuscule is easy, it is in fact one of its main principles. To start, you only need to type in these two lines.
// Import the Minuscule library
import eu.zidek.augustin.minuscule.*;
...
// The arguments of MinusculeWindow() are: width, height, window title and the background color
MinusculeWindow window = new MinusculeWindow(800, 600);
// Now obtain the canvas and you are ready to draw by calling appropriate canvas methods
Canvas canvas = window.getCanvas();

That's it! Now you can use all the methods that canvas provides for you. It is quite possible you will need to import also other Java classes that are used in this project, such as java.awt.Color, java.awt.Font or java.awt.Shape.

Javadoc

For the complete documentation see the Javadoc.


Drawing points

There are four methods available for drawing points (also with labels):
// Draw default point with coordinates (10, 10)
canvas.drawPoint(10, 10);

// Draw point with a label, placed next to the point
canvas.drawPoint(30, 40, "Point with a label");

// Draw blue point with diameter = 14
canvas.drawPoint(50, 100, 14, Color.BLUE);

// Method for drawing points which gives you the most control
canvas.drawPoint(100, 150, "P3", 10, Color.RED, Color.GREEN, 
                 LabelPosition.NORTH);

Screenshot

Demo 1 screenshot

Drawing lines

Two methods are available for drawing lines:
// Draw line from (50,10) to (350,150)
canvas.drawLine(50, 10, 350, 150);

// Draw line with given thickness and color
canvas.drawLine(350, 40, 40, 40, 15, Color.YELLOW);

// Draw semi-transparent green line
canvas.drawLine(200, 10, 200, 200, 10, new Color(0, 255, 0, 100));

Screenshot

Demo 2 screenshot

Drawing shapes

Minuscule can draw any Shape as defined in the standard Java libraries:
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.CubicCurve2D;
...
// Draw a custom shape - rectangle and fill it
Shape rectangle1 = new Rectangle(10, 10, 300, 150);
canvas.drawShape(rectangle1, Color.BLUE, true);

// Draw an unfilled rectangle
Shape rectangle2 = new Rectangle(100, 100, 200, 150);
canvas.drawShape(rectangle2, Color.GREEN, false);

// Draw a Bezier curve
Shape bezier = new CubicCurve2D.Double(50, 50, 400, -10, 300, 100, 400, 250);
canvas.drawShape(bezier, new Color(255, 0, 0, 100), true);

Screenshot

Demo 3 screenshot

Drawing grid and using Euclidean coordinates

Drawing grid is very easy with Minuscule. Also, it is often very convenient to use Euclidean style coordinate system instead of the computer graphics standard one (i.e. origin in the top left corner, y increases downwards). Switching to Euclidean coordinates is very easy as well:
// Draw grid with the given column and row size
canvas.drawGrid(20, 20);

// One can also use Euclidean coordinates
canvas.setEuclideanCoordinates(true);

// Draw the origin with a label
canvas.drawPoint(0, 0, "The origin");

Screenshot

Demo 4 screenshot

Playing with Minuscule

// Switch to Euclidean coordinate system
canvas.setEuclideanCoordinates(true);
// Constant to enable easy deg-->rad
final double deg2rad = 2 * Math.PI / 360;

canvas.drawGrid(40, 40);

// Draw an ellipse with r1 = diameter, r2 = 2*diameter
final int diameter = 100;
for (int i = 0; i < 360; i += 20) {
  // Calculate the coordinates
  final double x = Math.cos(i * deg2rad) * 2 * diameter;
  final double y = Math.sin(i * deg2rad) * diameter;

  // Calculate the color
  final int red = i * 255 / 360;
  final int green = 4 * i % 255;
  final int blue = 2 * i % 255;
  final Color pointColor = new Color(red, green, blue);

  final String label = "(" + Math.round(x) + "," + Math.round(y) + ")";
  canvas.drawPoint(x, y, label, 16, pointColor, Color.BLACK,
      LabelPosition.NORTHEAST);
}

canvas.drawPoint(0, 0, "ORIGIN");

Screenshot

Demo 5 screenshot

© 2014, Augustin Zidek. Web page done using Bootstrap and prism.js