// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.math.shape;

import com.hypixel.hytale.math.vector.Vector2d;
import java.awt.Graphics2D;

public class ViewUtil
{
    public static final int INSIDE = 0;
    public static final int LEFT = 1;
    public static final int RIGHT = 2;
    public static final int BOTTOM = 4;
    public static final int TOP = 8;
    
    private ViewUtil() {
        throw new UnsupportedOperationException();
    }
    
    private static int computeOutCode(final double x, final double y) {
        int code = 0;
        if (x < -1.0) {
            code |= 0x1;
        }
        else if (x > 1.0) {
            code |= 0x2;
        }
        if (y < -1.0) {
            code |= 0x4;
        }
        else if (y > 1.0) {
            code |= 0x8;
        }
        return code;
    }
    
    private static void CohenSutherlandLineClipAndDraw(double x0, double y0, double x1, double y1, final Graphics2D graphics2D, final double width, final double height) {
        int outcode0 = computeOutCode(x0, y0);
        int outcode2 = computeOutCode(x1, y1);
        boolean accept = false;
        while (true) {
            while ((outcode0 | outcode2) != 0x0) {
                if ((outcode0 & outcode2) != 0x0) {
                    if (accept) {
                        final Vector2d start = new Vector2d(x0, y0);
                        final Vector2d vector2d = new Vector2d(x1, y1);
                    }
                    return;
                }
                final int outcodeOut = (outcode0 != 0) ? outcode0 : outcode2;
                double x2;
                double y2;
                if ((outcodeOut & 0x8) != 0x0) {
                    x2 = x0 + (x1 - x0) * (1.0 - y0) / (y1 - y0);
                    y2 = 1.0;
                }
                else if ((outcodeOut & 0x4) != 0x0) {
                    x2 = x0 + (x1 - x0) * (-1.0 - y0) / (y1 - y0);
                    y2 = -1.0;
                }
                else if ((outcodeOut & 0x2) != 0x0) {
                    y2 = y0 + (y1 - y0) * (1.0 - x0) / (x1 - x0);
                    x2 = 1.0;
                }
                else if ((outcodeOut & 0x1) != 0x0) {
                    y2 = y0 + (y1 - y0) * (-1.0 - x0) / (x1 - x0);
                    x2 = -1.0;
                }
                else {
                    x2 = 0.0;
                    y2 = 0.0;
                }
                if (outcodeOut == outcode0) {
                    x0 = x2;
                    y0 = y2;
                    outcode0 = computeOutCode(x0, y0);
                }
                else {
                    x1 = x2;
                    y1 = y2;
                    outcode2 = computeOutCode(x1, y1);
                }
            }
            accept = true;
            continue;
        }
    }
}
