1 /** 
2  * Copyright: Enalye
3  * License: Zlib
4  * Authors: Enalye
5  */
6 module atelier.render.quadview;
7 
8 import atelier.core;
9 
10 import atelier.render.canvas;
11 import atelier.render.texture;
12 import atelier.render.window;
13 /*
14 class QuadView {
15 	Vec2f correction = Vec2f(-.001f, -.001f);
16 
17 	private {
18 		View[4] _views;
19 		Vec2f _position = Vec2f.zero, _size = Vec2f.zero;
20 		Vec2u _renderSize;
21 		ubyte _currentView = 0U;
22 		Color _clearColor = Color.clear;
23 	}
24 
25 	@property {
26 		Vec2u renderSize() const { return _renderSize; }
27 		Vec2u renderSize(Vec2u newRenderSize) {
28 			_renderSize = newRenderSize;
29 			foreach(view; _views)
30 				view.renderSize = _renderSize >> 1u;
31 			return _renderSize;
32 		}
33 
34 		Vec2f size() const { return _size; }
35 		Vec2f size(Vec2f newSize) {
36 			_size = newSize;
37 			foreach(view; _views)
38 				view.size = _size / 2f;
39 			position(_position);
40 			return _size;
41 		}
42 
43 		Vec2f position() const { return _position; }
44 		Vec2f position(Vec2f newPosition) {
45 			_position = newPosition;
46 			Vec2f quarterSize = _size / 4f;
47 			_views[0].position = _position - quarterSize;
48 			_views[1].position = _position + Vec2f(quarterSize.x, -quarterSize.y);
49 			_views[2].position = _position + Vec2f(-quarterSize.x, quarterSize.y);
50 			_views[3].position = _position + quarterSize;
51 			return _position;
52 		}
53 
54 		Color clearColor() const { return _clearColor; }
55 		Color clearColor(Color newColor) {
56 			_clearColor = newColor;
57 			foreach(view; _views)
58 				view.clearColor = _clearColor;
59 			return _clearColor;
60 		}
61 	}
62 
63 	this(Vec2f renderSize) {
64 		this(cast(Vec2u)(renderSize));
65 	}
66 
67 	this(Vec2u renderSize) {
68 		_renderSize = renderSize;
69 		_size = cast(Vec2f)_renderSize;
70 
71 		Vec2u halfSize = _renderSize >> 1U;
72 		foreach(i; 0.. 4)
73 			_views[i] = new View(halfSize);
74 
75 		position(cast(Vec2f)(halfSize));
76 
77 		//Clear all views
78 		foreach(view; _views) {
79 			pushView(view, true);
80 			popView();
81 		}
82 	}
83 
84 	const (View) getCurrent() const {
85 		return _views[_currentView];
86 	}
87 
88 	void advance() {
89 		_currentView ++;
90 		if(_currentView > 3U)
91 			_currentView = 0U;
92 	}
93 
94 	void setColorMod(const Color color, Blend blend = Blend.AlphaBlending) {
95 		foreach(view; _views)
96 			view.setColorMod(color, blend);
97 	}
98 
99 	void draw(const Vec2f renderPosition) {
100 		Vec2f quarterSize = cast(Vec2f)(_renderSize >> 2u) + correction;
101 		_views[0].draw(renderPosition - quarterSize);
102 		_views[1].draw(renderPosition + Vec2f(quarterSize.x, -quarterSize.y));
103 		_views[2].draw(renderPosition + Vec2f(-quarterSize.x, quarterSize.y));
104 		_views[3].draw(renderPosition + quarterSize);
105 	}
106 
107 	void draw(const Vec2f renderPosition, const Vec2f scale) const {
108 		Vec2f quarterSize = cast(Vec2f)(_renderSize >> 2u) + correction;
109 		_views[0].draw(renderPosition - quarterSize, scale);
110 		_views[1].draw(renderPosition + Vec2f(quarterSize.x, -quarterSize.y), scale);
111 		_views[2].draw(renderPosition + Vec2f(-quarterSize.x, quarterSize.y), scale);
112 		_views[3].draw(renderPosition + quarterSize, scale);
113 	}
114 }*/