java类android.graphics.Path的实例源码

ShapedImageView.java 文件源码 项目:PresenterLite 阅读 32 收藏 0 点赞 0 评论 0
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;
}
TrailedShape.java 文件源码 项目:android-dev-challenge 阅读 30 收藏 0 点赞 0 评论 0
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);
}
WeatherView.java 文件源码 项目:Aurora 阅读 29 收藏 0 点赞 0 评论 0
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);
}
MyBezierView.java 文件源码 项目:PropertyAnimatorDemo 阅读 34 收藏 0 点赞 0 评论 0
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);
}
RadarView.java 文件源码 项目:ColumnAnimViewProject 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 绘制正多边形
 */
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);
    }
}
CameraView.java 文件源码 项目:xwallet 阅读 31 收藏 0 点赞 0 评论 0
@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"));
}
RtlMaterialSpinner.java 文件源码 项目:RTLMaterialSpinner 阅读 36 收藏 0 点赞 0 评论 0
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();
        }
    }
ShapeFill.java 文件源码 项目:atlas 阅读 25 收藏 0 点赞 0 评论 0
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);
}
BaseFragment.java 文件源码 项目:Material-Motion 阅读 40 收藏 0 点赞 0 评论 0
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;
}
PopupLayer.java 文件源码 项目:PopupCircleMenu 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 用来给每一个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;
    }
}
AnimCheckBox.java 文件源码 项目:boohee_v5.6 阅读 34 收藏 0 点赞 0 评论 0
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);
}
SimpleGraph.java 文件源码 项目:open-rmbt 阅读 34 收藏 0 点赞 0 评论 0
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();
}
DrawView.java 文件源码 项目:RNLearn_Project1 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
}
LineRadarRenderer.java 文件源码 项目:GitHub 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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() + ".");
    }
}
Slidr.java 文件源码 项目:android-slidr 阅读 28 收藏 0 点赞 0 评论 0
private void drawBubblePath(Canvas canvas, float triangleCenterX, float height, float width) {
    final Path path = new Path();

    int padding = 3;
    final Rect rect = new Rect(padding, padding, (int) width - padding, (int) (height - dpToPx(BUBBLE_ARROW_HEIGHT)) - padding);

    final float roundRectHeight = (height - dpToPx(BUBBLE_ARROW_HEIGHT)) / 2;

    path.moveTo(rect.left + roundRectHeight, rect.top);
    path.lineTo(rect.right - roundRectHeight, rect.top);
    path.quadTo(rect.right, rect.top, rect.right, rect.top + roundRectHeight);
    path.lineTo(rect.right, rect.bottom - roundRectHeight);
    path.quadTo(rect.right, rect.bottom, rect.right - roundRectHeight, rect.bottom);

    path.lineTo(triangleCenterX + dpToPx(BUBBLE_ARROW_WIDTH) / 2f, height - dpToPx(BUBBLE_ARROW_HEIGHT) - padding);
    path.lineTo(triangleCenterX, height - padding);
    path.lineTo(triangleCenterX - dpToPx(BUBBLE_ARROW_WIDTH) / 2f, height - dpToPx(BUBBLE_ARROW_HEIGHT) - padding);

    path.lineTo(rect.left + roundRectHeight, rect.bottom);
    path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - roundRectHeight);
    path.lineTo(rect.left, rect.top + roundRectHeight);
    path.quadTo(rect.left, rect.top, rect.left + roundRectHeight, rect.top);
    path.close();

    canvas.drawPath(path, settings.paintBubble);
}
RoundImageView.java 文件源码 项目:MyRepository 阅读 36 收藏 0 点赞 0 评论 0
@Override
protected void onDraw(Canvas canvas) {
    Log.e("TAG", "onDraw");
    if (getDrawable() == null) {
        return;
    }
    setUpShader();

    if (type == TYPE_ROUND) {
        canvas.drawRoundRect(mRoundRect, mBorderRadius, mBorderRadius,
                mBitmapPaint);
    } else if (type == TYPE_LEFT_ROUND) {
        float[] radii = {mBorderRadius, mBorderRadius, 0f, 0f, 0f, 0f, mBorderRadius, mBorderRadius};
        Path path = new Path();
        path.addRoundRect(mRoundRect, radii, Path.Direction.CW);
        canvas.drawPath(path, mBitmapPaint);
    } else {
        canvas.drawCircle(mRadius, mRadius, mRadius, mBitmapPaint);
        // drawSomeThing(canvas);
    }
}
EasyGraphLine.java 文件源码 项目:EasyChart 阅读 43 收藏 0 点赞 0 评论 0
private void init(int selectedBgColor, float pointStrokeWidth, int pathColor, float pathWidth) {
    pointPaint = new Paint();
    pointPaint.setAntiAlias(true);
    pointPaint.setColor(pointColor);
    pointPaint.setStrokeWidth(pointStrokeWidth);
    pointPaint.setStyle(Paint.Style.STROKE);
    pathPaint = new Paint();
    pathPaint.setAntiAlias(true);
    pathPaint.setColor(pathColor);
    pathPaint.setStrokeWidth(pathWidth);
    pathPaint.setStyle(Paint.Style.STROKE);
    selectedBgPaint = new Paint();
    selectedBgPaint.setAntiAlias(true);
    selectedBgPaint.setColor(selectedBgColor);
    selectedBgPaint.setStrokeWidth(0);
    selectedBgPaint.setStyle(Paint.Style.FILL);
    selectedBgPaint.setAlpha(100);
    path = new Path();
    pathDst = new Path();
    pm = new PathMeasure();
    rectOval = new RectF();
    selectedIndex = -1;
}
MergePathsContent.java 文件源码 项目:atlas 阅读 34 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.KITKAT)
private void mergePaths() {

  switch (mergePaths.getMode()) {
    case Merge:
      supportMergePaths();
      break;
    case Add:
      opFirstPathWithRest(Path.Op.UNION);
      break;
    case Subtract:
      opFirstPathWithRest(Path.Op.REVERSE_DIFFERENCE);
      break;
    case Intersect:
      opFirstPathWithRest(Path.Op.INTERSECT);
      break;
    case ExcludeIntersections:
      opFirstPathWithRest(Path.Op.XOR);
      break;
  }
}
StaticGraph.java 文件源码 项目:open-rmbt 阅读 36 收藏 0 点赞 0 评论 0
private StaticGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;

    pathStroke = new Path();
    pathFill = new Path();
    paintStroke = new Paint();
    paintFill = 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.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
}
TrailedShape.java 文件源码 项目:android-dev-challenge 阅读 30 收藏 0 点赞 0 评论 0
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);
}
SimulationPageAnim.java 文件源码 项目:NovelReader 阅读 35 收藏 0 点赞 0 评论 0
public SimulationPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mPath0 = new Path();
    mPath1 = new Path();
    mMaxLength = (float) Math.hypot(mScreenWidth, mScreenHeight);
    mPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);

    createDrawable();

    ColorMatrix cm = new ColorMatrix();//设置颜色数组
    float array[] = { 1, 0, 0, 0, 0,
            0, 1, 0, 0, 0,
            0, 0,1, 0, 0,
            0, 0, 0, 1, 0 };
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();

    mTouchX = 0.01f; // 不让x,y为0,否则在点计算时会有问题
    mTouchY = 0.01f;
}
CornerCutView.java 文件源码 项目:PlayerBase 阅读 25 收藏 0 点赞 0 评论 0
private void drawRightTop(Canvas canvas) {

        // 初始化数据点和控制点的位置
        start.x = mWidth - mCornerRadius;
        start.y = 0;
        end.x = mWidth;
        end.y = mCornerRadius;
        control.x = mWidth;
        control.y = 0;

        Path rightTop = new Path();
        rightTop.moveTo(mWidth,0);
        rightTop.lineTo(mWidth - mCornerRadius,0);
        rightTop.quadTo(control.x,control.y,end.x,end.y);
        rightTop.lineTo(mWidth,0);
        canvas.drawPath(rightTop,mPaint);
    }
PathBitmapMesh.java 文件源码 项目:Mire 阅读 38 收藏 0 点赞 0 评论 0
public void matchVertsToPath(Path path, float bottomCoord, float extraOffset) {
    PathMeasure pm = new PathMeasure(path, false);

    for (int i = 0; i < staticVerts.length / 2; i++) {

        float yIndexValue = staticVerts[i * 2 + 1];
        float xIndexValue = staticVerts[i * 2];


        float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
        float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
        percentOffsetX2 += pathOffsetPercent;
        pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
        pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);

        if (yIndexValue == 0) {
            setXY(drawingVerts, i, coords[0], coords2[1]);
        } else {
            float desiredYCoord = bottomCoord;
            setXY(drawingVerts, i, coords[0], desiredYCoord);

        }
    }
}
ColumnChartRenderer.java 文件源码 项目:boohee_v5.6 阅读 83 收藏 0 点赞 0 评论 0
public void drawTargetCaloryLine(Canvas drawCanvas) {
    if (this.targetCalory > 0) {
        float currentLeft = 0.0f;
        float currentRight = 0.0f;
        int target = this.targetCalory;
        Viewport currentViewport = this.computator.getCurrentViewport();
        if (currentViewport != null) {
            currentLeft = currentViewport.left;
            currentRight = currentViewport.right;
        }
        float rawX1 = this.computator.computeRawX(currentLeft);
        float rawX2 = this.computator.computeRawX(currentRight);
        float y = this.computator.computeRawY((float) target);
        Path path1 = new Path();
        path1.moveTo(rawX1, y);
        path1.lineTo(rawX2, y);
        drawCanvas.drawPath(path1, this.caloryLinePaint);
    }
}
RadarView.java 文件源码 项目:ColumnAnimViewProject 阅读 32 收藏 0 点赞 0 评论 0
/**
 * 绘制区域
 * @param canvas
 */
private void drawRegion(Canvas canvas){
    Path path = new Path();
    valuePaint.setAlpha(255);
    for(int i=0;i<count;i++){
        double percent = data[i]/maxValue;
        float x = (float) (centerX+radius*Math.cos(angle*i)*percent);
        float y = (float) (centerY+radius*Math.sin(angle*i)*percent);
        if(i==0){
            path.moveTo(x, centerY);
        }else{
            path.lineTo(x,y);
        }
        //绘制小圆点
        canvas.drawCircle(x,y,10,valuePaint);
    }
    valuePaint.setStyle(Paint.Style.STROKE);
    canvas.drawPath(path, valuePaint);
    valuePaint.setAlpha(127);
    //绘制填充区域
    valuePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    canvas.drawPath(path, valuePaint);
}
GhostsEyeLoadingRenderer.java 文件源码 项目:GitHub 阅读 29 收藏 0 点赞 0 评论 0
private Path createLeftEyeCircle(RectF arcBounds, float offsetY) {
    Path path = new Path();

    //the center of the left eye
    float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
    float leftEyeCenterY = arcBounds.centerY() + offsetY;
    //the bounds of left eye
    RectF leftEyeBounds = new RectF(leftEyeCenterX - mEyeCircleRadius, leftEyeCenterY - mEyeCircleRadius,
            leftEyeCenterX + mEyeCircleRadius, leftEyeCenterY + mEyeCircleRadius);
    path.addArc(leftEyeBounds, 0, DEGREE_180 + 15);
    //the above radian of of the eye
    path.quadTo(leftEyeBounds.left + mAboveRadianEyeOffsetX, leftEyeBounds.top + mEyeCircleRadius * 0.2f,
            leftEyeBounds.left + mAboveRadianEyeOffsetX / 4.0f, leftEyeBounds.top - mEyeCircleRadius * 0.15f);

    return path;
}
ElectricView.java 文件源码 项目:SphereLayout 阅读 26 收藏 0 点赞 0 评论 0
public ElectricView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mPath = new Path();
    mRandom = new Random();
    mPaint = new Paint();
    mPaint.setColor(0xffffff8e);
    mPaint.setStrokeWidth(3);
    mPaint.setStyle(Paint.Style.STROKE);
    mMaxOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getContext().getResources().getDisplayMetrics());
    mStartMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getContext().getResources().getDisplayMetrics());

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ElectricView);
    mElectricCount = typedArray.getInt(R.styleable.ElectricView_electricCount, 1);
    mStartFromRight = typedArray.getInt(R.styleable.ElectricView_startFrom, 0) == 1;
    mDegree = typedArray.getInt(R.styleable.ElectricView_degree, 0);
    typedArray.recycle();
}
Windmill.java 文件源码 项目:OneWeather 阅读 26 收藏 0 点赞 0 评论 0
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);
}
SetupStartIndicatorView.java 文件源码 项目:AOSP-Kayboard-7.1.2 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final int width = getWidth();
    final int height = getHeight();
    final float halfHeight = height / 2.0f;
    final Path path = mIndicatorPath;
    path.rewind();
    if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
        // Left arrow
        path.moveTo(width, 0.0f);
        path.lineTo(0.0f, halfHeight);
        path.lineTo(width, height);
    } else { // LAYOUT_DIRECTION_LTR
        // Right arrow
        path.moveTo(0.0f, 0.0f);
        path.lineTo(width, halfHeight);
        path.lineTo(0.0f, height);
    }
    path.close();
    final int[] stateSet = getDrawableState();
    final int color = mIndicatorColor.getColorForState(stateSet, 0);
    mIndicatorPaint.setColor(color);
    canvas.drawPath(path, mIndicatorPaint);
}
BGAMoocStyleRefreshView.java 文件源码 项目:GitHub 阅读 35 收藏 0 点赞 0 评论 0
private void initCanvas() {
    mOriginalBitmapWidth = mOriginalBitmap.getWidth();
    mOriginalBitmapHeight = mOriginalBitmap.getHeight();

    // 初始状态值
    mWaveOriginalY = mOriginalBitmapHeight;
    mWaveY = 1.2f * mWaveOriginalY;
    mBezierControlOriginalY = 1.25f * mWaveOriginalY;
    mBezierControlY = mBezierControlOriginalY;

    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    mBezierPath = new Path();

    mCanvas = new Canvas();
    mUltimateBitmap = Bitmap.createBitmap(mOriginalBitmapWidth, mOriginalBitmapHeight, Config.ARGB_8888);
    mCanvas.setBitmap(mUltimateBitmap);
}


问题


面经


文章

微信
公众号

扫码关注公众号