Java Code Examples for android.graphics.Paint#clearShadowLayer()
The following examples show how to use
android.graphics.Paint#clearShadowLayer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainKeyboardView.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: ThermometerView.java From ThermometerView with MIT License | 6 votes |
/** * 绘制温度计水银高度 * 注:须与{@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); }
Example 3
Source File: ShadowBox.java From AndroidMathKeyboard with Apache License 2.0 | 6 votes |
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(); }
Example 4
Source File: WidgetPreviewLoader.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: MainKeyboardView.java From simple-keyboard with Apache License 2.0 | 6 votes |
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); }
Example 6
Source File: ShadowBox.java From FlexibleRichTextView with Apache License 2.0 | 6 votes |
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(); }
Example 7
Source File: MainKeyboardView.java From openboard with GNU General Public License v3.0 | 5 votes |
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); }
Example 8
Source File: ThermometerView.java From ThermometerView with MIT License | 5 votes |
/** * 绘制温度计形状 * * @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); }
Example 9
Source File: CustomTypefaceSpan.java From grblcontroller with GNU General Public License v3.0 | 5 votes |
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); }
Example 10
Source File: MainKeyboardView.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
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); }
Example 11
Source File: CustomTypefaceSpan.java From edx-app-android with Apache License 2.0 | 5 votes |
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); }
Example 12
Source File: MainKeyboardView.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
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); }
Example 13
Source File: ThermometerView.java From ThermometerView with MIT License | 4 votes |
/** * 绘制水银形状 * 注:须与{@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); }
Example 14
Source File: OverlayView.java From Eye-blink-detector with MIT License | 4 votes |
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 }