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


Java TileMode类代码示例

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


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

示例1: createColorWheelBitmap

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[] { 0f, 1f, 1f };
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
 
开发者ID:MLNO,项目名称:airgram,代码行数:27,代码来源:ColorPicker.java

示例2: createColorDiscBitmap

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private Bitmap createColorDiscBitmap(int radius) {
    int centerColor, edgeColor;
    Bitmap bitmap = Bitmap.createBitmap(2 * radius, 2 * radius, Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);
    mHSV[0] = 0; mHSV[1] = 1; mHSV[2] = 1;   //red
    SweepGradient sweepGradient = new SweepGradient(radius, radius, getColors(mHSV), null);
    mColorPaint.setShader(sweepGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    mHSV[0] = 0; mHSV[1] = 0; mHSV[2] = 1;   //white
    centerColor = Color.HSVToColor(255, mHSV);
    edgeColor = Color.HSVToColor(0, mHSV);
    RadialGradient radialGradient = new RadialGradient(radius, radius, radius, centerColor, edgeColor, TileMode.CLAMP);
    mColorPaint.setShader(radialGradient);
    canvas.drawCircle(radius, radius, radius, mColorPaint);

    return bitmap;
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:20,代码来源:ColorPicker.java

示例3: drawColorSquare

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private void drawColorSquare(Canvas canvas) {
    int pureColor, brightColor, darkColor, transparentColor;

    // pureColor
    mHSV[0] = mColorHSV[0];
    mHSV[1] = 1; mHSV[2] = 1;
    pureColor = Color.HSVToColor(mHSV);
    // brightColor
    mHSV[1] = 0; mHSV[2] = 1;
    brightColor = Color.HSVToColor(mHSV);
    // darkColor
    mHSV[1] = 1; mHSV[2] = 0;
    darkColor = Color.HSVToColor(255, mHSV);
    // alphaColor
    mHSV[1] = 0; mHSV[2] = 0;
    transparentColor = Color.HSVToColor(0, mHSV);

    // drawn without compose shader, but looks worse
    Shader gradient1 = new LinearGradient(mSquareRect.right, mSquareRect.bottom, mSquareRect.right, mSquareRect.top, brightColor, pureColor, TileMode.CLAMP);
    Shader gradient2 = new LinearGradient(mSquareRect.right, mSquareRect.bottom, mSquareRect.left, mSquareRect.bottom, transparentColor, darkColor, TileMode.CLAMP);

    mColorPaint.setShader(gradient1);
    canvas.drawRect(mSquareRect, mColorPaint);
    mColorPaint.setShader(gradient2);
    canvas.drawRect(mSquareRect, mColorPaint);
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:27,代码来源:ColorPicker.java

示例4: transform

import android.graphics.Shader.TileMode; //导入依赖的package包/类
public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());
    Bitmap squaredBitmap = Bitmap.createBitmap(source, (source.getWidth() - size) / 2, (source.getHeight() - size) / 2, size, size);
    if (squaredBitmap != source) {
        source.recycle();
    }
    Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setShader(new BitmapShader(squaredBitmap, TileMode.CLAMP, TileMode.CLAMP));
    paint.setAntiAlias(true);
    float r = ((float) size) / 2.0f;
    canvas.drawCircle(r, r, r, paint);
    squaredBitmap.recycle();
    return bitmap;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:17,代码来源:CircleTransform.java

示例5: setup

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private void setup() {
    if (!this.mReady) {
        this.mSetupPending = true;
    } else if (this.mBitmap != null) {
        this.mBitmapShader = new BitmapShader(this.mBitmap, TileMode.CLAMP, TileMode.CLAMP);
        this.mBitmapPaint.setAntiAlias(true);
        this.mBitmapPaint.setShader(this.mBitmapShader);
        this.mBorderPaint.setStyle(Style.STROKE);
        this.mBorderPaint.setAntiAlias(true);
        this.mBorderPaint.setColor(this.mBorderColor);
        this.mBorderPaint.setStrokeWidth((float) this.mBorderWidth);
        this.mBitmapHeight = this.mBitmap.getHeight();
        this.mBitmapWidth = this.mBitmap.getWidth();
        this.mBorderRect.set(0.0f, 0.0f, (float) getWidth(), (float) getHeight());
        this.mBorderRadius = Math.min((this.mBorderRect.height() - ((float) this.mBorderWidth)) / 2.0f, (this.mBorderRect.width() - ((float) this.mBorderWidth)) / 2.0f);
        this.mDrawableRect.set((float) this.mBorderWidth, (float) this.mBorderWidth, this.mBorderRect.width() - ((float) this.mBorderWidth), this.mBorderRect.height() - ((float) this.mBorderWidth));
        this.mDrawableRadius = Math.min(this.mDrawableRect.height() / 2.0f, this.mDrawableRect.width() / 2.0f);
        updateShaderMatrix();
        invalidate();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:CircleImageView.java

示例6: CircleDrawable

import android.graphics.Shader.TileMode; //导入依赖的package包/类
public CircleDrawable(Bitmap bitmap, Integer strokeColor, float strokeWidth) {
    this.radius = (float) (Math.min(bitmap.getWidth(), bitmap.getHeight()) / 2);
    this.bitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    this.mBitmapRect = new RectF(0.0f, 0.0f, (float) bitmap.getWidth(), (float) bitmap
            .getHeight());
    this.paint = new Paint();
    this.paint.setAntiAlias(true);
    this.paint.setShader(this.bitmapShader);
    this.paint.setFilterBitmap(true);
    this.paint.setDither(true);
    if (strokeColor == null) {
        this.strokePaint = null;
    } else {
        this.strokePaint = new Paint();
        this.strokePaint.setStyle(Style.STROKE);
        this.strokePaint.setColor(strokeColor.intValue());
        this.strokePaint.setStrokeWidth(strokeWidth);
        this.strokePaint.setAntiAlias(true);
    }
    this.strokeWidth = strokeWidth;
    this.strokeRadius = this.radius - (strokeWidth / 2.0f);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:CircleBitmapDisplayer.java

示例7: SelectableRoundedCornerDrawable

import android.graphics.Shader.TileMode; //导入依赖的package包/类
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    this.mBitmap = bitmap;
    this.mBitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    if (bitmap != null) {
        this.mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        this.mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        this.mBitmapHeight = -1;
        this.mBitmapWidth = -1;
    }
    this.mBitmapRect.set(0.0f, 0.0f, (float) this.mBitmapWidth, (float) this.mBitmapHeight);
    this.mBitmapPaint = new Paint(1);
    this.mBitmapPaint.setStyle(Style.FILL);
    this.mBitmapPaint.setShader(this.mBitmapShader);
    this.mBorderPaint = new Paint(1);
    this.mBorderPaint.setStyle(Style.STROKE);
    this.mBorderPaint.setColor(this.mBorderColor.getColorForState(getState(), -16777216));
    this.mBorderPaint.setStrokeWidth(this.mBorderWidth);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:SelectableRoundedImageView.java

示例8: buildShadowCorners

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius, -this.mCornerRadius, this.mCornerRadius, this.mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-this.mShadowSize, -this.mShadowSize);
    if (this.mCornerShadowPath == null) {
        this.mCornerShadowPath = new Path();
    } else {
        this.mCornerShadowPath.reset();
    }
    this.mCornerShadowPath.setFillType(FillType.EVEN_ODD);
    this.mCornerShadowPath.moveTo(-this.mCornerRadius, 0.0f);
    this.mCornerShadowPath.rLineTo(-this.mShadowSize, 0.0f);
    this.mCornerShadowPath.arcTo(outerBounds, 180.0f, 90.0f, false);
    this.mCornerShadowPath.arcTo(innerBounds, 270.0f, -90.0f, false);
    this.mCornerShadowPath.close();
    float startRatio = this.mCornerRadius / (this.mCornerRadius + this.mShadowSize);
    this.mCornerShadowPaint.setShader(new RadialGradient(0.0f, 0.0f, this.mCornerRadius + this.mShadowSize, new int[]{this.mShadowStartColor, this.mShadowStartColor, this.mShadowEndColor}, new float[]{0.0f, startRatio, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f, (-this.mCornerRadius) + this.mShadowSize, 0.0f, (-this.mCornerRadius) - this.mShadowSize, new int[]{this.mShadowStartColor, this.mShadowStartColor, this.mShadowEndColor}, new float[]{0.0f, 0.5f, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:RoundRectDrawableWithShadow.java

示例9: buildShadowCorners

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private void buildShadowCorners() {
    RectF innerBounds = new RectF(-this.mCornerRadius, -this.mCornerRadius, this.mCornerRadius, this.mCornerRadius);
    RectF outerBounds = new RectF(innerBounds);
    outerBounds.inset(-this.mShadowSize, -this.mShadowSize);
    if (this.mCornerShadowPath == null) {
        this.mCornerShadowPath = new Path();
    } else {
        this.mCornerShadowPath.reset();
    }
    this.mCornerShadowPath.setFillType(FillType.EVEN_ODD);
    this.mCornerShadowPath.moveTo(-this.mCornerRadius, 0.0f);
    this.mCornerShadowPath.rLineTo(-this.mShadowSize, 0.0f);
    this.mCornerShadowPath.arcTo(outerBounds, 180.0f, 90.0f, false);
    this.mCornerShadowPath.arcTo(innerBounds, 270.0f, -90.0f, false);
    this.mCornerShadowPath.close();
    float shadowRadius = -outerBounds.top;
    if (shadowRadius > 0.0f) {
        float startRatio = this.mCornerRadius / shadowRadius;
        float midRatio = startRatio + ((1.0f - startRatio) / 2.0f);
        this.mCornerShadowPaint.setShader(new RadialGradient(0.0f, 0.0f, shadowRadius, new int[]{0, this.mShadowStartColor, this.mShadowMiddleColor, this.mShadowEndColor}, new float[]{0.0f, startRatio, midRatio, 1.0f}, TileMode.CLAMP));
    }
    this.mEdgeShadowPaint.setShader(new LinearGradient(0.0f, innerBounds.top, 0.0f, outerBounds.top, new int[]{this.mShadowStartColor, this.mShadowMiddleColor, this.mShadowEndColor}, new float[]{0.0f, SHADOW_HORIZ_SCALE, 1.0f}, TileMode.CLAMP));
    this.mEdgeShadowPaint.setAntiAlias(false);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:ShadowDrawableWrapper.java

示例10: setBitmapShader

import android.graphics.Shader.TileMode; //导入依赖的package包/类
/**
 * 设置BitmapShader
 */
private void setBitmapShader() {
    Drawable drawable = getDrawable();
    if (null == drawable) {
        return;
    }
    Bitmap bitmap = drawableToBitmap(drawable);
    // 将bitmap作为着色器来创建一个BitmapShader
    mBitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    float scale = 1.0f;
    if (mType == TYPE_CIRCLE) {
        // 拿到bitmap宽或高的小值
        int bSize = Math.min(bitmap.getWidth(), bitmap.getHeight());
        scale = mWidth * 1.0f / bSize;

    } else if (mType == TYPE_ROUND || mType == TYPE_OVAL) {
        // 如果图片的宽或者高与view的宽高不匹配,计算出需要缩放的比例;缩放后的图片的宽高,一定要大于我们view的宽高;所以我们这里取大值;
        scale = Math.max(getWidth() * 1.0f / bitmap.getWidth(), getHeight() * 1.0f / bitmap.getHeight());
    }
    // shader的变换矩阵,我们这里主要用于放大或者缩小
    mMatrix.setScale(scale, scale);
    // 设置变换矩阵
    mBitmapShader.setLocalMatrix(mMatrix);
    mPaint.setShader(mBitmapShader);

}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:29,代码来源:ZQRoundOvalImageView.java

示例11: onDraw

import android.graphics.Shader.TileMode; //导入依赖的package包/类
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas)
{
	super.onDraw(canvas);
	int width  = getMeasuredWidth();
	int height = getMeasuredHeight();

	int new_color = Color.HSVToColor(hsv);
	if(color != new_color)
	{
		Shader shader_x = new LinearGradient(0.0F, 0.0F, width, 0.0F, Color.WHITE, new_color, TileMode.CLAMP);
		
		ComposeShader shader = new ComposeShader(shader_y, shader_x, PorterDuff.Mode.MULTIPLY);
		paint.setShader(shader);
		
		color = new_color;
	}
	canvas.drawRect(0.0F, 0.0F, width, height, paint);
}
 
开发者ID:KAlO2,项目名称:PerfectShow,代码行数:21,代码来源:ColorPickerCircle.java

示例12: createColorWheelBitmap

import android.graphics.Shader.TileMode; //导入依赖的package包/类
private Bitmap createColorWheelBitmap(int width, int height) {

        Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);

        int colorCount = 12;
        int colorAngleStep = 360 / 12;
        int colors[] = new int[colorCount + 1];
        float hsv[] = new float[]{0f, 1f, 1f};
        for (int i = 0; i < colors.length; i++) {
            hsv[0] = (i * colorAngleStep + 180) % 360;
            colors[i] = Color.HSVToColor(hsv);
        }
        colors[colorCount] = colors[0];

        SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
        RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
        ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);

        colorWheelPaint.setShader(composeShader);

        Canvas canvas = new Canvas(bitmap);
        canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

        return bitmap;

    }
 
开发者ID:mercadopago,项目名称:px-android,代码行数:27,代码来源:ColorPicker.java

示例13: onDraw

import android.graphics.Shader.TileMode; //导入依赖的package包/类
@Override
protected void onDraw(final Canvas canvas) {
	super.onDraw(canvas);

	if (this.paint == null) {
		this.paint = new Paint();
		this.luar = new LinearGradient(0.f, 0.f, 0.f, this.ukuranUiPx, 0xffffffff, 0xff000000,
				TileMode.CLAMP);
	}

	this.tmp00[1] = this.tmp00[2] = 1.f;
	this.tmp00[0] = this.hue;
	int rgb = Color.HSVToColor(this.tmp00);

	this.dalam = new LinearGradient(0.f, 0.f, this.ukuranUiPx, 0.f, 0xffffffff, rgb,
			TileMode.CLAMP);
	ComposeShader shader = new ComposeShader(this.luar, this.dalam, PorterDuff.Mode.MULTIPLY);

	this.paint.setShader(shader);

	canvas.drawRect(0.f, 0.f, this.ukuranUiPx, this.ukuranUiPx, this.paint);
}
 
开发者ID:andrewxu10,项目名称:Upkeep,代码行数:23,代码来源:AmbilWarnaKotak.java

示例14: createReflectedImage

import android.graphics.Shader.TileMode; //导入依赖的package包/类
/**
 * 全倒影
 * 
 * @param originalImage
 * @return
 */
public static Bitmap createReflectedImage(Bitmap originalImage, int imageHeight) {
	int width = originalImage.getWidth();
	int height = originalImage.getHeight();
	Matrix matrix = new Matrix();
	matrix.preScale(1, -1);
	Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height - imageHeight, width, imageHeight, matrix, false);
	Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + imageHeight), Config.ARGB_8888);
	Canvas canvas = new Canvas(bitmapWithReflection);
	Paint defaultpPaint = new Paint();
	canvas.drawBitmap(originalImage, 0, 0, defaultpPaint);
	canvas.drawBitmap(reflectionImage, 0, height, defaultpPaint);
	Paint paint = new Paint();
	LinearGradient shader = new LinearGradient(0, originalImage.getHeight(), 0, bitmapWithReflection.getHeight(), 0x70ffffff, 0x00ffffff, TileMode.MIRROR);
	paint.setShader(shader);
	paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
	canvas.drawRect(0, height, width, bitmapWithReflection.getHeight(), paint);
	reflectionImage.recycle();
	return bitmapWithReflection;
}
 
开发者ID:imknown,项目名称:IMKBaseFrameworkLibrary,代码行数:26,代码来源:Reflect3DImage.java

示例15: setUpShader

import android.graphics.Shader.TileMode; //导入依赖的package包/类
/**
 * 初始化BitmapShader
 */
private void setUpShader()
{
	Drawable drawable = getDrawable();
	if (drawable == null)
	{
		Log.e("view", "ok");
		return;
	}

	Bitmap bmp = drawableToBitamp(drawable);
	// 将bmp作为着色器,就是在指定区域内绘制bmp
	mBitmapShader = new BitmapShader(bmp, TileMode.CLAMP, TileMode.CLAMP);
	float scale = 1.0f;
	int bSize = Math.min(bmp.getWidth(), bmp.getHeight());
	scale = getWidth() * 1.0f / bSize;
	// shader的变换矩阵,我们这里主要用于放大或者缩小
	matrix.setScale(scale, scale);
	// 设置变换矩阵
	mBitmapShader.setLocalMatrix(matrix);
	// 设置shader
	paint.setShader(mBitmapShader);
}
 
开发者ID:liudabao,项目名称:Evisa,代码行数:26,代码来源:CircleView.java


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