package com.itant.joycity.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.itant.joycity.R;
import com.itant.joycity.tool.UITool;

/**
 * Created by Jason on 2016/10/10.
 */
public class LadderView extends RelativeLayout {
    private Context context;

    public LadderView(Context context) {
        super(context);
    }

    public LadderView(Context context, AttributeSet attrs) {
        super(context, attrs);

        this.context = context;
        setWillNotDraw(false);
    }

    public LadderView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }



    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        /*设置背景为白色*/
        canvas.drawColor(Color.TRANSPARENT);
        Paint paint=new Paint();
          /*去锯齿*/
        paint.setAntiAlias(true);


          /*设置paint 的style为 FILL：实心*/
        paint.setStyle(Paint.Style.FILL);
          /*设置paint的颜色*/
        paint.setColor(context.getResources().getColor(R.color.red_dark));

          /*画一个实心长方形*/
        //canvas.drawRect(90, 170, 150,200, paint);

          /*画一个实心梯形*/
        Path path=new Path();
        path.moveTo(0, 0);
        path.lineTo(0, UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 90),UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 75), 0);
        path.close();
        canvas.drawPath(path, paint);

        path.moveTo(UITool.dpToPx(context, 95), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 100), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 85),0);
        path.lineTo(UITool.dpToPx(context, 80), 0);
        path.close();
        canvas.drawPath(path, paint);

        path.moveTo(UITool.dpToPx(context, 105), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 110), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 95),0);
        path.lineTo(UITool.dpToPx(context, 90), 0);
        path.close();
        canvas.drawPath(path, paint);

        path.moveTo(UITool.dpToPx(context, 115), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 120), UITool.dpToPx(context, 40));
        path.lineTo(UITool.dpToPx(context, 105),0);
        path.lineTo(UITool.dpToPx(context, 100), 0);
        path.close();
        canvas.drawPath(path, paint);
    }
}
