sceneTexture.setStrokeColor(new MTColor(155,155,155));
frame.addChild(sceneTexture);
//Eraser button
PImage eraser = pa.loadImage(imagesPath + "Kde_crystalsvg_eraser.png");
MTImageButton b = new MTImageButton(eraser, pa);
b.setNoStroke(true);
b.translate(new Vector3D(-50,0,0));
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
switch (ae.getID()) {
case TapEvent.BUTTON_CLICKED:{
// //As we are messing with opengl here, we make sure it happens in the rendering thread
pa.invokeLater(new Runnable() {
public void run() {
sceneTexture.getFbo().clear(true, 255, 255, 255, 0, true);
}
});
}break;
default:
break;
}
}
});
frame.addChild(b);
//Pen brush selector button
PImage penIcon = pa.loadImage(imagesPath + "pen.png");
final MTImageButton penButton = new MTImageButton(penIcon, pa);
frame.addChild(penButton);
penButton.translate(new Vector3D(-50f, 65,0));
penButton.setNoStroke(true);
penButton.setStrokeColor(new MTColor(0,0,0));
//Texture brush selector button
PImage brushIcon = pa.loadImage(imagesPath + "paintbrush.png");
final MTImageButton brushButton = new MTImageButton(brushIcon, pa);
frame.addChild(brushButton);
brushButton.translate(new Vector3D(-50f, 130,0));
brushButton.setStrokeColor(new MTColor(0,0,0));
brushButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
switch (ae.getID()) {
case TapEvent.BUTTON_CLICKED:{
drawingScene.setBrush(textureBrush);
brushButton.setNoStroke(false);
penButton.setNoStroke(true);
}break;
default:
break;
}
}
});
penButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
switch (ae.getID()) {
case TapEvent.BUTTON_CLICKED:{
drawingScene.setBrush(pencilBrush);
penButton.setNoStroke(false);
brushButton.setNoStroke(true);
}break;
default:
break;
}
}
});
//Save to file button
PImage floppyIcon = pa.loadImage(imagesPath + "floppy.png");
final MTImageButton floppyButton = new MTImageButton(floppyIcon, pa);
frame.addChild(floppyButton);
floppyButton.translate(new Vector3D(-50f, 260,0));
floppyButton.setNoStroke(true);
floppyButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
switch (ae.getID()) {
case TapEvent.BUTTON_CLICKED:{
// pa.invokeLater(new Runnable() {
// public void run() {
// drawingScene.getCanvas().drawAndUpdateCanvas(pa.g, 0);
// pa.saveFrame();
// clear(pa.g);
// }
// });
drawingScene.registerPreDrawAction(new IPreDrawAction() {
public void processAction() {
//drawingScene.getCanvas().drawAndUpdateCanvas(pa.g, 0);
pa.saveFrame();
}
public boolean isLoop() {
return false;
}
});
}break;
default:
break;
}
}
});
/////////////////////////
//ColorPicker and colorpicker button
PImage colPick = pa.loadImage(imagesPath + "colorcircle.png");
// final MTColorPicker colorWidget = new MTColorPicker(0, pa.height-colPick.height, colPick, pa);
final MTColorPicker colorWidget = new MTColorPicker(0, 0, colPick, pa);
colorWidget.translate(new Vector3D(0f, 135,0));
colorWidget.setStrokeColor(new MTColor(0,0,0));
colorWidget.addGestureListener(DragProcessor.class, new IGestureEventListener() {
public boolean processGestureEvent(MTGestureEvent ge) {
if (ge.getId()== MTGestureEvent.GESTURE_ENDED){
if (colorWidget.isVisible()){
colorWidget.setVisible(false);
}
}else{
drawingScene.setBrushColor(colorWidget.getSelectedColor());
}
return false;
}
});
frame.addChild(colorWidget);
colorWidget.setVisible(false);
PImage colPickIcon = pa.loadImage(imagesPath + "ColorPickerIcon.png");
MTImageButton colPickButton = new MTImageButton(colPickIcon, pa);
frame.addChild(colPickButton);
colPickButton.translate(new Vector3D(-50f, 195,0));
colPickButton.setNoStroke(true);
colPickButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
switch (ae.getID()) {
case TapEvent.BUTTON_CLICKED:{
if (colorWidget.isVisible()){
colorWidget.setVisible(false);