This is a library for processing by Taylor O'Connor
The SketchMapper library offers a GUI tool and code to allow you to
create sketches and map them onto surfaces.
This is built off of SurfaceMapper by
ixagon
and
SurfaceMapperGui
by Jason Webb
and works in Processing 2.2.1 and 3
Last update: 08/17/2018
4.2.0 for Processing 3 released 08/17/2018
3.0.2 for Processing 2 released 03/10/2016
Unzip the SketchMapper.zip archive and put the extracted SketchMapper
folder into the libraries folder of your processing sketches.
The reference, examples, and source are included.
Check out the Javadocs.
View the source on GitHub.
Simple example. You will need both of these files:
SketchMapperTest.pde
TestSketch.pde
Example showing loading a default layout. You will need:
SketchMapperTest.pde
TestSketch.pde
test_layout.xml ( in the sketch's
data
folder.)
This section is about how to use the library in your processing sketches.
NOTE: in order to use this library you must also import ControlP5 v2.2.6
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 thatsuper
call.
Notice in thedraw
method we are usinggraphics
to do the
drawing.graphics
is defined in
AbstractSketch
and is an instance ofPGraphics
that is unique to this sketch.
AbstractSketch
also has aparent
variable that is the parentPApplet
class or the main sketch creating this sketch. Use theparent
object when you need to call
processing methods.
setup
is invoked once bySketchMapper
when the sketch is initialized.
ThekeyEvent
andmouseEvent
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 with a default layout to load.
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 dropdown 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();
}
This section is about how to use the gui tool itself.
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.
Platforms: linux, windows
Processing: 2.2.1, 3.0a5, 3.0.1, 3.1, 3.4
SketchMapper, projection mapping, geometry, projection