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


Java Paint类代码示例

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


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

示例1: drawPacman

import android.graphics.Paint; //导入依赖的package包/类
private void drawPacman(Canvas canvas,Paint paint){
    float x=getWidth()/2;
    float y=getHeight()/2;

    canvas.save();

    canvas.translate(x, y);
    canvas.rotate(degrees1);
    paint.setAlpha(255);
    RectF rectF1=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
    canvas.drawArc(rectF1, 0, 270, true, paint);

    canvas.restore();

    canvas.save();
    canvas.translate(x, y);
    canvas.rotate(degrees2);
    paint.setAlpha(255);
    RectF rectF2=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
    canvas.drawArc(rectF2,90,270,true,paint);
    canvas.restore();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PacmanIndicator.java

示例2: drawCenterText

import android.graphics.Paint; //导入依赖的package包/类
private void drawCenterText(Canvas canvas) {
    canvas.save();
    paint3.setStyle(Paint.Style.FILL);
    paint3.setColor(Color.WHITE);
    paint3.setFakeBoldText(true);
    paint3.setTextSize(topTextSize);
    String content1 = (maxNum-currNum) + "/" + maxNum;
    canvas.drawText(content1, -paint3.measureText(content1) / 2, 0, paint3);
    paint3.setTextSize(bottomTextSize);
    String content = "未得学分/总学分";
    paint3.setFakeBoldText(false);
    Rect r = new Rect();
    paint3.getTextBounds(content, 0, content.length(), r);
    canvas.drawText(content, -r.width() / 2, r.height() + 20, paint3);
    canvas.restore();
}
 
开发者ID:NICOLITE,项目名称:HutHelper,代码行数:17,代码来源:CirclePie.java

示例3: SimulationPageAnim

import android.graphics.Paint; //导入依赖的package包/类
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;
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:23,代码来源:SimulationPageAnim.java

示例4: scaleBitmap

import android.graphics.Paint; //导入依赖的package包/类
public static Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight) {
    Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);

    float scaleX = newWidth / (float) bitmap.getWidth();
    float scaleY = newHeight / (float) bitmap.getHeight();
    float pivotX = 0;
    float pivotY = 0;

    Matrix scaleMatrix = new Matrix();
    scaleMatrix.setScale(scaleX, scaleY, pivotX, pivotY);

    Canvas canvas = new Canvas(scaledBitmap);
    canvas.setMatrix(scaleMatrix);
    canvas.drawBitmap(bitmap, 0, 0, new Paint(Paint.FILTER_BITMAP_FLAG));

    return scaledBitmap;
}
 
开发者ID:afiqiqmal,项目名称:My-Android-Base-Code,代码行数:18,代码来源:SubUtils.java

示例5: addImageWatermark

import android.graphics.Paint; //导入依赖的package包/类
/**
 * 添加图片水印
 *
 * @param src 源图片
 * @param watermark 图片水印
 * @param x 起始坐标x
 * @param y 起始坐标y
 * @param alpha 透明度
 * @param recycle 是否回收
 * @return 带有图片水印的图片
 */
public static Bitmap addImageWatermark(Bitmap src, Bitmap watermark, int x, int y, int alpha, boolean recycle) {
    if (isEmptyBitmap(src)) {
        return null;
    }
    Bitmap ret = src.copy(src.getConfig(), true);
    if (!isEmptyBitmap(watermark)) {
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        Canvas canvas = new Canvas(ret);
        paint.setAlpha(alpha);
        canvas.drawBitmap(watermark, x, y, paint);
    }
    if (recycle && !src.isRecycled()) {
        src.recycle();
    }
    return ret;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:28,代码来源:ImageUtils.java

示例6: TextAlignment

import android.graphics.Paint; //导入依赖的package包/类
/**
 * Specifies the alignment of the canvas's text: center, normal
 * (starting at the specified point in DrawText() or DrawAngle()),
 * or opposite (ending at the specified point in DrawText() or
 * DrawAngle()).
 *
 * @param alignment  one of {@link Component#ALIGNMENT_NORMAL},
 *                   {@link Component#ALIGNMENT_CENTER} or
 *                   {@link Component#ALIGNMENT_OPPOSITE}
 */
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_TEXTALIGNMENT,
                  defaultValue = DEFAULT_TEXTALIGNMENT + "")
@SimpleProperty(userVisible = true)
public void TextAlignment(int alignment) {
  this.textAlignment = alignment;
  switch (alignment) {
    case Component.ALIGNMENT_NORMAL:
      paint.setTextAlign(Paint.Align.LEFT);
      break;
    case Component.ALIGNMENT_CENTER:
      paint.setTextAlign(Paint.Align.CENTER);
      break;
    case Component.ALIGNMENT_OPPOSITE:
      paint.setTextAlign(Paint.Align.RIGHT);
      break;
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:28,代码来源:Canvas.java

示例7: circleCrop

import android.graphics.Paint; //导入依赖的package包/类
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
    if (source == null) return null;

    int size = Math.min(source.getWidth(), source.getHeight());
    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);

    Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
    if (result == null) {
        result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    }

    Canvas canvas = new Canvas(result);
    Paint paint = new Paint();
    paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
    paint.setAntiAlias(true);
    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);
    return result;
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:23,代码来源:GlideCircleTransform.java

示例8: JavaFontRenderingBox

import android.graphics.Paint; //导入依赖的package包/类
public JavaFontRenderingBox(String str, int type, float size, Typeface f,
			boolean kerning) {
		this.str = str;
		this.size = size;
		//计算出文字需要的宽高
//		Paint pFont=AjLatexMath.getPaint();
//		pFont.setTextSize(AjLatexMath.getTextSize());
		Paint pFont =new Paint();
		Rect rect = new Rect();
		pFont.getTextBounds(str, 0, str.length(), rect);
		 this.height = (float) (-rect.top * size / 2);
		 this.depth = (float) ((rect.height() * size / 2) - this.height);
		 this.width = (float) ((rect.width() + rect.right + 0.4f) * size /
		 4);
		System.out.println(" width="+width+" height="+height+" text="+str);
	}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:17,代码来源:JavaFontRenderingBox.java

示例9: PDFView

import android.graphics.Paint; //导入依赖的package包/类
/** Construct the initial view */
public PDFView(Context context, AttributeSet set) {
    super(context, set);
    miniMapRequired = false;
    cacheManager = new CacheManager();
    animationManager = new AnimationManager(this);
    dragPinchManager = new DragPinchManager(this);

    paint = new Paint();
    debugPaint = new Paint();
    debugPaint.setStyle(Style.STROKE);
    paintMinimapBack = new Paint();
    paintMinimapBack.setStyle(Style.FILL);
    paintMinimapBack.setColor(Color.BLACK);
    paintMinimapBack.setAlpha(50);
    paintMinimapFront = new Paint();
    paintMinimapFront.setStyle(Style.FILL);
    paintMinimapFront.setColor(Color.BLACK);
    paintMinimapFront.setAlpha(50);

    // A surface view does not call
    // onDraw() as a default but we need it.
    setWillNotDraw(false);
}
 
开发者ID:lidong1665,项目名称:AndroidPDF,代码行数:25,代码来源:PDFView.java

示例10: highlightSelectedFaceThumbnail

import android.graphics.Paint; //导入依赖的package包/类
public static Bitmap highlightSelectedFaceThumbnail(Bitmap originalBitmap) {
    Bitmap bitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.parseColor("#3399FF"));
    int stokeWidth = Math.max(originalBitmap.getWidth(), originalBitmap.getHeight()) / 10;
    if (stokeWidth == 0) {
        stokeWidth = 1;
    }
    bitmap.getWidth();
    paint.setStrokeWidth(stokeWidth);
    canvas.drawRect(
            0,
            0,
            bitmap.getWidth(),
            bitmap.getHeight(),
            paint);

    return bitmap;
}
 
开发者ID:interritus1996,项目名称:memento-app,代码行数:23,代码来源:ImageHelper.java

示例11: init

import android.graphics.Paint; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void init(@NonNull TypedArray a) {
    setGravity(Gravity.CENTER_HORIZONTAL);

    mAspectRatioTitle = a.getString(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_title);
    mAspectRatioX = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_x, CropImageView.SOURCE_IMAGE_ASPECT_RATIO);
    mAspectRatioY = a.getFloat(R.styleable.ucrop_AspectRatioTextView_ucrop_artv_ratio_y, CropImageView.SOURCE_IMAGE_ASPECT_RATIO);

    if (mAspectRatioX == CropImageView.SOURCE_IMAGE_ASPECT_RATIO || mAspectRatioY == CropImageView.SOURCE_IMAGE_ASPECT_RATIO) {
        mAspectRatio = CropImageView.SOURCE_IMAGE_ASPECT_RATIO;
    } else {
        mAspectRatio = mAspectRatioX / mAspectRatioY;
    }

    mDotSize = getContext().getResources().getDimensionPixelSize(R.dimen.ucrop_size_dot_scale_text_view);
    mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDotPaint.setStyle(Paint.Style.FILL);

    setTitle();

    int activeColor = getResources().getColor(R.color.ucrop_color_widget_active);
    applyActiveColor(activeColor);

    a.recycle();
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:26,代码来源:AspectRatioTextView.java

示例12: PlayPauseView

import android.graphics.Paint; //导入依赖的package包/类
public PlayPauseView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setWillNotDraw(false);

    TypedValue colorTheme = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorAccent, colorTheme, true);

    mBackgroundColor = Color.parseColor("#000000");//colorTheme.data;
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);
    mDrawable = new PlayPauseDrawable(context);
    mDrawable.setCallback(this);

    mPauseBackgroundColor = Color.parseColor("#000000");//colorTheme.data;
    mPlayBackgroundColor = Color.parseColor("#000000");//colorTheme.data;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PlayPause);
    isDrawCircle = a.getBoolean(R.styleable.PlayPause_isCircleDraw, isDrawCircle);
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:20,代码来源:PlayPauseView.java

示例13: addImageWatermark

import android.graphics.Paint; //导入依赖的package包/类
/**
 * 添加图片水印
 *
 * @param src       源图片
 * @param watermark 图片水印
 * @param x         起始坐标x
 * @param y         起始坐标y
 * @param alpha     透明度
 * @param recycle   是否回收
 * @return 带有图片水印的图片
 */
public static Bitmap addImageWatermark(final Bitmap src, final Bitmap watermark, final int x
		, final int y, final int alpha, final boolean recycle) {
	if (isEmptyBitmap(src)) {
		return null;
	}
	Bitmap ret = src.copy(src.getConfig(), true);
	if (!isEmptyBitmap(watermark)) {
		Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		Canvas canvas = new Canvas(ret);
		paint.setAlpha(alpha);
		canvas.drawBitmap(watermark, x, y, paint);
	}
	if (recycle && !src.isRecycled()) {
		src.recycle();
	}
	return ret;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:29,代码来源:ImageUtils.java

示例14: blurBitmap

import android.graphics.Paint; //导入依赖的package包/类
public static Bitmap blurBitmap(Bitmap bkg, int width, int height) {
    long startMs = System.currentTimeMillis();
    float radius = 15;//越大模糊效果越大
    float scaleFactor = 8;
    //放大到整个view的大小
    bkg = DrawableProvider.getReSizeBitmap(bkg, width, height);
    Bitmap overlay = Bitmap.createBitmap((int) (width / scaleFactor)
            , (int) (height / scaleFactor), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.scale(1 / scaleFactor, 1 / scaleFactor);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(bkg, 0, 0, paint);
    overlay = FastBlur.doBlur(overlay, (int) radius, true);
    Log.w("test", "cost " + (System.currentTimeMillis() - startMs) + "ms");
    return overlay;
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:18,代码来源:FastBlur.java

示例15: toRound

import android.graphics.Paint; //导入依赖的package包/类
/**
 * 转为圆形图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 圆形图片
 */
public static Bitmap toRound(final Bitmap src, final boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:25,代码来源:ImageUtils.java


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