function Blackboard(canvas){
this.socket = io.connect('http://'+window.location.host+'/blackboard');
this.canvas = canvas;
this.ctx = this.canvas[0].getContext("2d");
this.ctxServer = this.canvas[0].getContext("2d");
this.drawing = false;
this.color = 'white';
this.width = 1;
this.colorServer = 'white';
this.widthServer = 1;
this.setEvent();
this.setServerEvent();
this.setShape();
this.color_map.forEach(element => {
$("#pen_color").append($("<option>").attr('value', element).text(element));
});
Array(16).fill(0).forEach((element, index) => {
$("#pen_width").append($("<option>").attr('value', index+1).text(index+1));
});
}
this때문에 존나할맛안나는데 다른방법없음?
그리고 canvas context 두개 따로 못만듬? 저거 this.ctx===this.ctxServer 하니 true쳐나오던데
저래 this 쓰면 브라우저에서 this == window 임
코드를 저렇게도 짤 수 있구나...
new Canvas 해서 쓰니까 잘돌아가던디?
아 new Blackboard
222.111/ 딱 봐도 일반 함수가 아니라 생성자로 쓰겠지