项目:PresenterLite
文件:ShapedImageView.java
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,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;
}
项目:android-dev-challenge
文件:TrailedShape.java
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);
}
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,getMeasuredWidth(),getMeasuredHeight()/2+getMeasuredWidth()/7f);
canvas.drawPath(mPath,mPaint);
canvas.restore();
mPaint.setShader(null);
}
项目:PropertyAnimatorDemo
文件:MyBezierView.java
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);
}
项目:ColumnAnimViewProject
文件:RadarView.java
/**
* 绘制正多边形
*/
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);
}
}
@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,mTransparentPaint);
canvas.drawPath(mPath,mSemiBlackPaint);
canvas.clipPath(mPath);
canvas.drawColor(Color.parseColor("#A6000000"));
}
项目:RTLMaterialSpinner
文件:RtlMaterialSpinner.java
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();
}
}
项目:atlas
文件:ShapeFill.java
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);
}
项目:Material-Motion
文件:BaseFragment.java
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;
}
项目:PopupCircleMenu
文件:PopupLayer.java
/**
* 用来给每一个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;
}
}
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);
}
项目:open-rmbt
文件:simplegraph.java
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();
}
项目:RNLearn_Project1
文件:DrawView.java
/**
* 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,Path.Direction.CW);
}
项目:GitHub
文件:LineRadarRenderer.java
/**
* 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() + ".");
}
}
项目:android-slidr
文件:Slidr.java
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.left,rect.bottom - roundRectHeight);
path.lineto(rect.left,rect.top + roundRectHeight);
path.quadTo(rect.left,rect.left + roundRectHeight,rect.top);
path.close();
canvas.drawPath(path,settings.paintBubble);
}
项目:MyRepository
文件:RoundImageView.java
@Override
protected void onDraw(Canvas canvas) {
Log.e("TAG","onDraw");
if (getDrawable() == null) {
return;
}
setUpShader();
if (type == TYPE_ROUND) {
canvas.drawRoundRect(mRoundRect,mBorderRadius,mBitmapPaint);
} else if (type == TYPE_LEFT_ROUND) {
float[] radii = {mBorderRadius,0f,mBorderRadius};
Path path = new Path();
path.addRoundRect(mRoundRect,radii,Path.Direction.CW);
canvas.drawPath(path,mBitmapPaint);
} else {
canvas.drawCircle(mRadius,mRadius,mBitmapPaint);
// drawSomeThing(canvas);
}
}
项目:EasyChart
文件:EasyGraphLine.java
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;
}
项目:atlas
文件:MergePathsContent.java
@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;
}
}
项目:open-rmbt
文件:StaticGraph.java
private StaticGraph(final int color,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);
}
项目:NovelReader
文件:SimulationPageAnim.java
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,1,0 };
cm.set(array);
mColorMatrixFilter = new ColorMatrixColorFilter(cm);
mMatrix = new Matrix();
mTouchX = 0.01f; // 不让x,y为0,否则在点计算时会有问题
mTouchY = 0.01f;
}
项目:PlayerBase
文件:CornerCutView.java
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);
}
项目:Mire
文件:PathBitmapMesh.java
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),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,desiredYCoord);
}
}
}
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);
}
}
项目:ColumnAnimViewProject
文件:RadarView.java
/**
* 绘制区域
* @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);
}
项目:GitHub
文件:GhostsEyeLoadingRenderer.java
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,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;
}
项目:SphereLayout
文件:ElectricView.java
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();
}
项目:OneWeather
文件:Windmill.java
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,mCenterPoint.y);
}
项目:AOSP-Kayboard-7.1.2
文件:SetupStartIndicatorView.java
@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);
}
项目:GitHub
文件:BGAMoocStyleRefreshView.java
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);
}
项目:Android-Code-Demos
文件:SpiderNetView.java
private void drawPointsAndFill(Canvas canvas) {
Path path = new Path();
path.moveto(munitPointFs[0].x * mOffsets[0] / 100 * mNetLength,munitPointFs[0].y * mOffsets[0] / 100 * mNetLength);
for (int i = 0; i < munitPointFs.length; i++) {
/* draw point */
canvas.drawPoint(munitPointFs[i].x * mOffsets[i] / 100 * mNetLength,munitPointFs[i].y * mOffsets[i] / 100 * mNetLength,mPointPaint);
/* draw line */
if (i + 1 != munitPointFs.length) {
path.lineto(munitPointFs[i + 1].x * mOffsets[i + 1] / 100 * mNetLength,munitPointFs[i + 1].y * mOffsets[i + 1] / 100 * mNetLength);
} else {
path.lineto(munitPointFs[0].x * mOffsets[0] / 100 * mNetLength,munitPointFs[0].y * mOffsets[0] / 100 * mNetLength);
}
}
path.close();
canvas.drawPath(path,mFillPaint);
}
项目:miaosou
文件:BounceBallView.java
private void initData() {
defaultPadding = 2 * radius + dp2px(2);
defaultPaddingBottom = 2 * radius + dp2px(15);
defaultWidth = (int) (2 * defaultPadding + dp2px(200));
defaultHeight = (int) (defaultPadding + defaultPaddingBottom + dp2px(80));
paint = new Paint[ballCount];
for (int i = 0; i < paint.length; i++) {
paint[i] = new Paint(Paint.ANTI_ALIAS_FLAG);
paint[i].setColor(ballColor);
paint[i].setStyle(Paint.Style.FILL);
}
path = new Path();
pathMeasure = new PathMeasure();
randomBallColors = new int[ballCount];
randomradius = new float[ballCount];
randomTransRatioX = new float[ballCount];
randomTransRatioY = new float[ballCount];
translateFraction = new float[ballCount];
translateAnim = new ValueAnimator[ballCount];
}
public Bitmap GetBitmapClippedCircle(Bitmap bitmap) {
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
final Bitmap outputBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
final Path path = new Path();
path.addCircle(
(float) (width / 2),(float) (height / 2),(float) Math.min(width,(height / 2)),Path.Direction.ccw);
final Canvas canvas = new Canvas(outputBitmap);
canvas.clipPath(path);
canvas.drawBitmap(bitmap,null);
bitmap.recycle();
return outputBitmap;
}
项目:Musicoco
文件:MarkerDrawable.java
private void computePath(Rect bounds) {
final float currentScale = mCurrentScale;
final Path path = mPath;
final RectF rect = mRect;
final Matrix matrix = mMatrix;
path.reset();
int totalSize = Math.min(bounds.width(),bounds.height());
float initial = mClosedStateSize;
float destination = totalSize;
float currentSize = initial + (destination - initial) * currentScale;
float halfSize = currentSize / 2f;
float inverseScale = 1f - currentScale;
float cornerSize = halfSize * inverseScale;
float[] corners = new float[]{halfSize,halfSize,cornerSize,cornerSize};
rect.set(bounds.left,bounds.top,bounds.left + currentSize,bounds.top + currentSize);
path.addRoundRect(rect,corners,Path.Direction.ccw);
matrix.reset();
matrix.postRotate(-45,bounds.left + halfSize,bounds.top + halfSize);
matrix.postTranslate((bounds.width() - currentSize) / 2,0);
float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
matrix.postTranslate(0,hDiff);
path.transform(matrix);
}
项目:SmartRefresh
文件:MaterialHeader.java
private void initView(Context context,AttributeSet attrs) {
setMinimumHeight(DensityUtil.dp2px(100));
mProgress = new MaterialProgressDrawable(context,this);
mProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
mProgress.setAlpha(255);
mProgress.setColorSchemeColors(0xff0099cc,0xffff4444,0xff669900,0xffaa66cc,0xffff8800);
mCircleView = new CircleImageView(context,CIRCLE_BG_LIGHT);
mCircleView.setimageDrawable(mProgress);
mCircleView.setVisibility(View.GONE);
addView(mCircleView);
final displayMetrics metrics = getResources().getdisplayMetrics();
mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density);
mBezierPath = new Path();
mBezierPaint = new Paint();
mBezierPaint.setAntiAlias(true);
mBezierPaint.setStyle(Paint.Style.FILL);
TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.MaterialHeader);
mShowBezierWave = ta.getBoolean(R.styleable.MaterialHeader_mhShowBezierWave,mShowBezierWave);
mBezierPaint.setColor(ta.getColor(R.styleable.MaterialHeader_mhPrimaryColor,0xff11bbff));
if (ta.hasValue(R.styleable.MaterialHeader_mhShadowRadius)) {
int radius = ta.getDimensionPixelOffset(R.styleable.MaterialHeader_mhShadowRadius,0);
int color = ta.getColor(R.styleable.MaterialHeader_mhShadowColor,0xff000000);
mBezierPaint.setShadowLayer(radius,color);
setLayerType(LAYER_TYPE_SOFTWARE,null);
}
ta.recycle();
}
/**
* Returns if the shape of the icon is same as the path.
* For this method to work,the shape path bounds should be in [0,1]x[0,1] bounds.
*/
private boolean isShape(Path maskPath) {
// Condition1:
// If width and height of the path not close to a square,then the icon shape is
// not same as the mask shape.
float iconRatio = ((float) mBounds.width()) / mBounds.height();
if (Math.abs(iconRatio - 1) > BOUND_RATIO_MARGIN) {
return false;
}
// Condition 2:
// Actual icon (white) and the fitted shape (e.g.,circle)(red) XOR operation
// should generate transparent image,if the actual icon is equivalent to the shape.
mFileId = mRandom.nextInt();
mBitmapARGB.eraseColor(Color.TRANSPARENT);
mCanvasARGB.drawBitmap(mBitmap,mPaintIcon);
// Fit the shape within the icon's bounding Box
mMatrix.reset();
mMatrix.setScale(mBounds.width(),mBounds.height());
mMatrix.postTranslate(mBounds.left,mBounds.top);
maskPath.transform(mMatrix);
// XOR operation
mCanvasARGB.drawPath(maskPath,mPaintMaskShape);
// DST_OUT operation around the mask path outline
mCanvasARGB.drawPath(maskPath,mPaintMaskShapeOutline);
boolean isTrans = isTransparentBitmap(mBitmapARGB);
// Check if the result is almost transparent
if (!isTrans) {
return false;
}
return true;
}
项目:Sprog-App
文件:FastScrollPopup.java
public void draw(Canvas canvas) {
if (isVisible()) {
// Draw the fast scroller popup
int restoreCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.translate(mBgBounds.left,mBgBounds.top);
mTmpRect.set(mBgBounds);
mTmpRect.offsetTo(0,0);
mBackgroundpath.reset();
mBackgroundRect.set(mTmpRect);
float[] radii;
if (Utils.isRtl(mRes)) {
radii = new float[]{mCornerRadius,mCornerRadius,0};
} else {
radii = new float[]{mCornerRadius,mCornerRadius};
}
mBackgroundpath.addRoundRect(mBackgroundRect,Path.Direction.CW);
mBackgroundPaint.setAlpha((int) (mAlpha * 255));
mTextPaint.setAlpha((int) (mAlpha * 255));
canvas.drawPath(mBackgroundpath,mBackgroundPaint);
canvas.drawText(mSectionName,(mBgBounds.width() - mTextBounds.width()) / 2,mBgBounds.height() - (mBgBounds.height() - mTextBounds.height()) / 2,mTextPaint);
canvas.restoretoCount(restoreCount);
}
}
项目:MySelfDemo
文件:MyView2.java
/**
* 用 path 拼接的时候 moveto 这个参数
*
* @param canvas
*/
private void drawPaht4(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.stroke);
paint.setAntiAlias(true);
Path path = new Path();
path.lineto(100,100);
path.moveto(200,100); //此为移动到某个点上去 用 moveto可以移动起始点 =此过程不会绘制图形,不过会移动点
path.lineto(200,0); // lineto 都是想对于上个点来说的
canvas.drawPath(path,paint);
}
项目:Vorolay
文件:VoronoiRegion.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。