Skip to content
Permalink
e80136c70b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
49 lines (40 sloc) 1.1 KB
class Point {
float _r = i_pointRad;
float _x;
float _y;
boolean _isSelected;
Point(float x0, float y0) {
_x = x0;
_y = y0;
_isSelected = false;
}
void draw() {
pushStyle();
stroke(c_pointStroke);
fill((_isSelected) ? c_pointSelect : c_pointDefault);
ellipse(_x, _y, i_pointRad, i_pointRad);
popStyle();
}
boolean isSelectedPoint(float x, float y) {
return (x - _x)*(x - _x) + (y - _y) * (y - _y) < _r * _r;
}
boolean isSelectedCir(float x, float y, float r) {
return (x - _x)*(x - _x) + (y - _y)*(y - _y) < r * r;
}
boolean isSelectedRect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
int l0 = lineSideTest(x1, y1, x2, y2, _x, _y);
int l1 = lineSideTest(x2, y2, x3, y3, _x, _y);
int l2 = lineSideTest(x3, y3, x4, y4, _x, _y);
int l3 = lineSideTest(x4, y4, x1, y1, _x, _y);
return (l0 == l1) && (l1 == l2) && (l2 == l3);
}
void setSelected() {
_isSelected = true;
}
void setUnSelected() {
_isSelected = false;
}
void toggleSelected() {
_isSelected = !_isSelected;
}
}