Java Code Examples for android.graphics.Path#rQuadTo()

The following examples show how to use android.graphics.Path#rQuadTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageLoader.java    From a with GNU General Public License v3.0 6 votes vote down vote up
private Path getActionPath(float curPercent) {
    final Path path = new Path();
    int x = -mDisplayWidth;
    x += curPercent * mDisplayWidth;
    path.moveTo(x, mDisplayHeight / 2);
    // 计算控制点
    int quadWidth = mDisplayWidth / 4;
    int quadHeight = mDisplayHeight / 20 * 3;
    // 第一个周期
    path.rQuadTo(quadWidth, quadHeight, quadWidth * 2, 0);
    path.rQuadTo(quadWidth, -quadHeight, quadWidth * 2, 0);
    // 第二个周期
    path.rQuadTo(quadWidth, quadHeight, quadWidth * 2, 0);
    path.rQuadTo(quadWidth, -quadHeight, quadWidth * 2, 0);

    // 右侧的直线
    path.lineTo(x + mDisplayWidth * 2, mDisplayHeight);
    path.lineTo(x, mDisplayHeight);
    path.close();
    return path;
}
 
Example 2
Source File: PageView.java    From a with GNU General Public License v3.0 6 votes vote down vote up
private Path getActionPath(float curPercent) {
    final Path path = new Path();
    int x = -mViewWidth;
    x += curPercent * mViewWidth;
    path.moveTo(x, mViewHeight / 2);
    // 计算控制点
    int quadWidth = mViewWidth / 4;
    int quadHeight = mViewHeight / 20 * 3;
    // 第一个周期
    path.rQuadTo(quadWidth, quadHeight, quadWidth * 2, 0);
    path.rQuadTo(quadWidth, -quadHeight, quadWidth * 2, 0);
    // 第二个周期
    path.rQuadTo(quadWidth, quadHeight, quadWidth * 2, 0);
    path.rQuadTo(quadWidth, -quadHeight, quadWidth * 2, 0);

    // 右侧的直线
    path.lineTo(x + mViewWidth * 2, mViewHeight);
    path.lineTo(x, mViewHeight);
    path.close();
    return path;
}
 
Example 3
Source File: TapBarMenu.java    From TapBarMenu with Apache License 2.0 6 votes vote down vote up
private Path createRoundedRectPathPreApi21(Path path, float left, float top, float right, float bottom, float rx, float ry) {
  if (rx < 0) rx = 0;
  if (ry < 0) ry = 0;
  float width = right - left;
  float height = bottom - top;
  if (rx > width / 2) rx = width / 2;
  if (ry > height / 2) ry = height / 2;
  float widthMinusCorners = (width - (2 * rx));
  float heightMinusCorners = (height - (2 * ry));
  path.moveTo(right, top + ry);
  path.rQuadTo(0, -ry, -rx, -ry);
  path.rLineTo(-widthMinusCorners, 0);
  path.rQuadTo(-rx, 0, -rx, ry);
  path.rLineTo(0, heightMinusCorners);
  path.rQuadTo(0, ry, rx, ry);
  path.rLineTo(widthMinusCorners, 0);
  path.rQuadTo(rx, 0, rx, -ry);
  path.rLineTo(0, -heightMinusCorners);
  path.close();
  return path;
}
 
Example 4
Source File: BitmapEditor.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
static public Path RoundedRect(float left, float top, float right, float bottom, float rx, float ry, boolean conformToOriginalPost) {
    Path path = new Path();
    if (rx < 0) rx = 0;
    if (ry < 0) ry = 0;
    float width = right - left;
    float height = bottom - top;
    if (rx > width/2) rx = width/2;
    if (ry > height/2) ry = height/2;
    float widthMinusCorners = (width - (2 * rx)); // do dai phan "thang" cua chieu rong
    float heightMinusCorners = (height - (2 * ry)); // do dai phan "thang" cua chieu dai

    path.moveTo(right, top + ry);  // bat dau tu  day
    path.rQuadTo(0, -ry, -rx, -ry);//y-right corner
    path.rLineTo(-widthMinusCorners, 0);
    path.rQuadTo(-rx, 0, -rx, ry); //y-x corner
    path.rLineTo(0, heightMinusCorners);

    if (conformToOriginalPost) {
        path.rLineTo(0, ry);
        path.rLineTo(width, 0);
        path.rLineTo(0, -ry);
    }
    else {

        path.rQuadTo(0, ry, rx, ry);//bottom-x corner
        path.rLineTo(widthMinusCorners, 0);
        path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner
    }

    path.rLineTo(0, -heightMinusCorners);

    path.close();//Given close, last lineto can be removed.

    return path;
}
 
Example 5
Source File: TextSelectionHint.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void roundedRect(Path path, float left, float top, float right, float bottom, float rx, float ry,
                         boolean tl, boolean tr) {
    path.reset();
    if (rx < 0) rx = 0;
    if (ry < 0) ry = 0;
    float width = right - left;
    float height = bottom - top;
    if (rx > width / 2) rx = width / 2;
    if (ry > height / 2) ry = height / 2;
    float widthMinusCorners = (width - (2 * rx));
    float heightMinusCorners = (height - (2 * ry));

    path.moveTo(right, top + ry);
    if (tr)
        path.rQuadTo(0, -ry, -rx, -ry);
    else {
        path.rLineTo(0, -ry);
        path.rLineTo(-rx, 0);
    }
    path.rLineTo(-widthMinusCorners, 0);
    if (tl)
        path.rQuadTo(-rx, 0, -rx, ry);
    else {
        path.rLineTo(-rx, 0);
        path.rLineTo(0, ry);
    }
    path.rLineTo(0, heightMinusCorners);
    path.rLineTo(0, ry);
    path.rLineTo(rx, 0);
    path.rLineTo(widthMinusCorners, 0);
    path.rLineTo(rx, 0);
    path.rLineTo(0, -ry);
    path.rLineTo(0, -heightMinusCorners);
    path.close();
}
 
Example 6
Source File: TextSelectionHint.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void roundedRect(Path path, float left, float top, float right, float bottom, float rx, float ry,
                         boolean tl, boolean tr) {
    path.reset();
    if (rx < 0) rx = 0;
    if (ry < 0) ry = 0;
    float width = right - left;
    float height = bottom - top;
    if (rx > width / 2) rx = width / 2;
    if (ry > height / 2) ry = height / 2;
    float widthMinusCorners = (width - (2 * rx));
    float heightMinusCorners = (height - (2 * ry));

    path.moveTo(right, top + ry);
    if (tr)
        path.rQuadTo(0, -ry, -rx, -ry);
    else {
        path.rLineTo(0, -ry);
        path.rLineTo(-rx, 0);
    }
    path.rLineTo(-widthMinusCorners, 0);
    if (tl)
        path.rQuadTo(-rx, 0, -rx, ry);
    else {
        path.rLineTo(-rx, 0);
        path.rLineTo(0, ry);
    }
    path.rLineTo(0, heightMinusCorners);
    path.rLineTo(0, ry);
    path.rLineTo(rx, 0);
    path.rLineTo(widthMinusCorners, 0);
    path.rLineTo(rx, 0);
    path.rLineTo(0, -ry);
    path.rLineTo(0, -heightMinusCorners);
    path.close();
}
 
Example 7
Source File: SVGAPath.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
private void operate(Path finalPath, String method, StringTokenizer args) {
    float x0 = 0.0f;
    float y0 = 0.0f;
    float x1 = 0.0f;
    float y1 = 0.0f;
    float x2 = 0.0f;
    float y2 = 0.0f;
    try {
        int index = 0;
        while (args.hasMoreTokens()) {
            String s = args.nextToken();
            if (TextUtils.isEmpty(s)) {
                continue;
            }
            if (index == 0) {
                x0 = Float.valueOf(s);
            }
            if (index == 1) {
                y0 = Float.valueOf(s);
            }
            if (index == 2) {
                x1 = Float.valueOf(s);
            }
            if (index == 3) {
                y1 = Float.valueOf(s);
            }
            if (index == 4) {
                x2 = Float.valueOf(s);
            }
            if (index == 5) {
                y2 = Float.valueOf(s);
            }
            index++;
        }
    } catch (Exception e) {
    }
    SVGAPoint currentPoint = new SVGAPoint(0.0f, 0.0f, 0.0f);
    if ("M".equals(method)) {
        finalPath.moveTo(x0, y0);
        currentPoint = new SVGAPoint(x0, y0, 0.0f);
    } else if ("m".equals(method)) {
        finalPath.rMoveTo(x0, y0);
        currentPoint = new SVGAPoint(currentPoint.x + x0, currentPoint.y + y0, 0.0f);
    }
    if ("L".equals(method)) {
        finalPath.lineTo(x0, y0);
    } else if ("l".equals(method)) {
        finalPath.rLineTo(x0, y0);
    }
    if ("C".equals(method)) {
        finalPath.cubicTo(x0, y0, x1, y1, x2, y2);
    } else if ("c".equals(method)) {
        finalPath.rCubicTo(x0, y0, x1, y1, x2, y2);
    }
    if ("Q".equals(method)) {
        finalPath.quadTo(x0, y0, x1, y1);
    } else if ("q".equals(method)) {
        finalPath.rQuadTo(x0, y0, x1, y1);
    }
    if ("H".equals(method)) {
        finalPath.lineTo(x0, currentPoint.y);
    } else if ("h".equals(method)) {
        finalPath.rLineTo(x0, 0f);
    }
    if ("V".equals(method)) {
        finalPath.lineTo(currentPoint.x, x0);
    } else if ("v".equals(method)) {
        finalPath.rLineTo(0f, x0);
    }
    if ("Z".equals(method)) {
        finalPath.close();
    } else if ("z".equals(method)) {
        finalPath.close();
    }

}
 
Example 8
Source File: ShapeUtils.java    From YCCardView with Apache License 2.0 4 votes vote down vote up
static Path roundedRect(float left, float top, float right, float bottom,
                        float rx, float ry, boolean tl, boolean tr, boolean br, boolean bl) {
    Path path = new Path();
    if (rx < 0) {
        rx = 0f;
    }
    if (ry < 0) {
        ry = 0f;
    }
    float width = right - left;
    float height = bottom - top;
    if (rx > width / 2) {
        rx = width / 2;
    }
    if (ry > height / 2) {
        ry = height / 2;
    }
    float widthMinusCorners = width - 2 * rx;
    float heightMinusCorners = height - 2 * ry;

    path.moveTo(right, top + ry);
    if (tr) {
        path.rQuadTo(0f, -ry, -rx, -ry);//top-right corner
    } else {
        path.rLineTo(0f, -ry);
        path.rLineTo(-rx, 0f);
    }
    path.rLineTo(-widthMinusCorners, 0f);
    if (tl) {
        path.rQuadTo(-rx, 0f, -rx, ry); //top-left corner
    } else {
        path.rLineTo(-rx, 0f);
        path.rLineTo(0f, ry);
    }
    path.rLineTo(0f, heightMinusCorners);

    if (bl) {
        path.rQuadTo(0f, ry, rx, ry);//bottom-left corner
    } else {
        path.rLineTo(0f, ry);
        path.rLineTo(rx, 0f);
    }

    path.rLineTo(widthMinusCorners, 0f);
    if (br) {
        path.rQuadTo(rx, 0f, rx, -ry); //bottom-right corner
    } else {
        path.rLineTo(rx, 0f);
        path.rLineTo(0f, -ry);
    }

    path.rLineTo(0f, -heightMinusCorners);

    path.close();//Given close, last lineto can be removed.

    return path;
}
 
Example 9
Source File: ShapeUtils.java    From YCCardView with Apache License 2.0 4 votes vote down vote up
static Path roundedRect(float left, float top, float right, float bottom,
                        float tl, float tr, float br, float bl) {
    Path path = new Path();
    if (tl < 0) {
        tl = 0f;
    }
    if (tr < 0) {
        tr = 0f;
    }
    if (br < 0) {
        br = 0f;
    }
    if (bl < 0) {
        bl = 0f;
    }
    float width = right - left;
    float height = bottom - top;
    float min = Math.min(width, height);
    if (tl > min / 2) {
        tl = min / 2;
    }
    if (tr > min / 2) {
        tr = min / 2;
    }
    if (br > min / 2) {
        br = min / 2;
    }
    if (bl > min / 2) {
        bl = min / 2;
    }
    if (tl == tr && tr == br && br == bl && tl == min / 2) {
        float radius = min / 2F;
        path.addCircle(left + radius, top + radius, radius, Path.Direction.CW);
        return path;
    }

    path.moveTo(right, top + tr);
    if (tr > 0) {
        path.rQuadTo(0f, -tr, -tr, -tr);//top-right corner
    } else {
        path.rLineTo(0f, -tr);
        path.rLineTo(-tr, 0f);
    }
    path.rLineTo(-(width - tr - tl), 0f);
    if (tl > 0) {
        path.rQuadTo(-tl, 0f, -tl, tl); //top-left corner
    } else {
        path.rLineTo(-tl, 0f);
        path.rLineTo(0f, tl);
    }
    path.rLineTo(0f, height - tl - bl);

    if (bl > 0) {
        path.rQuadTo(0f, bl, bl, bl);//bottom-left corner
    } else {
        path.rLineTo(0f, bl);
        path.rLineTo(bl, 0f);
    }

    path.rLineTo(width - bl - br, 0f);
    if (br > 0) {
        path.rQuadTo(br, 0f, br, -br); //bottom-right corner
    } else {
        path.rLineTo(br, 0f);
        path.rLineTo(0f, -br);
    }

    path.rLineTo(0f, -(height - br - tr));

    path.close();//Given close, last lineto can be removed.

    return path;
}
 
Example 10
Source File: BaseChartView.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static Path RoundedRect(
        Path path,
        float left, float top, float right, float bottom, float rx, float ry,
        boolean tl, boolean tr, boolean br, boolean bl
) {
    path.reset();
    if (rx < 0) rx = 0;
    if (ry < 0) ry = 0;
    float width = right - left;
    float height = bottom - top;
    if (rx > width / 2) rx = width / 2;
    if (ry > height / 2) ry = height / 2;
    float widthMinusCorners = (width - (2 * rx));
    float heightMinusCorners = (height - (2 * ry));

    path.moveTo(right, top + ry);
    if (tr)
        path.rQuadTo(0, -ry, -rx, -ry);
    else {
        path.rLineTo(0, -ry);
        path.rLineTo(-rx, 0);
    }
    path.rLineTo(-widthMinusCorners, 0);
    if (tl)
        path.rQuadTo(-rx, 0, -rx, ry);
    else {
        path.rLineTo(-rx, 0);
        path.rLineTo(0, ry);
    }
    path.rLineTo(0, heightMinusCorners);

    if (bl)
        path.rQuadTo(0, ry, rx, ry);
    else {
        path.rLineTo(0, ry);
        path.rLineTo(rx, 0);
    }

    path.rLineTo(widthMinusCorners, 0);
    if (br)
        path.rQuadTo(rx, 0, rx, -ry);
    else {
        path.rLineTo(rx, 0);
        path.rLineTo(0, -ry);
    }

    path.rLineTo(0, -heightMinusCorners);

    path.close();
    return path;
}
 
Example 11
Source File: BaseChartView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static Path RoundedRect(
        Path path,
        float left, float top, float right, float bottom, float rx, float ry,
        boolean tl, boolean tr, boolean br, boolean bl
) {
    path.reset();
    if (rx < 0) rx = 0;
    if (ry < 0) ry = 0;
    float width = right - left;
    float height = bottom - top;
    if (rx > width / 2) rx = width / 2;
    if (ry > height / 2) ry = height / 2;
    float widthMinusCorners = (width - (2 * rx));
    float heightMinusCorners = (height - (2 * ry));

    path.moveTo(right, top + ry);
    if (tr)
        path.rQuadTo(0, -ry, -rx, -ry);
    else {
        path.rLineTo(0, -ry);
        path.rLineTo(-rx, 0);
    }
    path.rLineTo(-widthMinusCorners, 0);
    if (tl)
        path.rQuadTo(-rx, 0, -rx, ry);
    else {
        path.rLineTo(-rx, 0);
        path.rLineTo(0, ry);
    }
    path.rLineTo(0, heightMinusCorners);

    if (bl)
        path.rQuadTo(0, ry, rx, ry);
    else {
        path.rLineTo(0, ry);
        path.rLineTo(rx, 0);
    }

    path.rLineTo(widthMinusCorners, 0);
    if (br)
        path.rQuadTo(rx, 0, rx, -ry);
    else {
        path.rLineTo(rx, 0);
        path.rLineTo(0, -ry);
    }

    path.rLineTo(0, -heightMinusCorners);

    path.close();
    return path;
}