Добавлен класс Clip
This commit is contained in:
parent
d789f69c6e
commit
57c252e46c
35
src/com/annimon/graphics/Clip.java
Normal file
35
src/com/annimon/graphics/Clip.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.annimon.graphics;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Clip extends Rect {
|
||||
|
||||
public Clip(double x, double y, double width, double height) {
|
||||
super(x, y, width, height);
|
||||
}
|
||||
|
||||
public void setClip(double x, double y, double width, double height) {
|
||||
super.x = x;
|
||||
super.y = y;
|
||||
super.width = width;
|
||||
super.height = height;
|
||||
}
|
||||
|
||||
public double getXMax() {
|
||||
return x + width;
|
||||
}
|
||||
|
||||
public double getYMax() {
|
||||
return y + height;
|
||||
}
|
||||
|
||||
public int getClipCode(double x, double y) {
|
||||
int xmin = (x < super.x) ? 1 : 0;
|
||||
int xmax = (x > getXMax()) ? 1 : 0;
|
||||
int ymin = (y < super.y) ? 1 : 0;
|
||||
int ymax = (y > getYMax()) ? 1 : 0;
|
||||
return (xmin << 3) | (xmax << 2) | (ymin << 1) | ymax;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user