This is the SketchMapper library for processing.
SketchMapper is a GUI tool that allows you to map processing sketches on surfaces.
This was built off of the Surface Mapper library by Ixagon and the original SurfaceMapperGui by Jason Webb.
This is mostly their work ! This is just adapted to do some different things.
Processing 3 - 4.2.0
Processing 2 - 3.0.2
uses ControlP5 version 2.2.6 when using this library, the ControlP5 library must be imported as well.
This section will describe how to build the library
you will need maven installed.
clone the processing-deps project, cd into the root directory of it and run:
./install.sh
This will install the processing dependencies and a number of libraries in your local maven repository (we will need ControlP5). Once you have the dependencies installed, go into the root dir of this project and run:
./build.sh
This will put the library folder called SketchMapper
in the target
directory as well as a SketchMapper.zip
archive. Copy the folder to your processing sketchbook's libraries folder to use it in processing.
This section is about how to use the library in your processing sketches.
This library provides a Sketch
interface and AbstractSketch
base implementation that are to be extended to create skeches. This is a base template for a TestSketch
that draws an ellipse in the middle of the screen:
public class TestSketch extends AbstractSketch {
public TestSketch(final PApplet parent, final int width, final int height) {
super(parent, width, height);
}
@Override
public void draw() {
graphics.beginDraw();
graphics.background(255);
graphics.fill(0);
graphics.ellipse(graphics.width / 2, graphics.height / 2, 25, 25);
}
graphics.endDraw();
}
@Override
public void keyEvent(KeyEvent event) {
}
@Override
public void mouseEvent(MouseEvent event) {
}
@Override
public void setup() {
}
}
The constructor must be present and at least have that super
call.
Notice in the draw
method we are using graphics
to do the drawing. graphics
is defined in AbstractSketch
and is an instance of PGraphics
that is unique to this sketch.
AbstractSketch
also has a parent
variable that is the parent PApplet
class or the main sketch creating this sketch. Use the parent
object when you need to call processing methods.
setup
is invoked once by SketchMapper
when the sketch is initialized.
The keyEvent
and mouseEvent
methods get invoked on key events and mouse events respectively.
Construct the SketchMapper
object by passing it this
from your main sketch.
SketchMapper sketchMapper = new SketchMapper(this);
You can also construct a SketchMapper
object that specifies a default layout file to load.
If a relative path is specified it will look in the sketch's data
folder, otherwise it looks at the absolute path specified.
SketchMapper sketchMapper = new SketchMapper(this, "myLayout.xml");
As of version 4.2.0
, SketchMapper will automatically find any classes that
extend AbstractSketch
and add them to the list.
Alternatively, you can add sketches to the SketchMapper
using the addSketch()
method.
sketchMapper.addSketch(new TestSketch(this, 500, 500));
The sketches that are added will show up in the sketch drop-down in the UI.
The only other requirement is that you call the draw
method on the object at the top of your draw
function.
public void draw() {
sketchMapper.draw();
}
quad surfaces and bezier surfaces can be added to the sketch by using the buttons
Create a new Quad Surface and Create a new Bezier Surface
Click on a surface to select it.
Select the desired sketch from the dropdown list of sketches
You can move a surface by clicking in the middle of it and dragging it.
You can change the shape of the surface by dragging it's corners.
Alternatively, if you click on a corner to highlight it, you can use the arrow keys to move it more precisely
Surfaces can be removed by clicking on them to highlight them and pressing the delete
key.
Your surface layout can be saved by clicking on Save Layout.
The sketch will prompt you for a place to save it.
Layouts are saved in XML format and include the layout of the surfaces and which sketches are on which surfaces.
To load a layout, click on Load Layout and open the layout in the pop-up dialog.
To run the thing, click on Switch to render mode.
Double click anywhere on the canvas while in render mode to return to calibration mode.