private void drawCircle(int[] bits, int[] circle, int x, int y, int r) {
        int d = 2*r + 1;
        int pw = getPanelWidth();
        int ph = getPanelHeight();

        int xStart = getXnull() + x - r, xCircleStart = 0;
        int yStart = getYnull() - y - r, yCircleStart = 0;

        int xStop = xStart + d, xCircleStop = d;
        int yStop = yStart + d, yCircleStop = d;

        //  boundary cases:
        int dx = 0;
        int dy = 0;

        if( xStart < 0 ){
            dx = -xStart;
            xCircleStart += dx;
        }
        if (yStart < 0 ){
            dy = -yStart;
            yCircleStart += dy;
        }
        if (xStop > pw){
            dx = xStop - pw;
            xCircleStop -= dx;
        }
        if (yStop > ph){
            dy = yStop - ph;
            yCircleStop -= dy;
        }

        for(int i = xCircleStart; i < xCircleStop; i++){
            for(int j = yCircleStart; j < yCircleStop; j++ ){
                if( circle[j*d + i] == GUIStandarts.drawColor){
                    bits[(i + xStart) + (j+ yStart)*pw] = circle[j*d + i];
                }
            }
        }
    }