From 57c252e46cc93d4bb6c11ea767ee5504bd69c613 Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 2 Mar 2014 18:15:45 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20Clip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/annimon/graphics/Clip.java | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/com/annimon/graphics/Clip.java diff --git a/src/com/annimon/graphics/Clip.java b/src/com/annimon/graphics/Clip.java new file mode 100644 index 0000000..e7a6d37 --- /dev/null +++ b/src/com/annimon/graphics/Clip.java @@ -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; + } + +}