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


Java Canvas.drawPaint方法代码示例

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


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

示例1: drawHorizontal

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 绘制横向水平分割线
 */
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    int top = parent.getPaddingTop();
    int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getRight() + layoutParams.rightMargin;
        int right = left + mDividerWidth;

        if (mDividerDrawable != null) {
            //如果是图片分割线,绘制图片
            mDividerDrawable.setBounds(left, top, right, bottom);
            canvas.drawPaint(mPaint);
            mDividerDrawable.draw(canvas);
        } else {
            //绘制矩形
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:25,代码来源:UIDivider.java

示例2: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 *即使不打算使用构造方法,按照习惯也应该添加它们
 */


@Override
protected void onDraw(Canvas canvas) {
    //fill the background
    canvas.drawPaint(mBackgroundPaint);

    for (Box box : mBoxen) {
        float left = Math.min(box.getOrigin().x, box.getCurrent().x);
        float right = Math.max(box.getOrigin().x, box.getCurrent().x);
        float top = Math.min(box.getOrigin().y, box.getCurrent().y);
        float bottom = Math.max(box.getOrigin().y, box.getCurrent().y);

        canvas.drawRect(left, top, right, bottom, mBoxPaint);
    }
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:20,代码来源:BoxDrawingView.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
  canvas.drawPaint(backgroundPaint);

  if (this.liveStrength == null) {
    // Nothing to draw yet...
    return;
  }

  float midX = canvas.getWidth() / 2f;
  float midY = canvas.getHeight() / 2f;
  float rad = Math.min(midX / 4f, midY);
  for (int i = 0; i < 4; i++) {
    float atX = midX + (i * 2 - 3) * rad; // i = [0, 1, 2, 3] -> [-3, -1, 1, 3]
    Paint paint = paintForStrength(liveStrength.getChannelStatus(i));
    canvas.drawCircle(atX, midY, rad * PADDING, paint);
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:19,代码来源:ConnectionStrengthView.java

示例4: drawUniverse

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawUniverse(Canvas canvas) {
    // draw background
    mPaint.setColor(mUniverse.getColor());
    canvas.drawPaint(mPaint);

    // draw stars
    for (Star star : mUniverse.getStars()) {
        drawStar(canvas, star);
    }
}
 
开发者ID:catalinc,项目名称:stars-daydream-android,代码行数:11,代码来源:RenderThread.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    canvas.drawPaint(mBackgroundPaint);
    
    for (Box box : mBoxen) {
        float left = Math.min(box.getOrigin().x, box.getCurrent().x);
        float top = Math.min(box.getOrigin().y, box.getCurrent().y);
        float right = Math.max(box.getOrigin().x, box.getCurrent().x);
        float bottom = Math.max(box.getOrigin().y, box.getCurrent().y);
        
        canvas.drawRect(left, top, right, bottom, mBoxPaint);
    }
    
    
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:16,代码来源:BoxDrawingView.java

示例6: clipCanvasHardware

import android.graphics.Canvas; //导入方法依赖的package包/类
private void clipCanvasHardware(Canvas canvas) {
    mPaint.setColor(Color.BLACK);
    mPaint.setXfermode(mClipPorterDuffXfermode);

    float radius = getScaledRadius();
    mShaderMatrix.setScale(radius, radius);
    mShaderMatrix.postTranslate(radius + getOffsetX(), radius + getOffsetY());
    mClipShader.setLocalMatrix(mShaderMatrix);
    mPaint.setShader(mClipShader);
    canvas.drawPaint(mPaint);
    mPaint.setXfermode(null);
    mPaint.setShader(null);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:14,代码来源:FolderIcon.java

示例7: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(final Canvas canvas) {
  final int x = 10;
  int y = (int) (fgPaint.getTextSize() * 1.5f);

  canvas.drawPaint(bgPaint);

  if (results != null) {
    for (final Recognition recog : results) {
      canvas.drawText(recog.getTitle() + ": " + recog.getConfidence(), x, y, fgPaint);
      y += fgPaint.getTextSize() * 1.5f;
    }
  }
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:15,代码来源:RecognitionScoreView.java

示例8: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    // Fill the background
    canvas.drawPaint(mBackgroundPaint);

    for (Box box : mBoxen) {
        float left = Math.min(box.getOrigin().x, box.getCurrent().x);
        float right = Math.max(box.getOrigin().x, box.getCurrent().x);
        float top = Math.min(box.getOrigin().y, box.getCurrent().y);
        float bottom = Math.max(box.getOrigin().y, box.getCurrent().y);
        
        canvas.drawRect(left, top, right, bottom, mBoxPaint);
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:15,代码来源:BoxDrawingView.java

示例9: dispatchDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (drawMask) {
        int height = getMeasuredHeight();
        LinearGradient linearGradient = new LinearGradient(0, height, 0,
                height - 40 * mDensity,
                new int[]{Color.parseColor("#80000000"), Color.TRANSPARENT /*Color.parseColor("#40000000")*/},
                null, Shader.TileMode.CLAMP);
        mPaint.setShader(linearGradient);
        canvas.drawPaint(mPaint);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:RNineImageLayout.java

示例10: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(final Canvas canvas) {
    final int x = 10;
    int y = (int) (fgPaint.getTextSize() * 1.5f);

    canvas.drawPaint(bgPaint);

    if (results != null) {
        for (final Classifier.Recognition recog : results) {
            String confidence = String.format("%.1f%% ", recog.getConfidence() * 100.0f);
            canvas.drawText(recog.getTitle() + ": " + confidence, x, y, fgPaint);
            y += fgPaint.getTextSize() * 1.5f;
        }
    }
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:16,代码来源:RecognitionScoreView.java

示例11: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
  Paint background = new Paint();
  background.setColor(Color.WHITE);
  background.setStyle(Paint.Style.FILL_AND_STROKE);
  canvas.drawPaint(background);

  if (timeSeries == null || timeSeries.isEmpty()) {
    return; // No points, so skip.
  }

  // Calculate bounds for the X axis.
  TimeSeriesSnapshot<Double[]> snapshot = timeSeries.getRecentSnapshot(Double[].class);
  long timeEndMicro = snapshot.timestamps[snapshot.length - 1];
  long timeStartMicro = snapshot.timestamps[0];
  double timeDeltaInv = 1.0 / (double)(timeEndMicro - timeStartMicro);

  for (int i = 0; i < snapshot.length; i++) {
    double x = snapshot.values[i][0]; // Relative Theta
    double y = snapshot.values[i][1]; // Relative Beta
    float fX = (float)(x * canvas.getWidth());
    float fY = (float)((1 - y) * canvas.getHeight());
    float fR = DOT_RADIUS * canvas.getWidth();
    double age = Math.min(1, Math.max(0,
        (timeEndMicro - snapshot.timestamps[i]) * timeDeltaInv));
    canvas.drawCircle(fX, fY, fR, paintForAge(age));
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:29,代码来源:Plot2DView.java

示例12: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(final Canvas canvas) {
    final int x = 10;
    int y = (int) (mFgPaint.getTextSize() * 1.5f);

    canvas.drawPaint(mBgPaint);

    if (mShowText != null) {
        canvas.drawText(mShowText, x, y, mFgPaint);
    }
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:12,代码来源:TrasparentTitleView.java

示例13: getInitialsBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
/** Constructing a bitmap with the given text written in it.*/
public static Bitmap getInitialsBitmap(int backGroundColor, int textColor, String initials){

    int size = BDefines.ImageProperties.INITIALS_IMAGE_SIZE;
    float textSize = BDefines.ImageProperties.INITIALS_TEXT_SIZE;

    int textSpace = size/2;

    // Create bitmap and canvas to draw to
    Bitmap b = Bitmap.createBitmap(size, size, Bitmap.Config.RGB_565);
    Canvas c= new Canvas(b);

    // Draw background
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG
            | Paint.LINEAR_TEXT_FLAG);
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(backGroundColor);
    c.drawPaint(paint);

    // Draw text
    c.save();

    Bitmap textBitmap = textAsBitmap(initials, textSize, textColor);

    c.drawBitmap(textAsBitmap(initials, textSize, textColor), textSpace - textBitmap.getWidth()/2, textSpace - textBitmap.getHeight()/2, null);

    c.restore();

    return b;
}
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:31,代码来源:ImageUtils.java

示例14: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    try {
        super.onDraw(canvas);
        this.canvas = canvas;
        setMinimumWidth(radius * 2);
        int theCircleWidth = getWidth();
        int theCircleHeight = getHeight();
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.TRANSPARENT);
        paint.setFlags(Paint.ANTI_ALIAS_FLAG);
        canvas.drawPaint(paint);

        // stroke
        paint.setColor(strokeColor);
        canvas.drawCircle(theCircleWidth / 2, theCircleHeight / 2, radius + Common.brailleDotStrokeSize, paint);

        //Radius
        if ((fillDot && fillDotOnTouchSettings) || !fillDotOnTouchSettings) {
            paint.setColor(fillColor);
            canvas.drawCircle(theCircleWidth / 2, theCircleHeight / 2, radius, paint);
        } else {
            paint.setColor(Common.getMyColor(R.color.swiftBrailleBG));
            canvas.drawCircle(theCircleWidth / 2, theCircleHeight / 2, radius, paint);
        }

        if (viewBrailleDotNumber) {
            textPaint.setColor(strokeColor);
            textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
            textPaint.setTextSize(radius);
            textPaint.setTextAlign(Paint.Align.CENTER);
            int yPos = (int) ((getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2));
            canvas.drawText(String.format(Locale.getDefault(), "%d", dotTextNumber), theCircleWidth / 2, yPos, textPaint);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:39,代码来源:BrailleDot.java

示例15: onDraw

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

// TextSize
paintTextLevel.setTextSize(this.getWidth() / 3 | 1);

 		// draw text
canvas.drawText(level + "%", this.getWidth() / 2, this.getHeight() / 2, paintTextLevel);

 	}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:16,代码来源:Main.java


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