error "processing.xml"
in
Contributed Library Questions
•
1 year ago
Hi,
I have installed processing 2.0 beta1.
I have copied the toxiclibs library and I get an error:
The package"processing.xml" does not exist. You might be missing a library.
I attached, the sript...
Thanks.
There are two class --> Ball, Shapes
I have installed processing 2.0 beta1.
I have copied the toxiclibs library and I get an error:
The package"processing.xml" does not exist. You might be missing a library.
I attached, the sript...
Thanks.
There are two class --> Ball, Shapes
- import toxi.geom.*;
import toxi.color.*;
float MAX_SPEED;
float GRAVITY = 0.3;
float RESTITUTION = 0.05;
float JITTER = 0.2;
float MAX_SPEED = 40;
List<Ball> balls = new ArrayList<Ball>();
void setup() {
size(680, 382);
ellipseMode(RADIUS);
rectMode(RADIUS);
initBalls();
}
void draw() {
background(224);
noStroke();
for(int i=0; i<balls.size(); i++){
balls.get(i).update();
balss.get(i).draw();
}
}
void initBalls() {
float rnd=random(1);
if(rnd<0.33){
balls.add(new Dot());
}else if (rnd<0.66){
balls.add(new Square());
} else{
balls.add(new Heart());
}
}
void keyPressed(){
if(key=='r'){
initBalls();
}
if(key=='x' && balls.size()>0){
balls.remove(0);
}
} - abstract class Ball {
Vec2D pos;
Vec2D vel;
float radius;
TColor col;
Ball() {
pos = new Vec2D(random(0.25,0.75)*width, random(0.25,0.75)*height);
vel = Vec2D.randomVector().scale(random(MAX_SPEED));
radius = random(0.25,1)*MAX_RADIUS;
col=TColor.newRandom();
}
void update(){
vel.y+=GRAVITY;
pos.addSelf(vel);
if(pos.x<radius){
pos.x=radius;
vel.x*=-1;
}else if (pos.x>=width-radius-1){
pos.x=width-radius-1;
vel.x*=-1;
}
if (pos.y<radius){
pos.y=radius;
vel.y*=-1;
}else if(pos.y>height-radius-1){
pos.y=height-radius-1;
vel.scaleSelf(1-RESTITUTION,-(1-RESTITUTION));
vel.x*=1+random(-1,1)*JITTER;
}
}
abstract void draw();
} - class Dot extends Ball{
void draw(){
fill(col.toARG());
ellipse(pos.x,pos.y,radius,radius);
}
}
class Square extends Ball {
void draw(){
fill(col.toARGB());
rect(pos.x,pos.y,radius,radius);
}
}
class Heart extends Ball {
Heart(){
super();
col=TColor.RED.getAnalog(20,0.5);
}
void draw(){
Spline2D s = new Spline2D();
s.add(new Vec2D (0,-0.5));
s.add(new Vec2D (-0.5,-1));
s.add(new Vec2D (-1,-0.5));
s.add(new Vec2D (-0.35,0.35));
s.add(new Vec2D (0,1));
List<Vec2D>points=s.computeVertices(8);
pushMatrix();
translate(pos.x,pos.y);
scale(radius);
fill(col.toARGB());
beginShape();
for(int i=0; i<points.size();i++){
Vec2D p = points.get(i);
vertex(p.x,p.y);
}
for(int i = points.size()-1; i>=0; i=i-1){
Vec2D p = points.get(i);
vertex(-p.x,p.y);
}
endShape();
popMatrix();
}
}
1