/* Licensed under the Apache License, Version 2.0 (the "License") http://www.apache.org/licenses/LICENSE-2.0 */
var Rect = function(wb, s, sBtn) {
	const rect = Shape(wb, sBtn);
	rect.createShape = function() {
		rect.obj = new fabric.Rect({
			strokeWidth: rect.stroke.width
			, fill: rect.fill.enabled ? rect.fill.color : 'rgba(0,0,0,0)'
			, stroke: rect.stroke.enabled ? rect.stroke.color : 'rgba(0,0,0,0)'
			, opacity: rect.opacity
			, left: rect.orig.x
			, top: rect.orig.y
			, width: 0
			, height: 0
			, omType: 'rect'
		});
		return rect.obj;
	};
	rect.internalActivate = function() {
		ToolUtil.enableAllProps(s, rect);
	};
	rect.updateShape = function(pointer) {
		if (rect.orig.x > pointer.x) {
			rect.obj.set({ left: pointer.x });
		}
		if (rect.orig.y > pointer.y) {
			rect.obj.set({ top: pointer.y });
		}
		rect.obj.set({
			width: Math.abs(rect.orig.x - pointer.x)
			, height: Math.abs(rect.orig.y - pointer.y)
		});
	};
	return rect;
};
