olcPixelGameEngine v2.28
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.09 |
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 - 2024 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
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*/
82
83#pragma once
84#ifndef OLC_PGEX_TRANSFORMEDVIEW_H
85#define OLC_PGEX_TRANSFORMEDVIEW_H
86
87#include "olcPixelGameEngine.h"
88
89
90
91namespace olc
92{
94 {
95 public:
96 TransformedView() = default;
97 virtual void Initialise(const olc::vi2d& vViewArea, const olc::vf2d& vPixelScale = { 1.0f, 1.0f });
98
100
101 public:
102 void SetWorldOffset(const olc::vf2d& vOffset);
103 void MoveWorldOffset(const olc::vf2d& vDeltaOffset);
104 void SetWorldScale(const olc::vf2d& vScale);
105 void SetViewArea(const olc::vi2d& vViewArea);
109 void ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos);
110 void SetZoom(const float fZoom, const olc::vf2d& vPos);
111 void StartPan(const olc::vi2d& vPos);
112 void UpdatePan(const olc::vi2d& vPos);
113 void EndPan(const olc::vi2d& vPos);
114 const olc::vf2d& GetWorldOffset() const;
115 const olc::vf2d& GetWorldScale() const;
116 virtual olc::vf2d WorldToScreen(const olc::vf2d& vWorldPos) const;
117 virtual olc::vf2d ScreenToWorld(const olc::vf2d& vScreenPos) const;
118 virtual olc::vf2d ScaleToWorld(const olc::vf2d& vScreenSize) const;
119 virtual olc::vf2d ScaleToScreen(const olc::vf2d& vWorldSize) const;
120 virtual bool IsPointVisible(const olc::vf2d& vPos) const;
121 virtual bool IsRectVisible(const olc::vf2d& vPos, const olc::vf2d& vSize) const;
122 virtual void HandlePanAndZoom(const int nMouseButton = 2, const float fZoomRate = 0.1f, const bool bPan = true, const bool bZoom = true);
123 void SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax);
124 void EnableScaleClamp(const bool bEnable);
125
126 protected:
127 olc::vf2d m_vWorldOffset = { 0.0f, 0.0f };
128 olc::vf2d m_vWorldScale = { 1.0f, 1.0f };
129 olc::vf2d m_vRecipPixel = { 1.0f, 1.0f };
130 olc::vf2d m_vPixelScale = { 1.0f, 1.0f };
131 bool m_bPanning = false;
132 olc::vf2d m_vStartPan = { 0.0f, 0.0f };
134 bool m_bZoomClamp = false;
135 olc::vf2d m_vMaxScale = { 0.0f, 0.0f };
136 olc::vf2d m_vMinScale = { 0.0f, 0.0f };
137
138 public: // Hopefully, these should look familiar!
139 // Plots a single point
140 virtual bool Draw(float x, float y, olc::Pixel p = olc::WHITE);
141 bool Draw(const olc::vf2d& pos, olc::Pixel p = olc::WHITE);
142 // Draws a line from (x1,y1) to (x2,y2)
143 void DrawLine(float x1, float y1, float x2, float y2, olc::Pixel p = olc::WHITE, uint32_t pattern = 0xFFFFFFFF);
144 void DrawLine(const olc::vf2d& pos1, const olc::vf2d& pos2, olc::Pixel p = olc::WHITE, uint32_t pattern = 0xFFFFFFFF);
145 // Draws a circle located at (x,y) with radius
146 void DrawCircle(float x, float y, float radius, olc::Pixel p = olc::WHITE, uint8_t mask = 0xFF);
147 void DrawCircle(const olc::vf2d& pos, float radius, olc::Pixel p = olc::WHITE, uint8_t mask = 0xFF);
148 // Fills a circle located at (x,y) with radius
149 void FillCircle(float x, float y, float radius, olc::Pixel p = olc::WHITE);
150 void FillCircle(const olc::vf2d& pos, float radius, olc::Pixel p = olc::WHITE);
151 // Draws a rectangle at (x,y) to (x+w,y+h)
152 void DrawRect(float x, float y, float w, float h, olc::Pixel p = olc::WHITE);
153 void DrawRect(const olc::vf2d& pos, const olc::vf2d& size, olc::Pixel p = olc::WHITE);
154 // Fills a rectangle at (x,y) to (x+w,y+h)
155 void FillRect(float x, float y, float w, float h, olc::Pixel p = olc::WHITE);
156 void FillRect(const olc::vf2d& pos, const olc::vf2d& size, olc::Pixel p = olc::WHITE);
157 // Draws a triangle between points (x1,y1), (x2,y2) and (x3,y3)
158 void DrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p = olc::WHITE);
159 void DrawTriangle(const olc::vf2d& pos1, const olc::vf2d& pos2, const olc::vf2d& pos3, olc::Pixel p = olc::WHITE);
160 // Flat fills a triangle between points (x1,y1), (x2,y2) and (x3,y3)
161 void FillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p = olc::WHITE);
162 void FillTriangle(const olc::vf2d& pos1, const olc::vf2d& pos2, const olc::vf2d& pos3, olc::Pixel p = olc::WHITE);
163 // Draws an entire sprite at location (x,y)
164 void DrawSprite(float x, float y, olc::Sprite* sprite, float scalex = 1, float scaley = 1, uint8_t flip = olc::Sprite::NONE);
165 void DrawSprite(const olc::vf2d& pos, olc::Sprite* sprite, const olc::vf2d& scale = { 1.0f, 1.0f }, uint8_t flip = olc::Sprite::NONE);
166 // Draws an area of a sprite at location (x,y), where the
167 // selected area is (ox,oy) to (ox+w,oy+h)
168 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);
169 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);
170 void DrawString(float x, float y, const std::string& sText, Pixel col, const olc::vf2d& scale);
171 void DrawString(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale);
172
173
174 // Draws a whole decal, with optional scale and tinting
175 void DrawDecal(const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE);
176 // Draws a region of a decal, with optional scale and tinting
177 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);
178 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);
179 // Draws fully user controlled 4 vertices, pos(pixels), uv(pixels), colours
180 void DrawExplicitDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d* uv, const olc::Pixel* col, uint32_t elements = 4);
182 void DrawWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::Pixel& tint = olc::WHITE);
183 void DrawWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::Pixel& tint = olc::WHITE);
184 void DrawWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::Pixel& tint = olc::WHITE);
186 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);
187 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);
188 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);
190 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);
191 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);
192 // Draws a multiline string as a decal, with tiniting and scaling
193 void DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
194 void DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f });
195 // Draws a single shaded filled rectangle as a decal
196 void FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
197 void DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE);
198
199 // Draws a corner shaded rectangle as a decal
200 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);
201 // Draws an arbitrary convex textured polygon using GPU
202 void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint = olc::WHITE);
203 void DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE);
204 void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>&pos, const std::vector<olc::vf2d>&uv, const std::vector<olc::Pixel> &tint);
205 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);
206
207
208#if defined(OLC_PGEX_SHADER)
209 // Shader Specific
210 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);
211 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);
212 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);
213#endif
214
215
216
217 };
218
220 {
221 public:
223 TileTransformedView(const olc::vi2d& vViewArea, const olc::vi2d& vTileSize);
224
225 public:
231
232 };
233}
234
235#ifdef OLC_PGEX_TRANSFORMEDVIEW
236#undef OLC_PGEX_TRANSFORMEDVIEW
237
238namespace olc
239{
241 {
242 return pge;
243 }
244
245 void TransformedView::Initialise(const olc::vi2d& vViewArea, const olc::vf2d& vPixelScale)
246 {
247 SetViewArea(vViewArea);
248 SetWorldScale(vPixelScale);
249 m_vPixelScale = vPixelScale;
251 }
252
253 void TransformedView::SetWorldOffset(const olc::vf2d& vOffset)
254 {
255 m_vWorldOffset = vOffset;
256 }
257
258 void TransformedView::MoveWorldOffset(const olc::vf2d& vDeltaOffset)
259 {
260 m_vWorldOffset += vDeltaOffset;
261 }
262
263 void TransformedView::SetWorldScale(const olc::vf2d& vScale)
264 {
265 m_vWorldScale = vScale;
267 }
268
269 void TransformedView::SetViewArea(const olc::vi2d& vViewArea)
270 {
271 m_vViewArea = vViewArea;
272 }
273
275 {
276 return TransformedView::ScreenToWorld({ 0,0 });
277 }
278
280 {
282 }
283
285 {
286 return GetWorldBR() - GetWorldTL();
287 }
288
289 void TransformedView::SetScaleExtents(const olc::vf2d& vScaleMin, const olc::vf2d& vScaleMax)
290 {
291 m_vMaxScale = vScaleMax;
292 m_vMinScale = vScaleMin;
293 }
294
295 void TransformedView::EnableScaleClamp(const bool bEnable)
296 {
297 m_bZoomClamp = bEnable;
298 }
299
300 void TransformedView::ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos)
301 {
302 olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
303 m_vWorldScale *= fDeltaZoom;
305 olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
306 m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
307 }
308
309 void TransformedView::SetZoom(const float fZoom, const olc::vf2d& vPos)
310 {
311 olc::vf2d vOffsetBeforeZoom = ScreenToWorld(vPos);
312 m_vWorldScale = { fZoom, fZoom };
314 olc::vf2d vOffsetAfterZoom = ScreenToWorld(vPos);
315 m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
316 }
317
318 void TransformedView::StartPan(const olc::vi2d& vPos)
319 {
320 m_bPanning = true;
321 m_vStartPan = olc::vf2d(vPos);
322 }
323
324 void TransformedView::UpdatePan(const olc::vi2d& vPos)
325 {
326 if (m_bPanning)
327 {
329 m_vStartPan = olc::vf2d(vPos);
330 }
331 }
332
333 void TransformedView::EndPan(const olc::vi2d& vPos)
334 {
335 UpdatePan(vPos);
336 m_bPanning = false;
337 }
338
340 {
341 return m_vWorldOffset;
342 }
343
345 {
346 return m_vWorldScale;
347 }
348
350 {
351 olc::vf2d vFloat = ((vWorldPos - m_vWorldOffset) * m_vWorldScale);
352 //vFloat = { std::floor(vFloat.x + 0.5f), std::floor(vFloat.y + 0.5f) };
353 return vFloat;
354 }
355
356 olc::vf2d TransformedView::ScreenToWorld(const olc::vf2d& vScreenPos) const
357 {
358 return (olc::vf2d(vScreenPos) / m_vWorldScale) + m_vWorldOffset;
359 }
360
361 olc::vf2d TransformedView::ScaleToWorld(const olc::vf2d& vScreenSize) const
362 {
363 return (olc::vf2d(vScreenSize) / m_vWorldScale);
364 }
365
366 olc::vf2d TransformedView::ScaleToScreen(const olc::vf2d& vWorldSize) const
367 {
368 //olc::vf2d vFloat = (vWorldSize * m_vWorldScale) + olc::vf2d(0.5f, 0.5f);
369 //return vFloat.floor();
370 return (vWorldSize * m_vWorldScale);
371 }
372
373 bool TransformedView::IsPointVisible(const olc::vf2d & vPos) const
374 {
375 olc::vi2d vScreen = WorldToScreen(vPos);
376 return vScreen.x >= 0 && vScreen.x < m_vViewArea.x&& vScreen.y >= 0 && vScreen.y < m_vViewArea.y;
377 }
378
379 bool TransformedView::IsRectVisible(const olc::vf2d& vPos, const olc::vf2d& vSize) const
380 {
381 olc::vi2d vScreenPos = WorldToScreen(vPos);
382 olc::vi2d vScreenSize = vSize * m_vWorldScale;
383 return (vScreenPos.x < 0 + m_vViewArea.x && vScreenPos.x + vScreenSize.x > 0 && vScreenPos.y < m_vViewArea.y&& vScreenPos.y + vScreenSize.y > 0);
384 }
385
386 void TransformedView::HandlePanAndZoom(const int nMouseButton, const float fZoomRate, const bool bPan, const bool bZoom)
387 {
388 const auto& vMousePos = pge->GetMousePos();
389 if (bPan)
390 {
391 if (pge->GetMouse(nMouseButton).bPressed) StartPan(vMousePos);
392 if (pge->GetMouse(nMouseButton).bHeld) UpdatePan(vMousePos);
393 if (pge->GetMouse(nMouseButton).bReleased) EndPan(vMousePos);
394 }
395
396 if (bZoom)
397 {
398 if (pge->GetMouseWheel() > 0) ZoomAtScreenPos(1.0f + fZoomRate, vMousePos);
399 if (pge->GetMouseWheel() < 0) ZoomAtScreenPos(1.0f - fZoomRate, vMousePos);
400 }
401 }
402
403 bool TransformedView::Draw(float x, float y, olc::Pixel p)
404 {
405 return Draw({ x, y }, p);
406 }
407
408 bool TransformedView::Draw(const olc::vf2d & pos, olc::Pixel p)
409 {
410 return pge->Draw(WorldToScreen(pos), p);
411 }
412
413 void TransformedView::DrawLine(float x1, float y1, float x2, float y2, olc::Pixel p, uint32_t pattern)
414 {
415 DrawLine({ x1, y1 }, { x2, y2 }, p, pattern);
416 }
417
418 void TransformedView::DrawLine(const olc::vf2d & pos1, const olc::vf2d & pos2, olc::Pixel p, uint32_t pattern)
419 {
420 pge->DrawLine(WorldToScreen(pos1), WorldToScreen(pos2), p, pattern);
421 }
422
423 void TransformedView::DrawCircle(float x, float y, float radius, olc::Pixel p, uint8_t mask)
424 {
425 DrawCircle({ x,y }, radius, p, mask);
426 }
427
428 void TransformedView::DrawCircle(const olc::vf2d & pos, float radius, olc::Pixel p, uint8_t mask)
429 {
430 pge->DrawCircle(WorldToScreen(pos), int32_t(radius * m_vWorldScale.x), p, mask);
431 }
432
433 void TransformedView::FillCircle(float x, float y, float radius, olc::Pixel p)
434 {
435 FillCircle({ x,y }, radius, p);
436 }
437
438 void TransformedView::FillCircle(const olc::vf2d & pos, float radius, olc::Pixel p)
439 {
440 pge->FillCircle(WorldToScreen(pos), int32_t(radius * m_vWorldScale.x), p);
441 }
442
443 void TransformedView::DrawRect(float x, float y, float w, float h, olc::Pixel p)
444 {
445 DrawRect({ x, y }, { w, h }, p);
446 }
447
448 void TransformedView::DrawRect(const olc::vf2d & pos, const olc::vf2d & size, olc::Pixel p)
449 {
450 pge->DrawRect(WorldToScreen(pos), ((size * m_vWorldScale) + olc::vf2d(0.5f, 0.5f)).floor(), p);
451 }
452
453 void TransformedView::FillRect(float x, float y, float w, float h, olc::Pixel p)
454 {
455 FillRect({ x, y }, { w, h }, p);
456 }
457
458 void TransformedView::FillRect(const olc::vf2d & pos, const olc::vf2d & size, olc::Pixel p)
459 {
460 pge->FillRect(WorldToScreen(pos), size * m_vWorldScale, p);
461 }
462
463 void TransformedView::DrawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p)
464 {
465 DrawTriangle({ x1, y1 }, { x2, y2 }, { x3, y3 }, p);
466 }
467
468 void TransformedView::DrawTriangle(const olc::vf2d & pos1, const olc::vf2d & pos2, const olc::vf2d & pos3, olc::Pixel p)
469 {
471 }
472
473 void TransformedView::FillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, olc::Pixel p)
474 {
475 FillTriangle({ x1, y1 }, { x2, y2 }, { x3, y3 }, p);
476 }
477
478 void TransformedView::FillTriangle(const olc::vf2d & pos1, const olc::vf2d & pos2, const olc::vf2d & pos3, olc::Pixel p)
479 {
481 }
482
483 void TransformedView::DrawSprite(float x, float y, olc::Sprite* sprite, float scalex, float scaley, uint8_t flip)
484 {
485 DrawSprite({ x, y }, sprite, { scalex, scaley }, flip);
486 }
487
488 void TransformedView::DrawSprite(const olc::vf2d & pos, olc::Sprite * sprite, const olc::vf2d & scale, uint8_t flip)
489 {
490 olc::vf2d vSpriteSize = olc::vf2d(float(sprite->width), float(sprite->height));
491 if (IsRectVisible(pos, vSpriteSize * scale))
492 {
493 olc::vf2d vSpriteScaledSize = vSpriteSize * m_vRecipPixel * m_vWorldScale * scale;
494 olc::vi2d vPixel;
495 olc::vi2d vSpritePixelStart = WorldToScreen(pos);
496 olc::vi2d vSpritePixelEnd = WorldToScreen((vSpriteSize * scale) + pos);
497
498 olc::vi2d vScreenPixelStart = (vSpritePixelStart).max({0,0});
499 olc::vi2d vScreenPixelEnd = (vSpritePixelEnd).min({ pge->ScreenWidth(),pge->ScreenHeight() });
500
501 olc::vf2d vPixelStep = 1.0f / vSpriteScaledSize;
502
503 for (vPixel.y = vScreenPixelStart.y; vPixel.y < vScreenPixelEnd.y; vPixel.y++)
504 {
505 for (vPixel.x = vScreenPixelStart.x; vPixel.x < vScreenPixelEnd.x; vPixel.x++)
506 {
507 olc::vf2d vSample = olc::vf2d(vPixel - vSpritePixelStart) * vPixelStep;
508 pge->Draw(vPixel, sprite->Sample(vSample.x, vSample.y));
509 }
510 }
511 }
512 }
513
514
515 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)
516 {
517 DrawPartialSprite({ x,y }, sprite, { ox,oy }, { w, h }, { scalex, scaley }, flip);
518 }
519
520 void TransformedView::DrawPartialSprite(const olc::vf2d& pos, Sprite* sprite, const olc::vi2d& sourcepos, const olc::vi2d& size, const olc::vf2d& scale, uint8_t flip)
521 {
522 olc::vf2d vSpriteSize = size;
523 if (IsRectVisible(pos, size * scale))
524 {
525 olc::vf2d vSpriteScaledSize = olc::vf2d(size) * m_vRecipPixel * m_vWorldScale * scale;
526 olc::vf2d vSpritePixelStep = 1.0f / olc::vf2d(float(sprite->width), float(sprite->height));
527 olc::vi2d vPixel, vStart = WorldToScreen(pos), vEnd = vSpriteScaledSize + vStart;
528 olc::vf2d vScreenPixelStep = 1.0f / vSpriteScaledSize;
529
530 for (vPixel.y = vStart.y; vPixel.y < vEnd.y; vPixel.y++)
531 {
532 for (vPixel.x = vStart.x; vPixel.x < vEnd.x; vPixel.x++)
533 {
534 olc::vf2d vSample = ((olc::vf2d(vPixel - vStart) * vScreenPixelStep) * size * vSpritePixelStep) + olc::vf2d(sourcepos) * vSpritePixelStep;
535 pge->Draw(vPixel, sprite->Sample(vSample.x, vSample.y));
536 }
537 }
538 }
539 }
540
541 void TransformedView::DrawString(float x, float y, const std::string& sText, Pixel col, const olc::vf2d& scale)
542 {
543 DrawString({ x, y }, sText, col, scale);
544 }
545
546 void TransformedView::DrawString(const olc::vf2d& pos, const std::string& sText, const Pixel col, const olc::vf2d& scale)
547 {
548 olc::vf2d vOffset = { 0.0f, 0.0f };
550
551 auto StringPlot = [&col](const int x, const int y, const olc::Pixel& pSource, const olc::Pixel& pDest)
552 {
553 return pSource.r > 1 ? col : pDest;
554 };
555
556 pge->SetPixelMode(StringPlot);
557
558 for (auto c : sText)
559 {
560 if (c == '\n')
561 {
562 vOffset.x = 0.0f; vOffset.y += 8.0f * m_vRecipPixel.y * scale.y;
563 }
564 else
565 {
566 int32_t ox = ((c - 32) % 16) * 8;
567 int32_t oy = ((c - 32) / 16) * 8;
568 DrawPartialSprite(pos + vOffset, pge->GetFontSprite(), { ox, oy }, { 8, 8 }, scale);
569 vOffset.x += 8.0f * m_vRecipPixel.x * scale.x;
570 }
571 }
572 pge->SetPixelMode(m);
573 }
574
575
576 void TransformedView::DrawDecal(const olc::vf2d & pos, olc::Decal * decal, const olc::vf2d & scale, const olc::Pixel & tint)
577 {
578 pge->DrawDecal(WorldToScreen(pos), decal, scale * m_vWorldScale * m_vRecipPixel, tint);
579 }
580
581 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)
582 {
583 pge->DrawPartialDecal(WorldToScreen(pos), decal, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
584 }
585
586 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)
587 {
588 pge->DrawPartialDecal(WorldToScreen(pos), size * m_vWorldScale * m_vRecipPixel, decal, source_pos, source_size, tint);
589 }
590
591 void TransformedView::DrawExplicitDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d* uv, const olc::Pixel* col, uint32_t elements)
592 {
593 std::vector<olc::vf2d> vTransformed(elements);
594 for (uint32_t n = 0; n < elements; n++)
595 vTransformed[n] = WorldToScreen(pos[n]);
596 pge->DrawExplicitDecal(decal, vTransformed.data(), uv, col, elements);
597 }
598
599 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::Pixel& tint)
600 {
601 std::array<olc::vf2d, 4> vTransformed =
602 { {
603 WorldToScreen(pos[0]), WorldToScreen(pos[1]),
604 WorldToScreen(pos[2]), WorldToScreen(pos[3]),
605 } };
606
607 pge->DrawWarpedDecal(decal, vTransformed, tint);
608 }
609
610 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const olc::vf2d(&pos)[4], const olc::Pixel& tint)
611 {
612 DrawWarpedDecal(decal, &pos[0], tint);
613 }
614
615 void TransformedView::DrawWarpedDecal(olc::Decal* decal, const std::array<olc::vf2d, 4>& pos, const olc::Pixel& tint)
616 {
617 DrawWarpedDecal(decal, pos.data(), tint);
618 }
619
620 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)
621 {
622 DrawPartialWarpedDecal(decal, &pos[0], source_pos, source_size, tint);
623 }
624
625 void TransformedView::DrawPartialWarpedDecal(olc::Decal* decal, const olc::vf2d* pos, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::Pixel& tint)
626 {
627 std::array<olc::vf2d, 4> vTransformed =
628 { {
629 WorldToScreen(pos[0]), WorldToScreen(pos[1]),
630 WorldToScreen(pos[2]), WorldToScreen(pos[3]),
631 } };
632
633 pge->DrawPartialWarpedDecal(decal, vTransformed, source_pos, source_size, tint);
634 }
635
636 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)
637 {
638 DrawPartialWarpedDecal(decal, pos.data(), source_pos, source_size, tint);
639 }
640
641 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)
642 {
643 pge->DrawRotatedDecal(WorldToScreen(pos), decal, fAngle, center, scale * m_vWorldScale * m_vRecipPixel, tint);
644 }
645
646 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)
647 {
648 pge->DrawPartialRotatedDecal(WorldToScreen(pos), decal, fAngle, center, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
649 }
650
651 void TransformedView::DrawStringDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale)
652 {
653 pge->DrawStringDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel);
654 }
655
656 void TransformedView::DrawStringPropDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale )
657 {
659 }
660
661 void TransformedView::FillRectDecal(const olc::vf2d & pos, const olc::vf2d & size, const olc::Pixel col)
662 {
663 pge->FillRectDecal(WorldToScreen(pos), (size * m_vWorldScale).ceil(), col);
664 }
665
666 void TransformedView::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)
667 {
668 pge->DrawRectDecal(WorldToScreen(pos), (size * m_vWorldScale).ceil(), col);
669 }
670
671 void TransformedView::DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p)
672 {
674 }
675
676 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)
677 {
678 pge->GradientFillRectDecal(WorldToScreen(pos), size * m_vWorldScale, colTL, colBL, colBR, colTR);
679 }
680
681 void TransformedView::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint)
682 {
683 std::vector<olc::vf2d> vTransformed(pos.size());
684 for (uint32_t n = 0; n < pos.size(); n++)
685 vTransformed[n] = WorldToScreen(pos[n]);
686 pge->DrawPolygonDecal(decal, vTransformed, uv, tint);
687 }
688
689 void TransformedView::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel> &tint)
690 {
691 std::vector<olc::vf2d> vTransformed(pos.size());
692 for (uint32_t n = 0; n < pos.size(); n++)
693 vTransformed[n] = WorldToScreen(pos[n]);
694 pge->DrawPolygonDecal(decal, vTransformed, uv, tint);
695 }
696
697 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)
698 {
699 std::vector<olc::vf2d> vTransformed(pos.size());
700 for (uint32_t n = 0; n < pos.size(); n++)
701 vTransformed[n] = WorldToScreen(pos[n]);
702 pge->DrawPolygonDecal(decal, vTransformed, uv, colours, tint);
703 }
704
705
706
707#if defined (OLC_PGEX_SHADER)
708
709 void TransformedView::DrawDecal(olc::Shade &shade, const olc::vf2d& pos, olc::Decal* decal, const olc::vf2d& scale, const olc::Pixel& tint)
710 {
711 shade.DrawDecal(WorldToScreen(pos), decal, scale * m_vWorldScale * m_vRecipPixel, tint);
712 }
713
714 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)
715 {
716 shade.DrawPartialDecal(WorldToScreen(pos), decal, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint);
717 }
718
719 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)
720 {
721 shade.DrawPartialDecal(WorldToScreen(pos), size * m_vWorldScale * m_vRecipPixel, decal, source_pos, source_size, tint);
722 }
723
724#endif
725
726
727
728
729
730
731
734
735
736 TileTransformedView::TileTransformedView(const olc::vi2d& vViewArea, const olc::vi2d& vTileSize)
737 {
738 Initialise(vViewArea, vTileSize);
739 }
740
741
743 {
744 return ScreenToWorld({ 0,0 }).floor();
745 }
746
748 {
750 }
751
753 {
755 }
756
758 {
759 return ScreenToWorld(vPos).floor();
760 }
761
763 {
764 return { int32_t((m_vWorldOffset.x - std::floor(m_vWorldOffset.x)) * m_vWorldScale.x),
765 int32_t((m_vWorldOffset.y - std::floor(m_vWorldOffset.y)) * m_vWorldScale.y) };
766 }
767}
768
769#endif
770#endif
Definition olcPixelGameEngine.h:1089
Definition olcPixelGameEngine.h:1615
static PixelGameEngine * pge
Definition olcPixelGameEngine.h:1627
Definition olcPixelGameEngine.h:1225
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 olcPixelGameEngine.h:1047
Pixel Sample(float x, float y) const
int32_t height
Definition olcPixelGameEngine.h:1060
@ NONE
Definition olcPixelGameEngine.h:1062
int32_t width
Definition olcPixelGameEngine.h:1059
Definition olcPGEX_TransformedView.h:220
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:94
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:136
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:133
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:131
void DrawRect(const olc::vf2d &pos, const olc::vf2d &size, olc::Pixel p=olc::WHITE)
olc::vf2d m_vWorldOffset
Definition olcPGEX_TransformedView.h:127
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:132
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:128
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:130
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:135
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:129
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:134
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:593
v_2d< float > vf2d
Definition olcPixelGameEngine.h:894
static const Pixel WHITE(255, 255, 255)
bool bPressed
Definition olcPixelGameEngine.h:999
bool bReleased
Definition olcPixelGameEngine.h:1000
bool bHeld
Definition olcPixelGameEngine.h:1001
Definition olcPixelGameEngine.h:924
Mode
Definition olcPixelGameEngine.h:931
constexpr v_2d clamp(const v_2d &v1, const v_2d &v2) const
Definition olcPixelGameEngine.h:702
T x
Definition olcPixelGameEngine.h:604
T y
Definition olcPixelGameEngine.h:606
constexpr v_2d ceil() const
Definition olcPixelGameEngine.h:660
constexpr v_2d floor() const
Definition olcPixelGameEngine.h:654