본문 바로가기

Android

셰이더 - 스윕 그래디언트 SweepGradient

package com.example.viewex01;

 

import android.content.Context;

 

import android.content.res.Resources;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Canvas;

import android.graphics.Color;

import android.graphics.LinearGradient;

import android.graphics.Paint;

import android.graphics.Path;

import android.graphics.RadialGradient;

import android.graphics.RectF;

import android.graphics.Shader.TileMode;

import android.graphics.SweepGradient;

import android.graphics.Typeface;

import android.view.View;

 

public class MyView15 extends View {

    

    

     public MyView15(Context context) {

           super(context);

           // TODO Auto-generated constructor stub

          

          

     }

 

     @Override

     public void onDraw(Canvas canvas) {

           Paint Pnt= new Paint();

           Pnt.setAntiAlias(true);

           int[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW, Color.WHITE};

           float[] pos = { 0.0f, 0.1f, 0.6f, 0.9f, 1.0f };

           // 파란색흰색

           Pnt.setShader(new SweepGradient(80, 80, Color.BLUE, Color.WHITE));

           canvas.drawCircle(80, 80, 70, Pnt);

           // 흰색파란색

           Pnt.setShader(new SweepGradient(230, 80, Color.WHITE, Color.BLUE));

           canvas.drawCircle(230, 80, 70, Pnt);

           // 여러가지색균등

           Pnt.setShader(new SweepGradient(80, 230, colors, null));

           canvas.drawCircle(80, 230, 70, Pnt);

           // 여러가지색차등

           Pnt.setShader(new SweepGradient(230, 230, colors, pos));

           canvas.drawCircle(230, 230, 70, Pnt);

           }

 

}




 

'Android' 카테고리의 다른 글

메뉴(menu) - 옵션 메뉴  (0) 2013.03.29
셰이더 - ShapeDrawable  (0) 2013.03.29
셰이더 - 원형 그래디언트 RadialGradient  (0) 2013.03.29
셰이더 - 직선 그래디언트 LinearGradient  (0) 2013.03.29
그리기 객체 - Path  (0) 2013.03.29