当前位置: 首页>>代码示例>>Java>>正文


Java Path类代码示例

本文整理汇总了Java中android.graphics.Path的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Path类属于android.graphics包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rotatedOval

import android.graphics.Path; //导入依赖的package包/类
private Bitmap rotatedOval(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    canvas.drawPath(oval, paint);

    return bmp;
}
 
开发者ID:StylingAndroid,项目名称:PresenterLite,代码行数:25,代码来源:ShapedImageView.java

示例2: drawWind

import android.graphics.Path; //导入依赖的package包/类
private void drawWind(Canvas canvas) {
    mWindPath = new Path();
    canvas.drawCircle(mCenterPoint.x,mCenterPoint.y,width/40,mWindmillPaint);
    mWindPath.moveTo(x1,y1);
    x2 = mCenterPoint.x + (float) (r1 * Math.cos(rad1 + angle));
    y2 = mCenterPoint.y + (float) (r1 * Math.sin(rad1 + angle));
    x3 = mCenterPoint.x + (float) (r2 * Math.cos(rad2 + angle));
    y3 = mCenterPoint.y + (float) (r2 * Math.sin(rad2 + angle));
    x4 = mCenterPoint.x + (float) (r3 * Math.cos(rad3 + angle));
    y4 = mCenterPoint.y + (float) (r3 * Math.sin(rad3 + angle));
    x5 = mCenterPoint.x + (float) (r4 * Math.cos(rad4 + angle));
    y5 = mCenterPoint.y + (float) (r4 * Math.sin(rad4 + angle));


    mWindPath.cubicTo(x2,y2,x3,y3,x4,y4);
    mWindPath.quadTo(x5,y5,x1,y1);
    mWindPath.close();
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
}
 
开发者ID:YugengWang,项目名称:OneWeather,代码行数:25,代码来源:Windmill.java

示例3: TrailedShape

import android.graphics.Path; //导入依赖的package包/类
TrailedShape(float multiplier) {
    this.mMultiplier = multiplier;

    // Setup trail variables
    this.mTrailPath = new Path();
    this.mTrailList = new LinkedList<>();

    // Setup paint and attributes
    this.mPaint = new Paint();
    this.mTrailPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);
    mTrailPaint.setStyle(Paint.Style.STROKE);
    mTrailPaint.setStrokeWidth(5);
    mTrailPaint.setStrokeJoin(Paint.Join.ROUND);
    mTrailPaint.setStrokeCap(Paint.Cap.ROUND);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:18,代码来源:TrailedShape.java

示例4: drawCloud

import android.graphics.Path; //导入依赖的package包/类
private void drawCloud(Canvas canvas) {
    mPath.reset();
    mPaint.setShader(mCloudLinearGradient);
    if (mCircleInfoBottomOne.isCanDraw())
        mPath.addCircle(mCircleInfoBottomOne.getX(),mCircleInfoBottomOne.getY(),mCircleInfoBottomOne.getRadius(), Path.Direction.CW);//左下1
    if (mCircleInfoBottomTwo.isCanDraw())
        mPath.addCircle(mCircleInfoBottomTwo.getX(),mCircleInfoBottomTwo.getY(),mCircleInfoBottomTwo.getRadius(), Path.Direction.CW);//底部2
    if (mCircleInfoBottomThree.isCanDraw())
        mPath.addCircle(mCircleInfoBottomThree.getX(),mCircleInfoBottomThree.getY(),mCircleInfoBottomThree.getRadius(), Path.Direction.CW);//底3
    if (mCircleInfoTopOne.isCanDraw())
        mPath.addCircle(mCircleInfoTopOne.getX(),mCircleInfoTopOne.getY(),mCircleInfoTopOne.getRadius(), Path.Direction.CW);//顶1
    if (mCircleInfoTopTwo.isCanDraw())
        mPath.addCircle(mCircleInfoTopTwo.getX(),mCircleInfoTopTwo.getY(),mCircleInfoTopTwo.getRadius(), Path.Direction.CW);//顶2
    canvas.save();
    canvas.clipRect(0,0,getMeasuredWidth(),getMeasuredHeight()/2+getMeasuredWidth()/7f);
    canvas.drawPath(mPath,mPaint);
    canvas.restore();
    mPaint.setShader(null);
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:20,代码来源:WeatherView.java

示例5: init

import android.graphics.Path; //导入依赖的package包/类
private void init(Context context) {
    mTextPaint = new Paint();
    mPaint = new Paint();
    mPath = new Path();
    startPoint = new Point(200, 200);
    endPoint = new Point(800, 800);
    assistPoint = new Point(800, 200);
    // 抗锯齿
    mPaint.setAntiAlias(true);
    // 防抖动
    mPaint.setDither(true);
    //坐标
    mTextPaint.setColor(Color.RED);
    mTextPaint.setTextSize(20);
    mTextPaint.setStrokeWidth(10);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setDither(true);
}
 
开发者ID:flyou,项目名称:PropertyAnimatorDemo,代码行数:19,代码来源:MyBezierView.java

示例6: drawPolygon

import android.graphics.Path; //导入依赖的package包/类
/**
 * 绘制正多边形
 */
private void drawPolygon(Canvas canvas){
    Path path = new Path();
    float r = radius/(count-1);
    for(int i=1;i<count;i++){
        float curR = r*i;
        path.reset();
        for(int j=0;j<count;j++){
            if(j==0){
                path.moveTo(centerX+curR,centerY);
            }else{
                float x = (float) (centerX+curR*Math.cos(angle*j));
                float y = (float) (centerY+curR*Math.sin(angle*j));
                path.lineTo(x,y);
            }
        }
        path.close();
        canvas.drawPath(path, mainPaint);
    }
}
 
开发者ID:lixiaodaoaaa,项目名称:ColumnAnimViewProject,代码行数:23,代码来源:RadarView.java

示例7: onDraw

import android.graphics.Path; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (canvas == null) return;

    mPath.reset();

    mPath.addCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, Path.Direction.CW);
    mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);

    canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, mTransparentPaint);

    canvas.drawPath(mPath, mSemiBlackPaint);
    canvas.clipPath(mPath);
    canvas.drawColor(Color.parseColor("#A6000000"));
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:18,代码来源:CameraView.java

示例8: initPaintObjects

import android.graphics.Path; //导入依赖的package包/类
private void initPaintObjects() {

        int labelTextSize = getResources().getDimensionPixelSize(R.dimen.label_text_size);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(labelTextSize);
        if (typeface != null) {
            textPaint.setTypeface(typeface);
        }
        textPaint.setColor(baseColor);
        baseAlpha = textPaint.getAlpha();

        selectorPath = new Path();
        selectorPath.setFillType(Path.FillType.EVEN_ODD);

        selectorPoints = new Point[3];
        for (int i = 0; i < 3; i++) {
            selectorPoints[i] = new Point();
        }
    }
 
开发者ID:hamsaadev,项目名称:RTLMaterialSpinner,代码行数:23,代码来源:RtlMaterialSpinner.java

示例9: newInstance

import android.graphics.Path; //导入依赖的package包/类
static ShapeFill newInstance(JSONObject json, LottieComposition composition) {
  AnimatableColorValue color = null;
  boolean fillEnabled;
  AnimatableIntegerValue opacity = null;

  JSONObject jsonColor = json.optJSONObject("c");
  if (jsonColor != null) {
    color = AnimatableColorValue.Factory.newInstance(jsonColor, composition);
  }

  JSONObject jsonOpacity = json.optJSONObject("o");
  if (jsonOpacity != null) {
    opacity = AnimatableIntegerValue.Factory.newInstance(jsonOpacity, composition);
  }
  fillEnabled = json.optBoolean("fillEnabled");

  int fillTypeInt = json.optInt("r", 1);
  Path.FillType fillType = fillTypeInt == 1 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD;

  return new ShapeFill(fillEnabled, fillType, color, opacity);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:ShapeFill.java

示例10: createArcPath

import android.graphics.Path; //导入依赖的package包/类
protected Path createArcPath(View view, float endX, float endY, float radius){
    Path arcPath=new Path();
    float startX=view.getTranslationX();
    float startY=view.getTranslationY();
    float midX = startX + ((endX - startX) / 2);
    float midY = startY + ((endY - startY) / 2);
    float xDiff = midX - startX;
    float yDiff = midY - startY;

    double angle = (Math.atan2(yDiff, xDiff) * (180 / Math.PI)) - 90;
    double angleRadians = Math.toRadians(angle);

    float pointX = (float) (midX + radius * Math.cos(angleRadians));
    float pointY = (float) (midY + radius * Math.sin(angleRadians));

    arcPath.moveTo(startX, startY);
    arcPath.cubicTo(startX,startY,pointX,pointY, endX, endY);
    return arcPath;
}
 
开发者ID:vpaliyX,项目名称:Material-Motion,代码行数:20,代码来源:BaseFragment.java

示例11: setPos

import android.graphics.Path; //导入依赖的package包/类
/**
 * 用来给每一个button设置一个中心点
 *
 * @param orbit 一个特定角度的path
 */
private void setPos(Path orbit) {
    PathMeasure measure = new PathMeasure(orbit, false);
    TextLableView tv;
    for (int i = 0; i < mButtons.size(); i++) {
        PopupButton pp = mButtons.get(i);
        tv = kvs.get(pp);
        float[] coords = new float[]{0f, 0f};
        int length = (int) ((i) * measure.getLength() / mButtons.size());
        measure.getPosTan(length, coords, null);
        int px = (int) coords[0] - pp.getMeasuredWidth() / 2;
        int py = (int) coords[1] - pp.getMeasuredHeight() / 2;
        int tvx = (int) coords[0] - tv.getMeasuredWidth() / 2;
        tv.x = tvx;
        tv.y = py - 60;
        pp.x = px;
        pp.y = py;
    }
}
 
开发者ID:panshen,项目名称:PopupCircleMenu,代码行数:24,代码来源:PopupLayer.java

示例12: AnimCheckBox

import android.graphics.Path; //导入依赖的package包/类
public AnimCheckBox(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.TAG = "AnimCheckBox";
    this.mPaint = new Paint(1);
    this.mRectF = new RectF();
    this.mInnerRectF = new RectF();
    this.mPath = new Path();
    this.mSin27 = Math.sin(Math.toRadians(27.0d));
    this.mSin63 = Math.sin(Math.toRadians(63.0d));
    this.mChecked = true;
    this.mInnerCircleAlpha = 255;
    this.mStrokeWidth = 2;
    this.mDuration = 500;
    this.mStrokeColor = -16776961;
    this.mCircleColor = -1;
    this.defaultSize = 40;
    this.mClickable = true;
    init(attrs);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:AnimCheckBox.java

示例13: SimpleGraph

import android.graphics.Path; //导入依赖的package包/类
private SimpleGraph(final int color, final long maxNsecs, final float width, final float height, final float strokeWidth)
{
    this.maxNsecs = maxNsecs;
    // this.width = width;
    this.height = height;
    nsecWidth = width / maxNsecs;
    
    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
    
    pathStroke = new Path();
    pathFill = new Path();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:26,代码来源:SimpleGraph.java

示例14: updateClipPath

import android.graphics.Path; //导入依赖的package包/类
/**
 * Update the path with which we'll clip this view
 */
private void updateClipPath() {
  mPath = new Path();

  TMP_RECT.set(
      getLeft(),
      getTop(),
      getRight(),
      getBottom());

  // set the path
  mPath.addRoundRect(
      TMP_RECT,
      mClipRadius,
      mClipRadius,
      Path.Direction.CW);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:DrawView.java

示例15: drawFilledPath

import android.graphics.Path; //导入依赖的package包/类
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        int save = c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restoreToCount(save);
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:LineRadarRenderer.java


注:本文中的android.graphics.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。