addPath ( )源码实例Demo

android.graphics.Path#addPath ( )源码实例Demo

下面列出了android.graphics.Path#addPath ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dynamic-support   文件: DynamicPageIndicator.java
private void drawUnselected(Canvas canvas) {
    combinedUnselectedPath.rewind();

    // draw any settled, revealing or joining dots
    for (int page = 0; page < pageCount; page++) {
        int nextXIndex = page == pageCount - 1 ? page : page + 1;
        Path unselectedPath = getUnselectedPath(page,
                dotCenterX[page],
                dotCenterX[nextXIndex],
                page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                dotRevealFractions[page]);
        unselectedPath.addPath(combinedUnselectedPath);
        combinedUnselectedPath.addPath(unselectedPath);
    }
    // draw any retreating joins
    if (retreatingJoinX1 != INVALID_FRACTION) {
        Path retreatingJoinPath = getRetreatingJoinPath();
        combinedUnselectedPath.addPath(retreatingJoinPath);
    }

    canvas.drawPath(combinedUnselectedPath, unselectedPaint);
}
 
源代码2 项目: microMathematics   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.Path obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;
   if (!visible())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   Path  path = (new PathConverter(obj.d)).getPath();

   if (obj.boundingBox == null) {
      obj.boundingBox = calculatePathBounds(path);
   }
   checkForClipPath(obj);

   //path.setFillType(getClipRuleFromState());
   combinedPath.setFillType(getClipRuleFromState());
   combinedPath.addPath(path, combinedPathMatrix);
}
 
源代码3 项目: andela-crypto-app   文件: InkPageIndicator.java
private void drawUnselected(Canvas canvas) {

        combinedUnselectedPath.rewind();

        // draw any settled, revealing or joining dots
        for (int page = 0; page < pageCount; page++) {
            int nextXIndex = page == pageCount - 1 ? page : page + 1;
            Path unselectedPath = getUnselectedPath(page,
                    dotCenterX[page],
                    dotCenterX[nextXIndex],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
            unselectedPath.addPath(combinedUnselectedPath);
            combinedUnselectedPath.addPath(unselectedPath);
        }
        // draw any retreating joins
        if (retreatingJoinX1 != INVALID_FRACTION) {
            Path retreatingJoinPath = getRetreatingJoinPath();
            combinedUnselectedPath.addPath(retreatingJoinPath);
        }

        canvas.drawPath(combinedUnselectedPath, unselectedPaint);
    }
 
源代码4 项目: starcor.xul   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.Path obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;
   if (!visible())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   Path  path = (new PathConverter(obj.d)).getPath();

   if (obj.boundingBox == null) {
      obj.boundingBox = calculatePathBounds(path);
   }
   checkForClipPath(obj);

   //path.setFillType(getClipRuleFromState());
   combinedPath.setFillType(getClipRuleFromState());
   combinedPath.addPath(path, combinedPathMatrix);
}
 
源代码5 项目: ForPDA   文件: InkPageIndicator.java
private void drawUnselected(Canvas canvas) {

        combinedUnselectedPath.rewind();

        // draw any settled, revealing or joining dots
        for (int page = 0; page < pageCount; page++) {
            int nextXIndex = page == pageCount - 1 ? page : page + 1;
            Path unselectedPath = getUnselectedPath(page,
                    dotCenterX[page],
                    dotCenterX[nextXIndex],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
            unselectedPath.addPath(combinedUnselectedPath);
            combinedUnselectedPath.addPath(unselectedPath);
        }
        // draw any retreating joins
        if (retreatingJoinX1 != INVALID_FRACTION) {
            Path retreatingJoinPath = getRetreatingJoinPath();
            combinedUnselectedPath.addPath(retreatingJoinPath);
        }

        canvas.drawPath(combinedUnselectedPath, unselectedPaint);
    }
 
源代码6 项目: GeometricWeather   文件: InkPageIndicator.java
private void drawUnselected(Canvas canvas) {

        combinedUnselectedPath.rewind();

        // draw any settled, revealing or joining dots
        for (int page = 0; page < pageCount; page++) {
            int nextXIndex = page == pageCount - 1 ? page : page + 1;
            Path unselectedPath = getUnselectedPath(page,
                    dotCenterX[page],
                    dotCenterX[nextXIndex],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
            unselectedPath.addPath(combinedUnselectedPath);
            combinedUnselectedPath.addPath(unselectedPath);
        }
        // draw any retreating joins
        if (retreatingJoinX1 != INVALID_FRACTION) {
            Path retreatingJoinPath = getRetreatingJoinPath();
            combinedUnselectedPath.addPath(retreatingJoinPath);
        }

        canvas.drawPath(combinedUnselectedPath, unselectedPaint);
    }
 
源代码7 项目: InkPageIndicator   文件: InkPageIndicator.java
private void drawUnselected(Canvas canvas) {

        combinedUnselectedPath.rewind();

        // draw any settled, revealing or joining dots
        for (int page = 0; page < pageCount; page++) {
            int nextXIndex = page == pageCount - 1 ? page : page + 1;
            Path unselectedPath = getUnselectedPath(page,
                    dotCenterX[page],
                    dotCenterX[nextXIndex],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
            unselectedPath.addPath(combinedUnselectedPath);
            combinedUnselectedPath.addPath(unselectedPath);
        }
        // draw any retreating joins
        if (retreatingJoinX1 != INVALID_FRACTION) {
            Path retreatingJoinPath = getRetreatingJoinPath();
            combinedUnselectedPath.addPath(retreatingJoinPath);
        }

        canvas.drawPath(combinedUnselectedPath, unselectedPaint);
    }
 
源代码8 项目: XDroidAnimation   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.Path obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;
   if (!visible())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   Path  path = (new PathConverter(obj.d)).getPath();

   if (obj.boundingBox == null) {
      obj.boundingBox = calculatePathBounds(path);
   }
   checkForClipPath(obj);

   //path.setFillType(getClipRuleFromState());
   combinedPath.setFillType(getClipRuleFromState());
   combinedPath.addPath(path, combinedPathMatrix);
}
 
源代码9 项目: XDroidAnimation   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.GraphicsElement obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;
   if (!visible())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   Path  path;
   if (obj instanceof SVG.Rect)
      path = makePathAndBoundingBox((SVG.Rect) obj);
   else if (obj instanceof SVG.Circle)
      path = makePathAndBoundingBox((SVG.Circle) obj);
   else if (obj instanceof SVG.Ellipse)
      path = makePathAndBoundingBox((SVG.Ellipse) obj);
   else if (obj instanceof SVG.PolyLine)
      path = makePathAndBoundingBox((SVG.PolyLine) obj);
   else
      return;

   checkForClipPath(obj);

   combinedPath.setFillType(path.getFillType());
   combinedPath.addPath(path, combinedPathMatrix);
}
 
源代码10 项目: geopaparazzi   文件: ShapeWriter.java
private PathShape toShape(MultiLineString mls) {
    Path path = new Path();

    for (int i = 0; i < mls.getNumGeometries(); i++) {
        LineString lineString = (LineString) mls.getGeometryN(i);
        PathShape shape = toShape(lineString);
        path.addPath(shape.getPath());
    }
    return new PathShape(path);
}
 
源代码11 项目: dynamic-support   文件: DynamicPageIndicator2.java
private void drawUnselected(Canvas canvas) {
    combinedUnselectedPath.rewind();

    // draw any settled, revealing or joining dots
    for (int page = 0; page < pageCount; page++) {
        int nextXIndex = page == pageCount - 1 ? page : page + 1;
        Path unselectedPath;
        if (!isRTL()) {
            unselectedPath = getUnselectedPath(page,
                    dotCenterX[page],
                    dotCenterX[nextXIndex],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
        } else {
            unselectedPath = getUnselectedPath(page,
                    dotCenterX[nextXIndex],
                    dotCenterX[page],
                    page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                    dotRevealFractions[page]);
        }
        unselectedPath.addPath(combinedUnselectedPath);
        combinedUnselectedPath.addPath(unselectedPath);
    }
    // draw any retreating joins
    if (retreatingJoinX1 != INVALID_FRACTION) {
        Path retreatingJoinPath = getRetreatingJoinPath();
        combinedUnselectedPath.addPath(retreatingJoinPath);
    }

    canvas.drawPath(combinedUnselectedPath, unselectedPaint);
}
 
源代码12 项目: GLEXP-Team-onebillion   文件: UPath.java
public Path bezierPath()
{
    Path bez = new Path();
    for (USubPath sp : subPaths)
        bez.addPath(sp.bezierPath());
    return bez;
}
 
源代码13 项目: microMathematics   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.GraphicsElement obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;
   if (!visible())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   Path  path;
   if (obj instanceof SVG.Rect)
      path = makePathAndBoundingBox((SVG.Rect) obj);
   else if (obj instanceof SVG.Circle)
      path = makePathAndBoundingBox((SVG.Circle) obj);
   else if (obj instanceof SVG.Ellipse)
      path = makePathAndBoundingBox((SVG.Ellipse) obj);
   else if (obj instanceof SVG.PolyLine)
      path = makePathAndBoundingBox((SVG.PolyLine) obj);
   else
      return;

   checkForClipPath(obj);

   combinedPath.setFillType(getClipRuleFromState());
   combinedPath.addPath(path, combinedPathMatrix);
}
 
源代码14 项目: cloud-cup-android   文件: TutorialView.java
private void generatePath(){
    Path pAnimated = new Path();
    Path pNoAnimated = new Path();
    for (Arrow a : this.arrows)
        if(a.getAnimated()) pAnimated.addPath(a.getPath());
        else pNoAnimated.addPath(a.getPath());

    this.pathAnimated = pAnimated;
    this.pathNoAnimation = pNoAnimated;
}
 
源代码15 项目: starcor.xul   文件: SVGAndroidRenderer.java
private void addObjectToClip(SVG.Text obj, Path combinedPath, Matrix combinedPathMatrix)
{
   updateStyleForElement(state, obj);

   if (!display())
      return;

   if (obj.transform != null)
      combinedPathMatrix.preConcat(obj.transform);

   // Get the first coordinate pair from the lists in the x and y properties.
   float  x = (obj.x == null || obj.x.size() == 0) ? 0f : obj.x.get(0).floatValueX(this);
   float  y = (obj.y == null || obj.y.size() == 0) ? 0f : obj.y.get(0).floatValueY(this);
   float  dx = (obj.dx == null || obj.dx.size() == 0) ? 0f : obj.dx.get(0).floatValueX(this);
   float  dy = (obj.dy == null || obj.dy.size() == 0) ? 0f : obj.dy.get(0).floatValueY(this);

   // Handle text alignment
   if (state.style.textAnchor != Style.TextAnchor.Start) {
      float  textWidth = calculateTextWidth(obj);
      if (state.style.textAnchor == Style.TextAnchor.Middle) {
         x -= (textWidth / 2);
      } else {
         x -= textWidth;  // 'End' (right justify)
      }
   }

   if (obj.boundingBox == null) {
      TextBoundsCalculator  proc = new TextBoundsCalculator(x, y);
      enumerateTextSpans(obj, proc);
      obj.boundingBox = new Box(proc.bbox.left, proc.bbox.top, proc.bbox.width(), proc.bbox.height());
   }
   checkForClipPath(obj);

   Path  textAsPath = new Path();
   enumerateTextSpans(obj, new PlainTextToPath(x + dx, y + dy, textAsPath));

   combinedPath.setFillType(getClipRuleFromState());
   combinedPath.addPath(textAsPath, combinedPathMatrix);
}
 
源代码16 项目: AsteroidOSSync   文件: InkPageIndicator.java
private void drawUnselected(Canvas canvas) {
    combinedUnselectedPath.rewind();

    for (int page = 0; page < pageCount; page++) {
        int nextXIndex;

        if (page == pageCount - 1) {
            nextXIndex = page;
        } else {
            nextXIndex = page + 1;
        }

        Path unselectedPath = getUnselectedPath(page,
                dotCenterX[page],
                dotCenterX[nextXIndex],
                page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
                dotRevealFractions[page]);

        unselectedPath.addPath(combinedUnselectedPath);
        combinedUnselectedPath.addPath(unselectedPath);
    }

    if (retreatingJoinX1 != INVALID_FRACTION) {
        Path retreatingJoinPath = getRetreatingJoinPath();
        combinedUnselectedPath.addPath(retreatingJoinPath);
    }

    canvas.drawPath(combinedUnselectedPath, unselectedPaint);
}
 
源代码17 项目: Tehreer-Android   文件: Renderer.java
/**
 * Generates the path of the specified glyph.
 *
 * @param glyphId The ID of glyph whose path is generated.
 * @return The path of the glyph specified by <code>glyphId</code>.
 */
public @NonNull Path generatePath(int glyphId) {
    Path glyphPath = new Path();
    glyphPath.addPath(getGlyphPath(glyphId));

    return glyphPath;
}
 
源代码18 项目: FuckingVolumeSlider   文件: Speaker.java
void fillPath(Path path) {
    base.fillPath(path);
    path.addPath(wawes.get(0).getPath());
    path.addPath(wawes.get(1).getPath());
}
 
源代码19 项目: android_maplib   文件: GISDisplay.java
public void drawTextOnPath(
        String text,
        Path path,
        float hOffset,
        float vOffset,
        Paint paint)
{
    if (null == mMainCanvas) {
        return;
    }

    PathMeasure pm = new PathMeasure(path, false);
    Matrix matrix = new Matrix();
    Path charPath = new Path();
    Path textPath = new Path();

    float pathLength = pm.getLength();
    float coordinates[] = new float[2];
    float tangent[] = new float[2];

    int i = 0;
    float position = hOffset;

    while (i < text.length()) {
        String ch = text.substring(i, i + 1);
        float charWidth = paint.measureText(ch);

        float nextPosition = position + charWidth;
        if (nextPosition > pathLength) {
            break;
        }

        pm.getPosTan(position + charWidth / 2, coordinates, tangent);
        float rotateAngle = (float) Math.toDegrees(
                Math.atan2((double) tangent[1], (double) tangent[0]));

        charPath.reset();
        paint.getTextPath(ch, 0, ch.length(), -charWidth / 2, vOffset, charPath);
        charPath.close(); // workaround

        matrix.reset();
        matrix.postScale(1, -1, 0, 0);
        matrix.postRotate(rotateAngle, 0, 0);
        matrix.postTranslate(coordinates[0], coordinates[1]);

        textPath.addPath(charPath, matrix);

        ++i;
        position = nextPosition;
    }

    mMainCanvas.drawPath(textPath, paint);

    // for debug
    //mMainCanvas.drawTextOnPath(text, path, hOffset, vOffset, paint);
}
 
源代码20 项目: BrokenView   文件: BrokenAnimator.java
/**
 * Build the final bitmap-pieces to draw in animation
 */
private void buildPieces(){
    pieces = new Piece[pathArray.size()];
    Paint paint = new Paint();
    Matrix matrix = new Matrix();
    Canvas canvas = new Canvas();
    for(int i = 0; i < pieces.length; i++) {
        int shadow = Utils.nextInt(Utils.dp2px(2),Utils.dp2px(9));
        Path path = pathArray.get(i);
        RectF r = new RectF();
        path.computeBounds(r, true);

        Bitmap pBitmap = Utils.createBitmapSafely((int)r.width() + shadow * 2,
                (int)r.height() + shadow * 2, Bitmap.Config.ARGB_4444,1);
        if(pBitmap == null){
            pieces[i] = new Piece(-1, -1, null, shadow);
            continue;
        }
        pieces[i] = new Piece((int)r.left + mTouchPoint.x - shadow,
                (int)r.top + mTouchPoint.y - shadow, pBitmap, shadow);
        canvas.setBitmap(pieces[i].bitmap);
        BitmapShader mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        matrix.reset();
        matrix.setTranslate(-r.left - offsetX + shadow, -r.top - offsetY + shadow);
        mBitmapShader.setLocalMatrix(matrix);

        paint.reset();
        Path offsetPath = new Path();
        offsetPath.addPath(path, -r.left + shadow, -r.top + shadow);

        // Draw shadow
        paint.setStyle(Paint.Style.FILL);
        paint.setShadowLayer(shadow,0,0,0xff333333);
        canvas.drawPath(offsetPath,paint);
        paint.setShadowLayer(0,0,0,0);

        // In case the view has alpha channel
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR));
        canvas.drawPath(offsetPath,paint);
        paint.setXfermode(null);

        // Draw bitmap
        paint.setShader(mBitmapShader);
        paint.setAlpha(0xcc);
        canvas.drawPath(offsetPath, paint);
    }
    // Sort by shadow
    Arrays.sort(pieces);
}