package com.codegym.task.task24.task2413;

public class Canvas {

    private int width;
    private int height;


    private char[][] matrix;


    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public char[][] getMatrix() {
        return matrix;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public void setMatrix(char[][] matrix) {
        this.matrix = matrix;
    }

    public Canvas(int width, int height){
        this.width = width;
        this.height = height;
        this.matrix = new char[height+2][width+2];
    }

    public void setPoint(double x, double y, char c){
        int ix = (int) Math.round(x);
        int iy =(int) Math.round(y);
        if( x < 0 || y < 0 || y >= matrix.length || x >= matrix[0].length){
//            do Nothing
        }else
            matrix[iy][ix] = c;
    }

    public void drawMatrix(double x, double y, int[][] matrix, char c){
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] != 0) {
                    setPoint(x + j, y + i, c);
                }
            }
        }
    }

    public void clear(){
        matrix = new char[height+2][width+2];
    }
    public void print(){
        for(int i = 0; i < matrix.length; i++){
            for(int j = 0; j < matrix[0].length; j++){
                System.out.println(matrix[j][i]);
            }
        }

    }

}