olcPixelGameEngine v2.29
The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects
Loading...
Searching...
No Matches
olcPGEX_TransformedView.h
Go to the documentation of this file.
1/*
2 olcPGEX_TransformedView.h
3
4 +-------------------------------------------------------------+
5 | OneLoneCoder Pixel Game Engine Extension |
6 | Transformed View v1.10 |
7 +-------------------------------------------------------------+
8
9 NOTE: UNDER ACTIVE DEVELOPMENT - THERE ARE BUGS/GLITCHES
10
11 What is this?
12 ~~~~~~~~~~~~~
13 This extension provides drawing routines that are compatible with
14 changeable world and screen spaces. For example you can pan and
15 zoom, and all PGE drawing routines will automatically adopt the current
16 world scales and offsets.
17
18 License (OLC-3)
19 ~~~~~~~~~~~~~~~
20
21 Copyright 2018 - 2025 OneLoneCoder.com
22
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions
25 are met:
26
27 1. Redistributions or derivations of source code must retain the above
28 copyright notice, this list of conditions and the following disclaimer.
29
30 2. Redistributions or derivative works in binary form must reproduce
31 the above copyright notice. This list of conditions and the following
32 disclaimer must be reproduced in the documentation and/or other
33 materials provided with the distribution.
34
35 3. Neither the name of the copyright holder nor the names of its
36 contributors may be used to endorse or promote products derived
37 from this software without specific prior written permission.
38
39 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50
51 Links
52 ~~~~~
53 YouTube: https://www.youtube.com/javidx9
54 Discord: https://discord.gg/WhwHUMV
55 Twitter: https://www.twitter.com/javidx9
56 Twitch: https://www.twitch.tv/javidx9
57 GitHub: https://www.github.com/onelonecoder
58 Homepage: https://www.onelonecoder.com
59
60 Author
61 ~~~~~~
62 David Barr, aka javidx9, ©OneLoneCoder 2019, 2020, 2021, 2022, 2023, 2024, 2025
63
64 Revisions:
65 1.00: Initial Release
66 1.01: Fix for rounding error when scaling to screen
67 1.02: Added DrawLineDecal for convenience
68 1.03: Removed std::floor from WorldToScreen()
69 Added HandlePanAndZoom(...) convenience function
70 Removed unused "range" facility in TileTransformView
71 1.04: Added DrawPolygonDecal() for arbitrary polygons
72 1.05: Clipped DrawSprite() to visible area, massive performance increase
73 1.06: Fixed error in DrawLine() - Thanks CraisyDaisyRecords (& Fern)!
74 1.07: +DrawRectDecal()
75 +GetPGE()
76 1.08: +DrawPolygonDecal() with tint overload, akin to PGE
77 1.09: +SetScaleExtents() - Sets range that world scale can exist within
78 +EnableScaleClamp() - Applies a range that scaling is clamped to
79 These are both useful for having zoom clamped between a min and max
80 without weird panning artefacts occuring
81 1.10: Hitched in some "shader" PGEX things
82*/
83
84#pragma once
85#ifndef OLC_PGEX_TRANSFORMEDVIEW_H
86#define OLC_PGEX_TRANSFORMEDVIEW_H
87
88#include "olcPixelGameEngine.h"
89
90
91
92namespace olc
93{
95 {
96 public:
97 TransformedView() = default;
98 virtual void Initialise(const olc::vi2d& vViewArea, const olc::vf2d& vPixelScale = { 1.0f, 1.0f });
99
101
102 public:
103 void SetWorldOffset(const olc::vf2d& vOffset);
104 void MoveWorldOffset(const olc::vf2d& vDeltaOffset);
105 void SetWorldScale(const olc::vf2d& vScale);
106 void SetViewArea(const olc::vi2d& vViewArea);
110 void ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos);
111 void SetZoom(const float fZoom, const olc::vf2d& vPos);
112 void StartPan(const olc::vi2d& vPos);
113 void UpdatePan(const olc::vi2d& vPos);
114 void EndPan(const olc::vi2d& vPos);
115 const olc::vf2d& GetWorldOffset() const;
116 const olc::vf2d& GetWorldScale() const;
117 virtual olc::vf2d WorldToScreen(const olc::vf2d& vWorldPos) const;
118 virtual olc::vf2d ScreenToWorld(const olc::vf2d& vScreenPos) const;
119 virtual olc::vf2d ScaleToWorld(const olc::vf2d& vScreenSize) const;
120 virtual olc::vf2d ScaleToScreen(const olc::vf2d& vWorldSize) const;
121 virtual bool IsPointVisible(const olc::vf2d& vPos) const;
122 virtual bool IsRectVisible(const olc::vf2d& vPos, const olc::vf2d& vSize) const;
123 virtual void HandlePanAndZoom(const int nMouseButton = 2, const float fZoomRate = 0.1f, const bool bPan = true, const bool bZoom = true);
124 void SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax);
125 void EnableScaleClamp(const bool bEnable);
126
127 protected:
128 olc::vf2d m_vWorldOffset = { 0.0f, 0.0f };
129 olc::vf2d m_vWorldScale = { 1.0f, 1.0f };
130 olc::vf2d m_vRecipPixel = { 1.0f, 1.0f };
131 olc::vf2d m_vPixelScale = { 1.0f, 1.0f };
132 bool m_bPanning = false;
133 olc::vf2d m_vStartPan = { 0.0f, 0.0f };
135 bool m_bZoomClamp = false;
136 olc::vf2d m_vMaxScale = { 0.0f, 0.0f };
137 olc::vf2d m_vMinScale = { 0.0f, 0.0f };
138
139 public: // Hopefully, these should look familiar!
140 // Plots a single point
141 virtual bool Draw(float x, float y, olc::Pixel p = olc::WHITE);
142 bool Draw(const olc::vf2d& pos, olc::Pixel p = olc::WHITE);
143 // Draws a line from (x1,y1) to (x2,y2)
144 void DrawLine(float x1, float y1, float x2, float y2, olc::Pixel p = olc::WHITE, uint32_t pattern = 0xFFFFFFFF);
145 void DrawLine(const olc::vf2d& pos1, const olc::vf2d& pos2, olc::Pixel p = olc::WHITE, uint32_t pattern = 0xFFFFFFFF);
146 // Draws a circle located at (x,y) with radius
147 void DrawCircle(float x, float y, float radius, olc::Pixel p = olc::WHITE, uint8_t mask = 0xFF);
148 void DrawCircle(const olc::vf2d& pos, float radius, olc::Pixel p = olc::WHITE, uint8_t mask = 0xFF);
149 // Fills a circle located at (x,y) with radius
150 void FillCircle(float x, float y, float radius, olc::Pixel p = olc::WHITE);
151 void FillCircle(const olc::vf2d& pos, float radius, olc::Pixel p = olc::WHITE);
152 // Draws a rectangle at (x,y) to (x+w,y+h)
153 void DrawRect(float x, float y, float w, float h, olc::Pixel p = olc::WHITE);
154 void DrawRect(const olc::vf2d& pos, const olc::vf2d& size, olc::Pixel p = olc::WHITE);
155 // Fills a rectangle at (x,y) to (x+w,y+h)
156 void FillRect(float x, float y, float w, float h, olc::Pixel p = olc::WHITE);
157 void FillRect(const olc::vf2d& pos, const olc::vf2d& size, olc::Pixel p = olc::WHITE);
158 // Draws a triangle between points (x1,y1), (x2,y2) and (x3,y3)
159 void DrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p = olc::WHITE);
160 void DrawTriangle(const olc::vf2d& pos1, const olc::vf2d& pos2, const olc::vf2d& pos3, olc::Pixel p = olc::WHITE);
161 // Flat fills a triangle between points (x1,y1), (x2,y2) and (x3,y3)
162 void FillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p = olc::WHITE);
163 void FillTriangle(const olc::vf2d& pos1, const olc::vf2d& pos2, const olc::vf2d& pos3, olc::Pixel p = olc::WHITE);
164 // Draws an entire sprite at location (x,y)
165 void DrawSprite(float x, float y, olc::Sprite* sprite, float scalex = 1, float scaley = 1, uint8_t flip = olc::Sprite::NONE);
166 void DrawSprite(const olc::vf2d& pos, olc::Sprite* sprite, const olc::vf2d& scale = { 1.0f, 1.0f }, uint8_t flip = olc::Sprite::NONE);
167 // Draws an area of a sprite at location (x,y), where the
168 // selected area is (ox,oy) to (ox+w,oy+h)
169 void DrawPartialSprite(float x, float y, Sprite* sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, float scalex = 1, float scaley = 1, uint8_t flip = olc::Sprite::NONE);
170 void DrawPartialSprite(const olc::vf2d& pos, Sprite* sprite, const olc::vi2d& sourcepos, const olc::vi2d& size, const olc::vf2d& scale = { 1.0f, 1.0f }, uint8_t flip = olc::Sprite::NONE);
171 void DrawString(float x, float y, const std::string& sText, Pixel col, const olc::vf2d& scale);
172 void DrawString(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale);
173
174
175 // Draws a whole decal, with optional scale and tinting
176 void DrawDecal(const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE);
177 // Draws a region of a decal, with optional scale and tinting
178 void DrawPartialDecal(const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE);
179 void DrawPartialDecal(const olc::vf2d& pos, const olc::vf2d& size, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint = olc::WHITE);
180 // Draws fully user controlled 4 vertices, pos(pixels), uv(pixels), colours
181 void DrawExplicitDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d* uv, const olc::Pixel* col, uint32_t elements = 4);
183 void DrawWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::Pixel& tint = olc::WHITE);
184 void DrawWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::Pixel& tint = olc::WHITE);
185 void DrawWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::Pixel& tint = olc::WHITE);
187 void DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint = olc::WHITE);
188 void DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint = olc::WHITE);
189 void DrawPartialWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint = olc::WHITE);
191 void DrawRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE);
192 void DrawPartialRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale = { 1.0f, 1.0f }, const olc::Pixel& tint = olc::WHITE);
193 // Draws a multiline string as a decal, with tiniting and scaling
194 void DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
195 void DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
196 // Draws a single shaded filled rectangle as a decal
197 void FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
198 void DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
199
200 // Draws a corner shaded rectangle as a decal
201 void GradientFillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR);
202 // Draws an arbitrary convex textured polygon using GPU
203 void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint = olc::WHITE);
204 void DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE);
205 void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>&pos, const std::vector<olc::vf2d>&uv, const std::vector<olc::Pixel> &tint);
206 void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint);
207
208
209#if defined(OLC_USING_PGEX_SHADER)
210 // Shader Specific
211 void DrawDecal(olc::Shade& shader, const olc::vf2d & pos, olc::Decal * decal, const olc::vf2d & scale = { 1.0f,1.0f }, const olc::Pixel & tint = olc::WHITE);
212 void DrawPartialDecal(olc::Shade& shader, const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE);
213 void DrawPartialDecal(olc::Shade& shader, const olc::vf2d& pos, const olc::vf2d& size, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint = olc::WHITE);
214#endif
215
216
217
218 };
219
221 {
222 public:
224 TileTransformedView(const olc::vi2d& vViewArea, const olc::vi2d& vTileSize);
225
226 public:
232
233 };
234}
235
236#ifdef OLC_PGEX_TRANSFORMEDVIEW
237#undef OLC_PGEX_TRANSFORMEDVIEW
238
239namespace olc
240{
242 {
243 return pge;
244 }
245
246 void TransformedView::Initialise(const olc::vi2d& vViewArea, const olc::vf2d& vPixelScale)
247 {
248 SetViewArea(vViewArea);
249 SetWorldScale(vPixelScale);
250 m_vPixelScale = vPixelScale;
252 }
253
254 void TransformedView::SetWorldOffset(const olc::vf2d& vOffset)
255 {
256 m_vWorldOffset = vOffset;
257 }
258
259 void TransformedView::MoveWorldOffset(const olc::vf2d& vDeltaOffset)
260 {
261 m_vWorldOffset += vDeltaOffset;
262 }
263
264 void TransformedView::SetWorldScale(const olc::vf2d& vScale)
265 {
266 m_vWorldScale = vScale;
268 }
269
270 void TransformedView::SetViewArea(const olc::vi2d& vViewArea)
271 {
272 m_vViewArea = vViewArea;
273 }
274
276 {
277 return TransformedView::ScreenToWorld({ 0,0 });
278 }
279
281 {
283 }
284
286 {
287 return GetWorldBR() - GetWorldTL();
288 }
289
290 void TransformedView::SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax)
291 {
292 m_vMaxScale = vScaleMax;
293 m_vMinScale = vScaleMin;
294 }
295
296 void TransformedView::EnableScaleClamp(const bool bEnable)
297 {
298 m_bZoomClamp = bEnable;
299 }
300
301 void TransformedView::ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos)
302 {
303 olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
304 m_vWorldScale *= fDeltaZoom;
306 olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
307 m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
308 }
309
310 void TransformedView::SetZoom(const float fZoom, const olc::vf2d& vPos)
311 {
312 olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
313 m_vWorldScale = { fZoom, fZoom };
315 olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
316 m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
317 }
318
319 void TransformedView::StartPan(const olc::vi2d& vPos)
320 {
321 m_bPanning = true;
322 m_vStartPan = olc::vf2d(vPos);
323 }
324
325 void TransformedView::UpdatePan(const olc::vi2d& vPos)
326 {
327 if (m_bPanning)
328 {
330 m_vStartPan = olc::vf2d(vPos);
331 }
332 }
333
334 void TransformedView::EndPan(const olc::vi2d& vPos)
335 {
336 UpdatePan(vPos);
337 m_bPanning = false;
338 }
339
341 {
342 return m_vWorldOffset;
343 }
344
346 {
347 return m_vWorldScale;
348 }
349
351 {
352 olc::vf2d vFloat = ((vWorldPos - m_vWorldOffset) * m_vWorldScale);
353 //vFloat = { std::floor(vFloat.x + 0.5f), std::floor(vFloat.y + 0.5f) };
354 return vFloat;
355 }
356
357 olc::vf2d TransformedView::ScreenToWorld(const olc::vf2d& vScreenPos) const
358 {
359 return (olc::vf2d(vScreenPos) / m_vWorldScale) + m_vWorldOffset;
360 }
361
362 olc::vf2d TransformedView::ScaleToWorld(const olc::vf2d& vScreenSize) const
363 {
364 return (olc::vf2d(vScreenSize) / m_vWorldScale);
365 }
366
367 olc::vf2d TransformedView::ScaleToScreen(const olc::vf2d& vWorldSize) const
368 {
369 //olc::vf2d vFloat = (vWorldSize * m_vWorldScale) + olc::vf2d(0.5f, 0.5f);
370 //return vFloat.floor();
371 return (vWorldSize * m_vWorldScale);
372 }
373
374 bool TransformedView::IsPointVisible(const olc::vf2d & vPos) const
375 {
376 olc::vi2d vScreen = WorldToScreen(vPos);
377 return vScreen.x >= 0 && vScreen.x < m_vViewArea.x&& vScreen.y >= 0 && vScreen.y < m_vViewArea.y;
378 }
379
380 bool TransformedView::IsRectVisible(const olc::vf2d& vPos, const olc::vf2d& vSize) const
381 {
382 olc::vi2d vScreenPos = WorldToScreen(vPos);
383 olc::vi2d vScreenSize = vSize * m_vWorldScale;
384 return (vScreenPos.x < 0 + m_vViewArea.x && vScreenPos.x + vScreenSize.x > 0 && vScreenPos.y < m_vViewArea.y&& vScreenPos.y + vScreenSize.y > 0);
385 }
386
387 void TransformedView::HandlePanAndZoom(const int nMouseButton, const float fZoomRate, const bool bPan, const bool bZoom)
388 {
389 const auto& vMousePos = pge->GetMousePos();
390 if (bPan)
391 {
392 if (pge->GetMouse(nMouseButton).bPressed) StartPan(vMousePos);
393 if (pge->GetMouse(nMouseButton).bHeld) UpdatePan(vMousePos);
394 if (pge->GetMouse(nMouseButton).bReleased) EndPan(vMousePos);
395 }
396
397 if (bZoom)
398 {
399 if (pge->GetMouseWheel() > 0) ZoomAtScreenPos(1.0f + fZoomRate, vMousePos);
400 if (pge->GetMouseWheel() < 0) ZoomAtScreenPos(1.0f - fZoomRate, vMousePos);
401 }
402 }
403
404 bool TransformedView::Draw(float x, float y, olc::Pixel p)
405 {
406 return Draw({ x, y }, p);
407 }
408
409 bool TransformedView::Draw(const olc::vf2d & pos, olc::Pixel p)
410 {
411 return pge->Draw(WorldToScreen(pos), p);
412 }
413
414 void TransformedView::DrawLine(float x1, float y1, float x2, float y2, olc::Pixel p, uint32_t pattern)
415 {
416 DrawLine({ x1, y1 }, { x2, y2 }, p, pattern);
417 }
418
419 void TransformedView::DrawLine(const olc::vf2d & pos1, const olc::vf2d & pos2, olc::Pixel p, uint32_t pattern)
420 {
421 pge->DrawLine(WorldToScreen(pos1), WorldToScreen(pos2), p, pattern);
422 }
423
424 void TransformedView::DrawCircle(float x, float y, float radius, olc::Pixel p, uint8_t mask)
425 {
426 DrawCircle({ x,y }, radius, p, mask);
427 }
428
429 void TransformedView::DrawCircle(const olc::vf2d & pos, float radius, olc::Pixel p, uint8_t mask)
430 {
431 pge->DrawCircle(WorldToScreen(pos), int32_t(radius * m_vWorldScale.x), p, mask);
432 }
433
434 void TransformedView::FillCircle(float x, float y, float radius, olc::Pixel p)
435 {
436 FillCircle({ x,y }, radius, p);
437 }
438
439 void TransformedView::FillCircle(const olc::vf2d & pos, float radius, olc::Pixel p)
440 {
441 pge->FillCircle(WorldToScreen(pos), int32_t(radius * m_vWorldScale.x), p);
442 }
443
444 void TransformedView::DrawRect(float x, float y, float w, float h, olc::Pixel p)
445 {
446 DrawRect({ x, y }, { w, h }, p);
447 }
448
449 void TransformedView::DrawRect(const olc::vf2d & pos, const olc::vf2d & size, olc::Pixel p)
450 {
451 pge->DrawRect(WorldToScreen(pos), ((size * m_vWorldScale) + olc::vf2d(0.5f, 0.5f)).floor(), p);
452 }
453
454 void TransformedView::FillRect(float x, float y, float w, float h, olc::Pixel p)
455 {
456 FillRect({ x, y }, { w, h }, p);
457 }
458
459 void TransformedView::FillRect(const olc::vf2d & pos, const olc::vf2d & size, olc::Pixel p)
460 {
461 pge->FillRect(WorldToScreen(pos), size * m_vWorldScale, p);
462 }
463
464 void TransformedView::DrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p)
465 {
466 DrawTriangle({ x1, y1 }, { x2, y2 }, { x3, y3 }, p);
467 }
468
469 void TransformedView::DrawTriangle(const olc::vf2d & pos1, const olc::vf2d & pos2, const olc::vf2d & pos3, olc::Pixel p)
470 {
472 }
473
474 void TransformedView::FillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p)
475 {
476 FillTriangle({ x1, y1 }, { x2, y2 }, { x3, y3 }, p);
477 }
478
479 void TransformedView::FillTriangle(const olc::vf2d & pos1, const olc::vf2d & pos2, const olc::vf2d & pos3, olc::Pixel p)
480 {
482 }
483
484 void TransformedView::DrawSprite(float x, float y, olc::Sprite* sprite, float scalex, float scaley, uint8_t flip)
485 {
486 DrawSprite({ x, y }, sprite, { scalex, scaley }, flip);
487 }
488
489 void TransformedView::DrawSprite(const olc::vf2d & pos, olc::Sprite * sprite, const olc::vf2d & scale, uint8_t flip)
490 {
491 olc::vf2d vSpriteSize = olc::vf2d(float(sprite->width), float(sprite->height));
492 if (IsRectVisible(pos, vSpriteSize * scale))
493 {
494 olc::vf2d vSpriteScaledSize = vSpriteSize * m_vRecipPixel * m_vWorldScale * scale;
495 olc::vi2d vPixel;
496 olc::vi2d vSpritePixelStart = WorldToScreen(pos);
497 olc::vi2d vSpritePixelEnd = WorldToScreen((vSpriteSize * scale) + pos);
498
499 olc::vi2d vScreenPixelStart = (vSpritePixelStart).max({0,0});
500 olc::vi2d vScreenPixelEnd = (vSpritePixelEnd).min({ pge->ScreenWidth(),pge->ScreenHeight() });
501
502 olc::vf2d vPixelStep = 1.0f / vSpriteScaledSize;
503
504 for (vPixel.y = vScreenPixelStart.y; vPixel.y < vScreenPixelEnd.y; vPixel.y++)
505 {
506 for (vPixel.x = vScreenPixelStart.x; vPixel.x < vScreenPixelEnd.x; vPixel.x++)
507 {
508 olc::vf2d vSample = olc::vf2d(vPixel - vSpritePixelStart) * vPixelStep;
509 pge->Draw(vPixel, sprite->Sample(vSample.x, vSample.y));
510 }
511 }
512 }
513 }
514
515
516 void TransformedView::DrawPartialSprite(float x, float y, Sprite* sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, float scalex, float scaley, uint8_t flip)
517 {
518 DrawPartialSprite({ x,y }, sprite, { ox,oy }, { w, h }, { scalex, scaley }, flip);
519 }
520
521 void TransformedView::DrawPartialSprite(const olc::vf2d& pos, Sprite* sprite, const olc::vi2d& sourcepos, const olc::vi2d& size, const olc::vf2d& scale, uint8_t flip)
522 {
523 olc::vf2d vSpriteSize = size;
524 if (IsRectVisible(pos, size * scale))
525 {
526 olc::vf2d vSpriteScaledSize = olc::vf2d(size) * m_vRecipPixel * m_vWorldScale * scale;
527 olc::vf2d vSpritePixelStep = 1.0f / olc::vf2d(float(sprite->width), float(sprite->height));
528 olc::vi2d vPixel, vStart = WorldToScreen(pos), vEnd = vSpriteScaledSize + vStart;
529 olc::vf2d vScreenPixelStep = 1.0f / vSpriteScaledSize;
530
531 for (vPixel.y = vStart.y; vPixel.y < vEnd.y; vPixel.y++)
532 {
533 for (vPixel.x = vStart.x; vPixel.x < vEnd.x; vPixel.x++)
534 {
535 olc::vf2d vSample = ((olc::vf2d(vPixel - vStart) * vScreenPixelStep) * size * vSpritePixelStep) + olc::vf2d(sourcepos) * vSpritePixelStep;
536 pge->Draw(vPixel, sprite->Sample(vSample.x, vSample.y));
537 }
538 }
539 }
540 }
541
542 void TransformedView::DrawString(float x, float y, const std::string& sText, Pixel col, const olc::vf2d& scale)
543 {
544 DrawString({ x, y }, sText, col, scale);
545 }
546
547 void TransformedView::DrawString(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale)
548 {
549 olc::vf2d vOffset = { 0.0f, 0.0f };
551
552 auto StringPlot = [&col](const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest)
553 {
554 return pSource.r > 1 ? col : pDest;
555 };
556
557 pge->SetPixelMode(StringPlot);
558
559 for (auto c : sText)
560 {
561 if (c == '\n')
562 {
563 vOffset.x = 0.0f; vOffset.y += 8.0f * m_vRecipPixel.y * scale.y;
564 }
565 else
566 {
567 int32_t ox = ((c - 32) % 16) * 8;
568 int32_t oy = ((c - 32) / 16) * 8;
569 DrawPartialSprite(pos + vOffset, pge->GetFontSprite(), { ox, oy }, { 8, 8 }, scale);
570 vOffset.x += 8.0f * m_vRecipPixel.x * scale.x;
571 }
572 }
573 pge->SetPixelMode(m);
574 }
575
576
577 void TransformedView::DrawDecal(const olc::vf2d & pos, olc::Decal * decal, const olc::vf2d & scale, const olc::Pixel & tint)
578 {
579 pge->DrawDecal(WorldToScreen(pos), decal, scale * m_vWorldScale * m_vRecipPixel, tint);
580 }
581
582 void TransformedView::DrawPartialDecal(const olc::vf2d & pos, olc::Decal * decal, const olc::vf2d & source_pos, const olc::vf2d & source_size, const olc::vf2d & scale, const olc::Pixel & tint)
583 {
584 pge->DrawPartialDecal(WorldToScreen(pos), decal, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
585 }
586
587 void TransformedView::DrawPartialDecal(const olc::vf2d & pos, const olc::vf2d & size, olc::Decal * decal, const olc::vf2d & source_pos, const olc::vf2d & source_size, const olc::Pixel & tint)
588 {
589 pge->DrawPartialDecal(WorldToScreen(pos), size * m_vWorldScale * m_vRecipPixel, decal, source_pos, source_size, tint);
590 }
591
592 void TransformedView::DrawExplicitDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d* uv, const olc::Pixel* col, uint32_t elements)
593 {
594 std::vector<olc::vf2d> vTransformed(elements);
595 for (uint32_t n = 0; n < elements; n++)
596 vTransformed[n] = WorldToScreen(pos[n]);
597 pge->DrawExplicitDecal(decal, vTransformed.data(), uv, col, elements);
598 }
599
600 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::Pixel& tint)
601 {
602 std::array<olc::vf2d, 4> vTransformed =
603 { {
604 WorldToScreen(pos[0]), WorldToScreen(pos[1]),
605 WorldToScreen(pos[2]), WorldToScreen(pos[3]),
606 } };
607
608 pge->DrawWarpedDecal(decal, vTransformed, tint);
609 }
610
611 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::Pixel& tint)
612 {
613 DrawWarpedDecal(decal, &pos[0], tint);
614 }
615
616 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::Pixel& tint)
617 {
618 DrawWarpedDecal(decal, pos.data(), tint);
619 }
620
621 void TransformedView::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint)
622 {
623 DrawPartialWarpedDecal(decal, &pos[0], source_pos, source_size, tint);
624 }
625
626 void TransformedView::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint)
627 {
628 std::array<olc::vf2d, 4> vTransformed =
629 { {
630 WorldToScreen(pos[0]), WorldToScreen(pos[1]),
631 WorldToScreen(pos[2]), WorldToScreen(pos[3]),
632 } };
633
634 pge->DrawPartialWarpedDecal(decal, vTransformed, source_pos, source_size, tint);
635 }
636
637 void TransformedView::DrawPartialWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint)
638 {
639 DrawPartialWarpedDecal(decal, pos.data(), source_pos, source_size, tint);
640 }
641
642 void TransformedView::DrawRotatedDecal(const olc::vf2d & pos, olc::Decal * decal, const float fAngle, const olc::vf2d & center, const olc::vf2d & scale, const olc::Pixel & tint)
643 {
644 pge->DrawRotatedDecal(WorldToScreen(pos), decal, fAngle, center, scale * m_vWorldScale * m_vRecipPixel, tint);
645 }
646
647 void TransformedView::DrawPartialRotatedDecal(const olc::vf2d & pos, olc::Decal * decal, const float fAngle, const olc::vf2d & center, const olc::vf2d & source_pos, const olc::vf2d & source_size, const olc::vf2d & scale, const olc::Pixel & tint)
648 {
649 pge->DrawPartialRotatedDecal(WorldToScreen(pos), decal, fAngle, center, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
650 }
651
652 void TransformedView::DrawStringDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale)
653 {
654 pge->DrawStringDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel);
655 }
656
657 void TransformedView::DrawStringPropDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale )
658 {
660 }
661
662 void TransformedView::FillRectDecal(const olc::vf2d & pos, const olc::vf2d & size, const olc::Pixel col)
663 {
664 pge->FillRectDecal(WorldToScreen(pos), (size * m_vWorldScale).ceil(), col);
665 }
666
667 void TransformedView::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)
668 {
669 pge->DrawRectDecal(WorldToScreen(pos), (size * m_vWorldScale).ceil(), col);
670 }
671
672 void TransformedView::DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p)
673 {
675 }
676
677 void TransformedView::GradientFillRectDecal(const olc::vf2d & pos, const olc::vf2d & size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR)
678 {
679 pge->GradientFillRectDecal(WorldToScreen(pos), size * m_vWorldScale, colTL, colBL, colBR, colTR);
680 }
681
682 void TransformedView::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
683 {
684 std::vector<olc::vf2d> vTransformed(pos.size());
685 for (uint32_t n = 0; n < pos.size(); n++)
686 vTransformed[n] = WorldToScreen(pos[n]);
687 pge->DrawPolygonDecal(decal, vTransformed, uv, tint);
688 }
689
690 void TransformedView::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel> &tint)
691 {
692 std::vector<olc::vf2d> vTransformed(pos.size());
693 for (uint32_t n = 0; n < pos.size(); n++)
694 vTransformed[n] = WorldToScreen(pos[n]);
695 pge->DrawPolygonDecal(decal, vTransformed, uv, tint);
696 }
697
698 void TransformedView::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& colours, const olc::Pixel tint)
699 {
700 std::vector<olc::vf2d> vTransformed(pos.size());
701 for (uint32_t n = 0; n < pos.size(); n++)
702 vTransformed[n] = WorldToScreen(pos[n]);
703 pge->DrawPolygonDecal(decal, vTransformed, uv, colours, tint);
704 }
705
706
707
708#if defined (OLC_USING_PGEX_SHADER)
709
710 void TransformedView::DrawDecal(olc::Shade &shade, const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& scale, const olc::Pixel& tint)
711 {
712 shade.DrawDecal(WorldToScreen(pos), decal, scale * m_vWorldScale * m_vRecipPixel, tint);
713 }
714
715 void TransformedView::DrawPartialDecal(olc::Shade& shade, const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale, const olc::Pixel& tint)
716 {
717 shade.DrawPartialDecal(WorldToScreen(pos), decal, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
718 }
719
720 void TransformedView::DrawPartialDecal(olc::Shade& shade, const olc::vf2d& pos, const olc::vf2d& size, olc::Decal* decal, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint)
721 {
722 shade.DrawPartialDecal(WorldToScreen(pos), size * m_vWorldScale * m_vRecipPixel, decal, source_pos, source_size, tint);
723 }
724
725#endif
726
727
728
729
730
731
732
735
736
737 TileTransformedView::TileTransformedView(const olc::vi2d& vViewArea, const olc::vi2d& vTileSize)
738 {
739 Initialise(vViewArea, vTileSize);
740 }
741
742
744 {
745 return ScreenToWorld({ 0,0 }).floor();
746 }
747
749 {
751 }
752
754 {
756 }
757
759 {
760 return ScreenToWorld(vPos).floor();
761 }
762
764 {
765 return { int32_t((m_vWorldOffset.x - std::floor(m_vWorldOffset.x)) * m_vWorldScale.x),
766 int32_t((m_vWorldOffset.y - std::floor(m_vWorldOffset.y)) * m_vWorldScale.y) };
767 }
768}
769
770#endif
771#endif
Definition olcPixelGameEngine.h:1113
Definition olcPixelGameEngine.h:1685
static PixelGameEngine * pge
Definition olcPixelGameEngine.h:1697
Definition olcPixelGameEngine.h:1278
void FillRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel col=olc::WHITE)
void GradientFillRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR)
void DrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, Pixel p=olc::WHITE, uint32_t pattern=0xFFFFFFFF)
void DrawRect(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p=olc::WHITE)
void DrawExplicitDecal(olc::Decal *decal, const olc::vf2d *pos, const olc::vf2d *uv, const olc::Pixel *col, uint32_t elements=4)
void DrawTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p=olc::WHITE)
void DrawCircle(int32_t x, int32_t y, int32_t radius, Pixel p=olc::WHITE, uint8_t mask=0xFF)
void DrawPolygonDecal(olc::Decal *decal, const std::vector< olc::vf2d > &pos, const std::vector< olc::vf2d > &uv, const olc::Pixel tint=olc::WHITE)
void DrawRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel col=olc::WHITE)
void FillCircle(int32_t x, int32_t y, int32_t radius, Pixel p=olc::WHITE)
void DrawDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void DrawWarpedDecal(olc::Decal *decal, const olc::vf2d(&pos)[4], const olc::Pixel &tint=olc::WHITE)
void DrawStringDecal(const olc::vf2d &pos, const std::string &sText, const Pixel col=olc::WHITE, const olc::vf2d &scale={ 1.0f, 1.0f })
void FillRect(int32_t x, int32_t y, int32_t w, int32_t h, Pixel p=olc::WHITE)
void DrawStringPropDecal(const olc::vf2d &pos, const std::string &sText, const Pixel col=olc::WHITE, const olc::vf2d &scale={ 1.0f, 1.0f })
void DrawPartialWarpedDecal(olc::Decal *decal, const olc::vf2d(&pos)[4], const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
const olc::vi2d & GetMousePos() const
void DrawPartialDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
virtual bool Draw(int32_t x, int32_t y, Pixel p=olc::WHITE)
int32_t GetMouseWheel() const
void DrawLineDecal(const olc::vf2d &pos1, const olc::vf2d &pos2, Pixel p=olc::WHITE)
int32_t ScreenWidth() const
void DrawPartialRotatedDecal(const olc::vf2d &pos, olc::Decal *decal, const float fAngle, const olc::vf2d &center, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void DrawRotatedDecal(const olc::vf2d &pos, olc::Decal *decal, const float fAngle, const olc::vf2d &center={ 0.0f, 0.0f }, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
int32_t ScreenHeight() const
HWButton GetMouse(uint32_t b) const
void FillTriangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, Pixel p=olc::WHITE)
Pixel::Mode GetPixelMode()
olc::Sprite * GetFontSprite()
void SetPixelMode(Pixel::Mode m)
Definition olcPGEX_Shaders.h:272
void DrawDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void DrawPartialDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
Definition olcPixelGameEngine.h:1071
Pixel Sample(float x, float y) const
int32_t height
Definition olcPixelGameEngine.h:1084
@ NONE
Definition olcPixelGameEngine.h:1086
int32_t width
Definition olcPixelGameEngine.h:1083
Definition olcPGEX_TransformedView.h:221
olc::vi2d GetTileUnderScreenPos(const olc::vi2d &vPos) const
olc::vi2d GetTopLeftTile() const
olc::vi2d GetVisibleTiles() const
TileTransformedView(const olc::vi2d &vViewArea, const olc::vi2d &vTileSize)
olc::vi2d GetBottomRightTile() const
const olc::vi2d GetTileOffset() const
Definition olcPGEX_TransformedView.h:95
void FillTriangle(const olc::vf2d &pos1, const olc::vf2d &pos2, const olc::vf2d &pos3, olc::Pixel p=olc::WHITE)
void DrawPartialDecal(const olc::vf2d &pos, const olc::vf2d &size, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
void DrawPolygonDecal(olc::Decal *decal, const std::vector< olc::vf2d > &pos, const std::vector< olc::vf2d > &uv, const olc::Pixel tint=olc::WHITE)
const olc::vf2d & GetWorldOffset() const
olc::vf2d m_vMinScale
Definition olcPGEX_TransformedView.h:137
void DrawSprite(float x, float y, olc::Sprite *sprite, float scalex=1, float scaley=1, uint8_t flip=olc::Sprite::NONE)
virtual bool Draw(float x, float y, olc::Pixel p=olc::WHITE)
olc::vi2d m_vViewArea
Definition olcPGEX_TransformedView.h:134
void DrawPartialSprite(const olc::vf2d &pos, Sprite *sprite, const olc::vi2d &sourcepos, const olc::vi2d &size, const olc::vf2d &scale={ 1.0f, 1.0f }, uint8_t flip=olc::Sprite::NONE)
void DrawRotatedDecal(const olc::vf2d &pos, olc::Decal *decal, const float fAngle, const olc::vf2d &center={ 0.0f, 0.0f }, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
virtual olc::vf2d ScreenToWorld(const olc::vf2d &vScreenPos) const
void MoveWorldOffset(const olc::vf2d &vDeltaOffset)
virtual olc::vf2d WorldToScreen(const olc::vf2d &vWorldPos) const
void DrawPartialWarpedDecal(olc::Decal *decal, const olc::vf2d(&pos)[4], const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
void SetScaleExtents(const olc::vf2d &vScaleMin, const olc::vf2d &vScaleMax)
void DrawPartialDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
TransformedView()=default
void GradientFillRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR)
bool Draw(const olc::vf2d &pos, olc::Pixel p=olc::WHITE)
void DrawWarpedDecal(olc::Decal *decal, const olc::vf2d *pos, const olc::Pixel &tint=olc::WHITE)
void DrawLine(float x1, float y1, float x2, float y2, olc::Pixel p=olc::WHITE, uint32_t pattern=0xFFFFFFFF)
void DrawWarpedDecal(olc::Decal *decal, const olc::vf2d(&pos)[4], const olc::Pixel &tint=olc::WHITE)
bool m_bPanning
Definition olcPGEX_TransformedView.h:132
void DrawRect(const olc::vf2d &pos, const olc::vf2d &size, olc::Pixel p=olc::WHITE)
olc::vf2d m_vWorldOffset
Definition olcPGEX_TransformedView.h:128
void FillRect(float x, float y, float w, float h, olc::Pixel p=olc::WHITE)
olc::PixelGameEngine * GetPGE()
void EndPan(const olc::vi2d &vPos)
void SetZoom(const float fZoom, const olc::vf2d &vPos)
void DrawPartialRotatedDecal(const olc::vf2d &pos, olc::Decal *decal, const float fAngle, const olc::vf2d &center, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void DrawSprite(const olc::vf2d &pos, olc::Sprite *sprite, const olc::vf2d &scale={ 1.0f, 1.0f }, uint8_t flip=olc::Sprite::NONE)
void DrawTriangle(const olc::vf2d &pos1, const olc::vf2d &pos2, const olc::vf2d &pos3, olc::Pixel p=olc::WHITE)
void UpdatePan(const olc::vi2d &vPos)
void StartPan(const olc::vi2d &vPos)
olc::vf2d m_vStartPan
Definition olcPGEX_TransformedView.h:133
olc::vf2d GetWorldBR() const
void FillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p=olc::WHITE)
virtual olc::vf2d ScaleToScreen(const olc::vf2d &vWorldSize) const
void DrawLine(const olc::vf2d &pos1, const olc::vf2d &pos2, olc::Pixel p=olc::WHITE, uint32_t pattern=0xFFFFFFFF)
void DrawWarpedDecal(olc::Decal *decal, const std::array< olc::vf2d, 4 > &pos, const olc::Pixel &tint=olc::WHITE)
void DrawPartialWarpedDecal(olc::Decal *decal, const std::array< olc::vf2d, 4 > &pos, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
olc::vf2d m_vWorldScale
Definition olcPGEX_TransformedView.h:129
virtual bool IsPointVisible(const olc::vf2d &vPos) const
void DrawPolygonDecal(olc::Decal *decal, const std::vector< olc::vf2d > &pos, const std::vector< olc::vf2d > &uv, const std::vector< olc::Pixel > &tint)
void DrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p=olc::WHITE)
void DrawRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel col=olc::WHITE)
virtual olc::vf2d ScaleToWorld(const olc::vf2d &vScreenSize) const
virtual void Initialise(const olc::vi2d &vViewArea, const olc::vf2d &vPixelScale={ 1.0f, 1.0f })
olc::vf2d GetWorldVisibleArea() const
void DrawPartialSprite(float x, float y, Sprite *sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, float scalex=1, float scaley=1, uint8_t flip=olc::Sprite::NONE)
void FillRectDecal(const olc::vf2d &pos, const olc::vf2d &size, const olc::Pixel col=olc::WHITE)
void ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d &vPos)
const olc::vf2d & GetWorldScale() const
void DrawPartialWarpedDecal(olc::Decal *decal, const olc::vf2d *pos, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
void DrawDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void FillCircle(const olc::vf2d &pos, float radius, olc::Pixel p=olc::WHITE)
void DrawStringDecal(const olc::vf2d &pos, const std::string &sText, const olc::Pixel col=olc::WHITE, const olc::vf2d &scale={ 1.0f, 1.0f })
olc::vf2d m_vPixelScale
Definition olcPGEX_TransformedView.h:131
void SetWorldScale(const olc::vf2d &vScale)
void EnableScaleClamp(const bool bEnable)
void DrawCircle(const olc::vf2d &pos, float radius, olc::Pixel p=olc::WHITE, uint8_t mask=0xFF)
void DrawRect(float x, float y, float w, float h, olc::Pixel p=olc::WHITE)
void DrawString(const olc::vf2d &pos, const std::string &sText, const Pixel col, const olc::vf2d &scale)
olc::vf2d m_vMaxScale
Definition olcPGEX_TransformedView.h:136
void DrawCircle(float x, float y, float radius, olc::Pixel p=olc::WHITE, uint8_t mask=0xFF)
void FillRect(const olc::vf2d &pos, const olc::vf2d &size, olc::Pixel p=olc::WHITE)
void DrawExplicitDecal(olc::Decal *decal, const olc::vf2d *pos, const olc::vf2d *uv, const olc::Pixel *col, uint32_t elements=4)
void SetViewArea(const olc::vi2d &vViewArea)
olc::vf2d GetWorldTL() const
void DrawString(float x, float y, const std::string &sText, Pixel col, const olc::vf2d &scale)
olc::vf2d m_vRecipPixel
Definition olcPGEX_TransformedView.h:130
void DrawPolygonDecal(olc::Decal *decal, const std::vector< olc::vf2d > &pos, const std::vector< olc::vf2d > &uv, const std::vector< olc::Pixel > &colours, const olc::Pixel tint)
virtual bool IsRectVisible(const olc::vf2d &vPos, const olc::vf2d &vSize) const
void SetWorldOffset(const olc::vf2d &vOffset)
void DrawLineDecal(const olc::vf2d &pos1, const olc::vf2d &pos2, Pixel p=olc::WHITE)
bool m_bZoomClamp
Definition olcPGEX_TransformedView.h:135
virtual void HandlePanAndZoom(const int nMouseButton=2, const float fZoomRate=0.1f, const bool bPan=true, const bool bZoom=true)
void FillCircle(float x, float y, float radius, olc::Pixel p=olc::WHITE)
void DrawStringPropDecal(const olc::vf2d &pos, const std::string &sText, const olc::Pixel col=olc::WHITE, const olc::vf2d &scale={ 1.0f, 1.0f })
Definition olcPixelGameEngine.h:612
v_2d< float > vf2d
Definition olcPixelGameEngine.h:918
static const Pixel WHITE(255, 255, 255)
bool bPressed
Definition olcPixelGameEngine.h:1023
bool bReleased
Definition olcPixelGameEngine.h:1024
bool bHeld
Definition olcPixelGameEngine.h:1025
Definition olcPixelGameEngine.h:948
Mode
Definition olcPixelGameEngine.h:955
constexpr v_2d clamp(const v_2d &v1, const v_2d &v2) const
Definition olcPixelGameEngine.h:726
T x
Definition olcPixelGameEngine.h:623
T y
Definition olcPixelGameEngine.h:625
constexpr v_2d ceil() const
Definition olcPixelGameEngine.h:684
constexpr v_2d floor() const
Definition olcPixelGameEngine.h:678