Proxml problem
in
Contributed Library Questions
•
1 year ago
Hi,
I am trying to using Proxml, but it doesn't look it's working.
Because funnel library and arduino library doesn't work properly in the latest version of processing, I use the previous version of processing which is 1.5.1. It works fine by now.
However, Proxml doesn't work in the previous version. It works fine in the latest version which is 2.0b3.
Is there any way to use arduino, funnel and proxml libraries in the same processing version?
I read some question about proxml and one of the suggestions was prefixing proxml.
For example, XMLElement -> proxml.XMLElement
I changed it but it still doesn't work.
I keep getting the msg "Cannot find a class or type named "XMLElement""
The line "XMLElement ellipses;" is highlighted.
Help me~!!
This is the code copied from Proxml homepage
import proxml.*;
//to store the background after painting an ellipse
PImage back;
//xml element to store and load the drawn ellipses
XMLElement ellipses;
XMLInOut xmlInOut;
int xPos = 0;
int yPos = 0;
void setup(){
size(400,400);
smooth();
background(255);
//load ellipses from file if it exists
xmlInOut = new XMLInOut(this);
try{
xmlInOut.loadElement("ellipse.xml");
}catch(Exception e){
//if the xml file could not be loaded it has to be created
xmlEvent(new XMLElement("ellipses"));
}
}
void xmlEvent(XMLElement element){
ellipses = element;
initEllipses();
//initialise PImage for background
back = new PImage(width,height);
loadPixels();
back.pixels = pixels;
}
void draw(){
}
//draw all ellipses saved in the xml file
void initEllipses(){
ellipses.printElementTree(" ");
XMLElement ellipse;
XMLElement position;
XMLElement size;
for(int i = 0; i < ellipses.countChildren();i++){
ellipse = ellipses.getChild(i);
position = ellipse.getChild(0);
size = ellipse.getChild(1);
ellipse(
position.getIntAttribute("xPos"),
position.getIntAttribute("yPos"),
size.getFloatAttribute("Xsize"),
size.getFloatAttribute("Ysize")
);
}
}
void mousePressed(){
xPos = mouseX;
yPos = mouseY;
}
void mouseDragged(){
background(back);
ellipse(xPos,yPos,abs(xPos-mouseX),abs(yPos-mouseY));
}
void mouseReleased(){
XMLElement ellipse = new XMLElement("ellipse");
ellipses.addChild(ellipse);
XMLElement position = new XMLElement("position");
position.addAttribute("xPos",xPos);
position.addAttribute("yPos",yPos);
ellipse.addChild(position);
XMLElement size = new XMLElement("size");
size.addAttribute("Xsize",abs(xPos-mouseX));
size.addAttribute("Ysize",abs(yPos-mouseY));
ellipse.addChild(size);
xmlInOut.saveElement(ellipses,"ellipse.xml");
loadPixels();
back.pixels = pixels;
}
1