android.graphics.Paint#clearShadowLayer ( )源码实例Demo

下面列出了android.graphics.Paint#clearShadowLayer ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
源代码2 项目: ThermometerView   文件: ThermometerView.java
/**
 * 绘制温度计水银高度
 * 注:须与{@link #drawShape(Paint, Canvas)}方法结合
 *
 * @param shapePaint Paint
 * @param canvas     Canvas
 */
private void drawWaveShape(Paint shapePaint, Canvas canvas) {
    float waveTop = mPaddingTop + titleHeight + minThermometerRadius
            + (maxScaleValue - curScaleValue) * 10 * scaleSpaceHeight;

    shapePaint.setColor(leftMercuryColor);
    shapePaint.clearShadowLayer();
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));

    canvas.drawRect(leftWaveLeft, waveTop, leftWaveRight, waveBottom, shapePaint);

    shapePaint.setColor(rightMercuryColor);
    shapePaint.clearShadowLayer();

    canvas.drawRect(rightWaveLeft, waveTop, rightWaveRight, waveBottom, shapePaint);
}
 
源代码3 项目: AndroidMathKeyboard   文件: ShadowBox.java
public void draw(Canvas g2, float x, float y) {
	float th = thickness / 2;
	box.draw(g2, x + space + thickness, y);
	Paint st = AjLatexMath.getPaint();
	float w = st.getStrokeWidth();
	int c = st.getColor();
	Style s = st.getStyle();
	st.setStrokeWidth(thickness);
	st.setStyle(Style.STROKE);
	float penth = 0;// (float) Math.abs(1 / g2.getTransform().getScaleX());
	g2.drawRect(x + th, y - height + th, x + th + width - shadowRule
			- thickness, y + th + depth - shadowRule - thickness, st);
	st.setStyle(Style.FILL);
	g2.drawRect(x + shadowRule - penth, y + depth - shadowRule - penth, x
			- penth + width, y + depth - penth, st);
	g2.drawRect(x + width - shadowRule - penth, y - height + th
			+ shadowRule, x + width - penth, y + shadowRule + depth - 2
			* shadowRule, st);

	st.setColor(c);
	st.setStrokeWidth(w);
	st.setStyle(s);
	st.clearShadowLayer();

}
 
源代码4 项目: LaunchEnr   文件: WidgetPreviewLoader.java
private RectF drawBoxWithShadow(Canvas c, Paint p, int width, int height) {
    Resources res = mContext.getResources();
    float shadowBlur = res.getDimension(R.dimen.widget_preview_shadow_blur);
    float keyShadowDistance = res.getDimension(R.dimen.widget_preview_key_shadow_distance);
    float corner = res.getDimension(R.dimen.widget_preview_corner_radius);

    RectF bounds = new RectF(shadowBlur, shadowBlur,
            width - shadowBlur, height - shadowBlur - keyShadowDistance);
    p.setColor(Color.WHITE);

    // Key shadow
    p.setShadowLayer(shadowBlur, 0, keyShadowDistance,
            ShadowGenerator.KEY_SHADOW_ALPHA << 24);
    c.drawRoundRect(bounds, corner, corner, p);

    // Ambient shadow
    p.setShadowLayer(shadowBlur, 0, 0,
            ColorUtils.setAlphaComponent(Color.BLACK, ShadowGenerator.AMBIENT_SHADOW_ALPHA));
    c.drawRoundRect(bounds, corner, corner, p);

    p.clearShadowLayer();
    return bounds;
}
 
源代码5 项目: simple-keyboard   文件: MainKeyboardView.java
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
源代码6 项目: FlexibleRichTextView   文件: ShadowBox.java
public void draw(Canvas g2, float x, float y) {
	float th = thickness / 2;
	box.draw(g2, x + space + thickness, y);
	Paint st = AjLatexMath.getPaint();
	float w = st.getStrokeWidth();
	int c = st.getColor();
	Style s = st.getStyle();
	st.setStrokeWidth(thickness);
	st.setStyle(Style.STROKE);
	float penth = 0;// (float) Math.abs(1 / g2.getTransform().getScaleX());
	g2.drawRect(x + th, y - height + th, x + th + width - shadowRule
			- thickness, y + th + depth - shadowRule - thickness, st);
	st.setStyle(Style.FILL);
	g2.drawRect(x + shadowRule - penth, y + depth - shadowRule - penth, x
			- penth + width, y + depth - penth, st);
	g2.drawRect(x + width - shadowRule - penth, y - height + th
			+ shadowRule, x + width - penth, y + shadowRule + depth - 2
			* shadowRule, st);

	st.setColor(c);
	st.setStrokeWidth(w);
	st.setStyle(s);
	st.clearShadowLayer();

}
 
源代码7 项目: openboard   文件: MainKeyboardView.java
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
源代码8 项目: ThermometerView   文件: ThermometerView.java
/**
 * 绘制温度计形状
 *
 * @param shapePaint Paint
 * @param canvas     Canvas
 */
private void drawShapeBg(Paint shapePaint, Canvas canvas) {
    shapePaint.setColor(thermometerBg);
    shapePaint.setShadowLayer(8, 0, 0, thermometerShadowBg);

    canvas.drawCircle(thermometerTopX, thermometerTopY, minThermometerRadius, shapePaint);
    canvas.drawCircle(thermometerBottomX, thermometerBottomY, maxThermometerRadius, shapePaint);
    canvas.drawRect(thermometerRectF, shapePaint);

    /* 以下三句是为了去除部分不需要的阴影 */
    shapePaint.clearShadowLayer();
    canvas.drawCircle(thermometerTopX, thermometerTopY, minThermometerRadius, shapePaint);
    canvas.drawCircle(thermometerBottomX, thermometerBottomY, maxThermometerRadius, shapePaint);
}
 
源代码9 项目: grblcontroller   文件: CustomTypefaceSpan.java
private void applyCustomTypeFace(Paint paint, Typeface tf) {
    paint.setFakeBoldText(false);
    paint.setTextSkewX(0f);
    paint.setTypeface(tf);
    if (rotate) paint.clearShadowLayer();
    if (iconSizeRatio > 0) paint.setTextSize(paint.getTextSize() * iconSizeRatio);
    else if (iconSizePx > 0) paint.setTextSize(iconSizePx);
    if (iconColor < Integer.MAX_VALUE) paint.setColor(iconColor);
}
 
源代码10 项目: AOSP-Kayboard-7.1.2   文件: MainKeyboardView.java
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
源代码11 项目: edx-app-android   文件: CustomTypefaceSpan.java
private void applyCustomTypeFace(@NonNull Paint paint, @NonNull Typeface tf) {
    paint.setFakeBoldText(false);
    paint.setTextSkewX(0f);
    paint.setTypeface(tf);
    if (animation != Animation.NONE) paint.clearShadowLayer();
    if (iconSizeRatio > 0) paint.setTextSize(paint.getTextSize() * iconSizeRatio);
    else if (iconSizePx > 0) paint.setTextSize(iconSizePx);
    if (iconColor < Integer.MAX_VALUE) paint.setColor(iconColor);
}
 
源代码12 项目: Indic-Keyboard   文件: MainKeyboardView.java
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
源代码13 项目: ThermometerView   文件: ThermometerView.java
/**
 * 绘制水银形状
 * 注:须与{@link #drawWaveShape(Paint, Canvas)}方法结合
 *
 * @param shapePaint Paint
 * @param canvas     Canvas
 */
private void drawShape(Paint shapePaint, Canvas canvas) {
    shapePaint.clearShadowLayer();

    shapePaint.setColor(leftMercuryBg);
    canvas.drawArc(mercuryRectF, 90, 180, true, shapePaint);

    canvas.drawRect(leftMercuryLeft, mercuryTop, leftMercuryRight, mercuryBottom, shapePaint);

    shapePaint.setColor(rightMercuryBg);
    canvas.drawArc(mercuryRectF, -90, 180, true, shapePaint);

    canvas.drawRect(rightMercuryLeft, mercuryTop, rightMercuryRight, mercuryBottom, shapePaint);

    canvas.drawCircle(thermometerBottomX, thermometerBottomY, maxMercuryRadius, shapePaint);

}
 
源代码14 项目: Eye-blink-detector   文件: OverlayView.java
public OverlayView(CameraActivity captureActivity, AttributeSet attributeSet, boolean showTorch) {
    super(captureActivity, attributeSet);

    mShowTorch = showTorch;
    mScanActivityRef = new WeakReference<CameraActivity>(captureActivity);

    mRotationFlip = 1;

    // card.io is designed for an hdpi screen (density = 1.5);
    mScale = getResources().getDisplayMetrics().density / 1.5f;


    mGuidePaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mLockedBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLockedBackgroundPaint.clearShadowLayer();
    mLockedBackgroundPaint.setStyle(Paint.Style.FILL);
    mLockedBackgroundPaint.setColor(0xbb000000); // 75% black

}