package fr.iutfbleau.liste;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class Carre extends View {

    private float x1;
    private float y1;
    private float x2;
    private float y2;
    private final Paint peinture;

    public Carre(Context c, AttributeSet s) {
        super(c, s);
        this.x1 = 0;
        this.y1 = 0;
        this.x2 = 0;
        this.y2 = 0;
        this.peinture = new Paint();
        this.peinture.setStrokeWidth(40f);
        this.peinture.setColor(0xffff0000);
        this.peinture.setStyle(Paint.Style.STROKE);
    }

    @Override
    protected void onDraw(Canvas c) {
        super.onDraw(c);
        c.drawRect(x1, y1, x2, y2, this.peinture);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        this.x1 = 0;
        this.y1 = 0;
        this.x2 = w;
        this.y2 = h;
    }
}

