本文整理汇总了Java中android.graphics.Paint.ANTI_ALIAS_FLAG属性的典型用法代码示例。如果您正苦于以下问题:Java Paint.ANTI_ALIAS_FLAG属性的具体用法?Java Paint.ANTI_ALIAS_FLAG怎么用?Java Paint.ANTI_ALIAS_FLAG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.ANTI_ALIAS_FLAG属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RadarView
public RadarView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context,attrs);
mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBgPaint.setColor(mRadarBackGroundColor);
mBgPaint.setStyle(Paint.Style.FILL);
mRadarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRadarPaint.setColor(mRadarCircleColor);
mRadarPaint.setStyle(Paint.Style.STROKE);
mRadarPaint.setStrokeWidth(2);
mRadarGradient = new SweepGradient(0,0,mRadarStartColor,mRadarEndColor);
mMatrix = new Matrix();
}
示例2: initPaintObjects
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();
}
}
示例3: addImageWatermark
/**
* 添加图片水印
*
* @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;
}
示例4: init
private void init(Context context, AttributeSet attrs) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TickView);
mStrokeWidth = typedArray.getDimensionPixelSize(R.styleable.TickView_tv_strokeWidth, 0);
int color = typedArray.getColor(R.styleable.TickView_tv_color, Color.RED);
mPercent = typedArray.getFloat(R.styleable.TickView_tv_percent, 0f);
typedArray.recycle();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setColor(color);
mTickPath = new Path();
mArcRect = new RectF();
mTickPoints = new Point[3];
mTickPoints[0] = new Point();
mTickPoints[1] = new Point();
mTickPoints[2] = new Point();
}
示例5: init
private void init() {
mLinePath = new Path();
mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mLinePaint.setColor(0xFFF90382);
mLinePaint.setStyle(Paint.Style.STROKE);
mLinePaint.setStrokeWidth(10.0f);
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mTextPaint.setColor(Color.WHITE);
mTextPaint.setTextSize(Util.sp2px(mContext, 13.0f));
mBubblePaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
mBubblePaint.setColor(0xFF3B4DEC);
mBubblePath = new Path();
mBubbleRect = new RectF();
}
示例6: drawTextToDrawable
public Bitmap drawTextToDrawable(@DrawableRes int resId, String text, int textSize) {
Resources resources = _context.getResources();
float scale = resources.getDisplayMetrics().density;
Bitmap bitmap = getBitmapFromDrawable(resId);
bitmap = bitmap.copy(bitmap.getConfig(), true);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.rgb(61, 61, 61));
paint.setTextSize((int) (textSize * scale));
paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);
Rect bounds = new Rect();
paint.getTextBounds(text, 0, text.length(), bounds);
int x = (bitmap.getWidth() - bounds.width()) / 2;
int y = (bitmap.getHeight() + bounds.height()) / 2;
canvas.drawText(text, x, y, paint);
return bitmap;
}
示例7: initView
/**
* 进行一些初始化的操作
*/
private void initView() {
//初始化画笔,路径
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStrokeWidth(8);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.BLACK);
mPath = new Path();
mRandom = new Random();
//获取资源图片转化Bitmap(不可修改)
mBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.icon_star);
setOnClickListener(this);
}
示例8: init
private void init(Context context, boolean isSelected ,@ColorInt int color){
//Set circle size
currentSize = context.getResources().getDimensionPixelSize(R.dimen.schedule_item_size);
//Set circle color
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
if(!isInEditMode()) {
mPaint.setColor(isSelected ? color : ContextCompat.getColor(context, R.color.week_picker_inactive));
}
}
示例9: calculation
private void calculation() {
if (mShowDebug) {
fpsPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
fpsPaint.setColor(Color.YELLOW);
fpsPaint.setTextSize(20);
times = new LinkedList<>();
lines = new LinkedList<>();
}
initChannelMap();
initChannelY();
}
示例10: updateProgressColor
/**
* updates the paint of the progress and the thumb to give them a new visual style
*/
private void updateProgressColor() {
mProgressColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mProgressColorPaint.setColor(mProgressColor);
mProgressColorPaint.setStyle(Paint.Style.STROKE);
mProgressColorPaint.setStrokeWidth(mCircleStrokeWidth);
mThumbColorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mThumbColorPaint.setColor(mProgressColor);
mThumbColorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mThumbColorPaint.setStrokeWidth(mCircleStrokeWidth);
invalidate();
}
示例11: createPaintFromColor
/**
* Returns a paint instance created as per the required specs.
*
* @param color <tt>int</tt> : Color of the paint.
* @param style <tt>Paint.Style></tt> : Style of the paint. Eg - Fill, Stroke, etc.
* @param shadowEnabled <tt>boolean</tt> : Enables shadow for the objects using this paint if
* true.
* @param shadowColor <tt>int</tt> : Color of the shadow if the shadow is enabled.
* @param shadowLength <tt>int</tt> : Length of the shadow in pixels.
* @return paint Paint instance created.
* @see <a href="https://developer.android.com/reference/android/graphics/Paint.Style.html">Paint.Style</a>
*/
static Paint createPaintFromColor(int color, Paint.Style style, boolean shadowEnabled,
int shadowColor, int shadowLength) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(color);
paint.setStyle(style);
paint.setAntiAlias(true);
if (shadowEnabled) {
paint.setShadowLayer(shadowLength, 0, 0, shadowColor);
}
return paint;
}
示例12: PageIndicatorDots
public PageIndicatorDots(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setStyle(Style.FILL);
mDotRadius = getResources().getDimension(R.dimen.page_indicator_dot_size) / 2;
setOutlineProvider(new MyOutlineProver());
mActiveColor = Utilities.getColorAccent(context);
mInActiveColor = getResources().getColor(R.color.page_indicator_dot_color);
mIsRtl = Utilities.isRtl(getResources());
}
示例13: WaveBezier
public WaveBezier(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDarkerPath = new Path();
mLightPath = new Path();
mDarkerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDarkerPaint.setColor(Color.parseColor("#77512DA8"));
mDarkerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mLightPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mLightPaint.setColor(Color.parseColor("#55512DA8"));
mLightPaint.setStyle(Paint.Style.FILL_AND_STROKE);
}
示例14: createSpotBitmap
private Bitmap createSpotBitmap(String data) {
Bitmap bitmap = Bitmap.createBitmap(
(int) mSpotRadius * 2,
(int) mSpotRadius * 2, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.rgb(235, 160, 160));
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStrokeWidth(5);
paint.setTextSize(80);
paint.setColor(Color.BLACK);
canvas.drawText(data, 0, 80, paint);
return bitmap;
}
示例15: init
private void init(Context context, AttributeSet attrs) {
//关闭硬件加速,不然setXfermode()可能会不生效
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (attrs != null) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RectProgress);
bgColor = typedArray.getColor(R.styleable.RectProgress_bgColor, defaultBgColor);
progressColor = typedArray.getColor(R.styleable.RectProgress_progressColor, defaultProgressColor);
progress = typedArray.getInteger(R.styleable.RectProgress_progressValue, progress);
max = typedArray.getInteger(R.styleable.RectProgress_progressMax, max);
if (max <= 0)
throw new RuntimeException("Max 必须大于 0");
orientation = typedArray.getInteger(R.styleable.RectProgress_progressOrientation, VERTICAL);
int imgSrc = typedArray.getResourceId(R.styleable.RectProgress_iconSrc, 0);
iconPadding = typedArray.getDimensionPixelSize(R.styleable.RectProgress_iconPadding, 10);
rectRadius = typedArray.getDimensionPixelSize(R.styleable.RectProgress_rectRadius, 20);
if (max < progress) {
progress = max;
}
typedArray.recycle();
if (imgSrc != 0) {
bitmap = ((BitmapDrawable) getResources().getDrawable(imgSrc)).getBitmap();
}
}
bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
bgPaint.setColor(bgColor);
progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
progressPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
progressPaint.setColor(progressColor);
}