Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
RenderHelper.cpp
1 /*
2  Harmonic Flow Framework
3  Copyright (C) 2011-2018 Andreas Widen <andreas@harmonicflow.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "RenderHelper.h"
22 #include "Environment.h"
23 
24 #include <assert.h>
25 
26 using namespace HFCore;
27 
28 #include "debug/CrtDbgNew.h"
29 
31 {
32  mClipRectWasEnabled = false;
33  mBatchRenderingEnabled = false;
34 }
35 
37 {
38 }
39 
40 fp32_hf RenderHelper::clamp(fp32_hf val, fp32_hf high, fp32_hf low)
41 {
42  fp32_hf retVal = val;
43 
44  if (val > high)
45  {
46  retVal = high;
47  }
48  else if (val < low)
49  {
50  retVal = low;
51  }
52 
53  return retVal;
54 }
55 
56 void RenderHelper::enableColorization(Graphics *g, Color color, fp32_hf alpha)
57 {
58  assert(g != NULL);
59 
60  g->setColorizationEnabled(true);
61  g->setColor(color);
62  g->setAlpha(alpha);
63 }
64 
65 void RenderHelper::disableColorization(Graphics *g)
66 {
67  assert(g != NULL);
68 
69  g->setColorizationEnabled(false);
70 }
71 
72 void RenderHelper::enableDrawMode(Graphics *g, Graphics::DrawMode drawMode)
73 {
74  assert(g != NULL);
75 
76  if (drawMode != Graphics::DRAWMODE_NORMAL)
77  {
78  g->setDrawMode(drawMode);
79  }
80 }
81 
82 void RenderHelper::resetDrawMode(Graphics *g, Graphics::DrawMode curDrawMode)
83 {
84  assert(g != NULL);
85 
86  if (curDrawMode != Graphics::DRAWMODE_NORMAL)
87  {
89  }
90 }
91 
93  fp32_hf start, fp32_hf end)
94 {
95  fp32_hf diff = 0.0f;
96  if (end < start)
97  {
98  diff = start - end;
99  }
100  else
101  {
102  diff = end - start;
103  }
104 
105  fp32_hf elapsedTime = (HFCORE_ENV->getTime() - startTime);
106  fp32_hf inc = (elapsedTime / duration) * diff;
107  fp32_hf val = 0.0f;
108 
109  if (end < start)
110  {
111  val = clamp(start - inc, start, end);
112  }
113  else
114  {
115  val = clamp(start + inc, end, start);
116  }
117  return val;
118 }
119 
121 {
122  if (clipRect != Rect::ZERO())
123  {
124  g->enableClipRect(true);
125  g->setClipRect(clipRect);
126  }
127 }
128 
130 {
131  g->enableClipRect(false);
132 }
133 
135  Rect clipRect)
136 {
137  assert(g != NULL);
138 
139  g->beginBatch(mode, clipRect);
140  mBatchRenderingEnabled = true;
141 }
142 
143 void RenderHelper::endBatch(Graphics *g, bool render)
144 {
145  assert(g != NULL);
146 
147  g->endBatch(render);
148  mBatchRenderingEnabled = false;
149 }
150 
152 {
153  assert(g != NULL);
154 
155  g->clearBatch();
156  mBatchRenderingEnabled = false;
157 }
158 
160 {
161  assert(g != NULL);
162 
163  g->renderBatch(mode);
164 }
165 
167 {
168  assert(g != NULL);
169 
170  g->renderBatchAll();
171 }
172 
174 {
175  assert(g != NULL);
176 
177  g->clearBatchAll();
178  mBatchRenderingEnabled = false;
179 }
180 
182 {
183  assert(g != NULL);
184 
185  g->beginBatchUI(clipRect);
186  mBatchRenderingEnabled = true;
187 }
188 
190 {
191  assert(g != NULL);
192 
193  g->endBatchUI();
194  mBatchRenderingEnabled = false;
195 }
196 
198 {
199  assert(g != NULL);
200 
201  g->clearBatchUI();
202  mBatchRenderingEnabled = false;
203 }
204 
206 {
207  assert(g != NULL);
208 
209  g->renderBatchUI();
210 }
211 
213 {
214  assert(g != NULL);
215 
216  g->setCreateNewBatchRenderQueue(create);
217 }
218 
221 {
222  assert(g != NULL);
223 
224  g->setCreateNewBatchPrimitiveQueue(create, type);
225 }
226 
228  fp32_hf x,
229  fp32_hf y,
230  Color color,
231  Graphics::DrawMode drawMode)
232 {
233  assert(g != NULL);
234 
235  if (mBatchRenderingEnabled)
236  {
237  g->drawPointBatch(x, y, color, drawMode);
238  }
239  else
240  {
241  g->setColor(color);
242  g->drawPoint(x, y);
243  }
244 }
245 
247  fp32_hf cx,
248  fp32_hf cy,
249  Color color,
250  fp32_hf radiusw,
251  fp32_hf radiush,
252  int32_hf numSegments,
253  bool filled,
254  Graphics::DrawMode drawMode)
255 {
256  assert(g != NULL);
257 
258  g->setColor(color);
259  if (filled)
260  {
261  g->fillEllipse(cx, cy, radiusw, radiush, numSegments);
262 
263  // draw antialiased outline:
264  g->drawEllipse(cx, cy, radiusw, radiush, numSegments);
265  }
266  else
267  {
268  g->drawEllipse(cx, cy, radiusw, radiush, numSegments);
269  }
270 }
271 
273  fp32_hf cx,
274  fp32_hf cy,
275  Color color,
276  fp32_hf radius,
277  int32_hf numSegments,
278  bool filled,
279  Graphics::DrawMode drawMode)
280 {
281  assert(g != NULL);
282 
283  g->setColor(color);
284  if (filled)
285  {
286  g->fillCircle(cx, cy, radius, numSegments);
287 
288  // draw antialiased outline:
289  g->drawCircle(cx, cy, radius, numSegments);
290  }
291  else
292  {
293  g->drawCircle(cx, cy, radius, numSegments);
294  }
295 }
296 
298  fp32_hf x0,
299  fp32_hf y0,
300  fp32_hf x1,
301  fp32_hf y1,
302  Color color,
303  Graphics::DrawMode drawMode)
304 {
305  assert(g != NULL);
306 
307  if (mBatchRenderingEnabled)
308  {
309  g->drawLineBatch(x0, y0, x1, y1, color, drawMode);
310  }
311  else
312  {
313  g->setColor(color);
314  g->drawLine(x0, y0, x1, y1);
315  }
316 }
317 
319  fp32_hf x0,
320  fp32_hf y0,
321  fp32_hf x1,
322  fp32_hf y1,
323  fp32_hf x2,
324  fp32_hf y2,
325  Color color,
326  bool filled,
327  Graphics::DrawMode drawMode)
328 {
329  assert(g != NULL);
330 
331  if (mBatchRenderingEnabled)
332  {
333  if (filled)
334  {
335  g->fillTriangleBatch(x0, y0, x1, y1, x2, y2, color, drawMode);
336  }
337  else
338  {
339  g->drawTriangleBatch(x0, y0, x1, y1, x2, y2, color, drawMode);
340  }
341  }
342  else
343  {
344  g->setColor(color);
345  if (filled)
346  {
347  g->fillTriangle(x0, y0, x1, y1, x2, y2);
348 
349  // draw antialiased outline:
350  g->drawTriangle(x0, y0, x1, y1, x2, y2);
351  }
352  else
353  {
354  g->drawTriangle(x0, y0, x1, y1, x2, y2);
355  }
356  }
357 }
358 
360  fp32_hf h, Color color,
361  Graphics::DrawMode drawMode)
362 {
363  assert(g != NULL);
364 
365  if (mBatchRenderingEnabled)
366  {
367  g->fillRectBatch(x0, y0, w, h, color, drawMode);
368  }
369  else
370  {
371  g->setColor(color);
372  g->fillRect(x0, y0, w, h);
373  }
374 }
375 
377  const Rect &rect,
378  Color color,
379  Graphics::DrawMode drawMode)
380 {
381  drawRect(g, rect.getX(), rect.getY(),
382  rect.getWidth(), rect.getHeight(),
383  color, drawMode);
384 }
385 
387  int32_hf rectWidth, int32_hf strWidth)
388 {
389  // Left Justify
390  if (halign == TEXT_HALIGN_LEFT)
391  return rectPosX;
392  // Center Justify
393  else if (halign == TEXT_HALIGN_CENTER)
394  return rectPosX + ((rectWidth - strWidth) / 2);
395  // Right Justify
396  else if (halign == TEXT_HALIGN_RIGHT)
397  return rectPosX + (rectWidth - strWidth);
398  // default to left
399  else
400  return rectPosX;
401 }
402 
404  int32_hf rectHeight, int32_hf strHeight)
405 {
406  // Top Justify
407  if (valign == TEXT_VALIGN_TOP)
408  return rectPosY;
409  // Center Justify
410  else if (valign == TEXT_VALIGN_CENTER)
411  return rectPosY + ((rectHeight - strHeight) / 2);
412  // Bottom Justify
413  else if (valign == TEXT_VALIGN_BOTTOM)
414  return rectPosY + (rectHeight - strHeight);
415  // default to Top
416  else
417  return rectPosY;
418 }
419 
420 std::wstring RenderHelper::getTextSmallerThenWidth(std::wstring text, Font *font,
421  int32_hf width, int32_hf lineStartPos,
422  uint32_hf curPos, fp32_hf scale)
423 {
424  assert(font != NULL);
425 
426  std::wstring newString;
427 
428  std::wstring subStr = text.substr(lineStartPos, curPos);
429  for (uint32_hf i = lineStartPos; i <= curPos; i++)
430  {
431  int32_hf j = curPos - i;
432  std::wstring tmpBuff = subStr.substr(0, j);
433  int32_hf curWidth = font->getStringWidth(tmpBuff.c_str(), scale);
434 
435  if (curWidth <= width)
436  {
437  newString = tmpBuff;
438  break;
439  }
440  }
441 
442  return newString;
443 }
444 
446  Rect &rect, const UString &line,
447  int32_hf lineSpacing)
448 {
449  assert(g != NULL);
450  assert(font != NULL);
451 
452  // Just call the Draw version as it returns height. Color param is not used here.
453  // renderString param = false just run same code but without drawing :)
454  // This method is mainly used to calculate height when Aligning vertically Centered or Bottom.
455  return drawWordWrappedString(g, font, Color(255, 255, 255), rect,
456  line, lineSpacing, -1, -1, false);
457 }
458 
460  int32_hf y, int32_hf widgetPosX, int32_hf widgetWidth,
461  const UString &string, fp32_hf scale)
462 {
463  assert(g != NULL);
464  assert(font != NULL);
465 
466  int32_hf strWidth = font->getStringWidth(string, scale);
467  int32_hf x = ((widgetWidth - strWidth) / 2 + widgetPosX);
468 
469  if (mBatchRenderingEnabled)
470  {
471  font->drawStringBatch(g, string, color, (fp32_hf)x, (fp32_hf)y, scale);
472  }
473  else
474  {
475  enableColorization(g, color, (fp32_hf)color.getAlphaf() / 255);
476 
477  g->pushTransform();
478  g->translate((fp32_hf)x, (fp32_hf)y);
479  font->drawString(g, string, scale);
480  g->popTransform();
481 
482  disableColorization(g);
483  }
484 
485  return Rect((fp32_hf)x, (fp32_hf)y,
486  (fp32_hf)strWidth, (fp32_hf)font->getHeight());
487 }
488 
490  const UString &string, int32_hf x, int32_hf y,
491  fp32_hf scale)
492 {
493  assert(g != NULL);
494  assert(font != NULL);
495 
496  fp32_hf w = 0;
497 
498  if (mBatchRenderingEnabled)
499  {
500  font->drawStringBatch(g, string, color,
501  (fp32_hf)x, (fp32_hf)y, scale);
502  }
503  else
504  {
505  enableColorization(g, color, (fp32_hf)color.getAlphaf() / 255);
506 
507  g->pushTransform();
508  g->translate((fp32_hf)x, (fp32_hf)y);
509  w = font->drawString(g, string, scale);
510  g->popTransform();
511 
512  disableColorization(g);
513  }
514 
515  return w;
516 }
517 
519  const Rect &rect, const UString &string,
520  int32_hf lineSpacing, int32_hf valign, int32_hf halign,
521  bool renderString, fp32_hf scale)
522 {
523  assert(g != NULL);
524  assert(font != NULL);
525 
526  std::wstring text = string.wc_str();
527 
528  int32_hf offsetY = 0;
529 
530  if (lineSpacing == -1)
531  {
532  lineSpacing = (int32_hf)(font->getLineSpacing() * scale);
533  }
534 
535  std::wstring curString;
536  uint32_hf curPos = 0;
537  int32_hf curPosY = (int32_hf)rect.getY();
538  int32_hf lineStartPos = 0;
539  int32_hf curWidth = 0;
540  wchar_t curChar = 0;
541  wchar_t prevChar = 0;
542  int32_hf spacePos = -1;
543  int32_hf indentX = 0;
544  bool removeOddChar = false;
545  bool forceRender = false;
546 
547  if (valign == TEXT_VALIGN_CENTER || (valign == TEXT_VALIGN_BOTTOM && renderString))
548  {
549  int32_hf strHeight = getWordWrappedHeight(g, font, rect, string, lineSpacing);
550  strHeight = (int32_hf)(strHeight * scale);
551  curPosY = getVAlignPosY(valign, (int32_hf)rect.getY(),
552  (int32_hf)rect.getHeight(), (int32_hf)strHeight);
553  }
554 
555  while (curPos < text.length())
556  {
557  curChar = text[curPos];
558  if (curChar == 94) // Handle special '^' color modifier
559  {
560  if (curPos + 1 < text.length())
561  {
562  if ((uint32_hf)text[curPos + 1] == 94)
563  {
564  curPos++; // literal '^' -> just skip the extra '^'
565  }
566  else
567  {
568  curPos += 8;
569  continue; // skip the color specifier when calculating the width
570  }
571  }
572  }
573  else if (curChar == 32) // blank space " "
574  {
575  spacePos = curPos;
576  }
577  else if (curChar == 10) // \n
578  {
579  curWidth = (int32_hf)rect.getWidth() + 1; // force word wrap
580  spacePos = curPos;
581  curPos++; // skip enter on next go round
582  }
583  // utf8 version for \n
584  else if (prevChar == 92 && curChar == 110)
585  {
586  curWidth = (int32_hf)rect.getWidth() + 1; // force word wrap
587  spacePos = curPos;
588  curPos++; // skip enter on next go round
589  removeOddChar = true;
590  }
591 
592  curWidth += font->getCharWidth(curChar, scale);
593  prevChar = curChar;
594 
595  if (curWidth > rect.getWidth()) // need to wrap
596  {
597  // if no space pos is found we need to get text smaller then rect.getWidth()
598  if (spacePos == -1)
599  {
600  curString = getTextSmallerThenWidth(text, font, (int32_hf)rect.getWidth(),
601  lineStartPos, curPos, scale);
602  curPos = lineStartPos + curString.length();
603  forceRender = true;
604  }
605  else
606  {
607  curString = text.substr(lineStartPos, spacePos - lineStartPos);
608  }
609  if (removeOddChar)
610  {
611  curString = curString.substr(0, curString.length() - 1);
612  removeOddChar = false;
613  }
614 
615  int32_hf writtenWidth = 0;
616  if (spacePos != -1 || forceRender)
617  {
618  int32_hf physPos = curPosY;
619  if ((physPos >= curPosY) && (physPos < rect.getY() +
620  rect.getHeight() + lineSpacing))
621  {
622  if (renderString)
623  {
624  int32_hf strwidth = font->getStringWidth(curString.c_str(), scale);
625  int32_hf halignPosX = getHAlignPosX(halign, (int32_hf)rect.getX(),
626  (int32_hf)rect.getWidth(), strwidth);
627 
628  drawString(g, font, color, curString.c_str(), halignPosX, physPos, scale);
629  forceRender = false;
630  }
631 
632  curPosY += lineSpacing; // offsetY;
633  }
634  else
635  {
636  break;
637  }
638 
639  writtenWidth = curWidth + indentX;
640 
641  if (writtenWidth < 0)
642  {
643  break;
644  }
645 
646  if (spacePos == -1)
647  {
648  // curPos++;
649  }
650  else
651  {
652  curPos = spacePos + 1;
653  }
654  if ((uint32_hf)text[curPos] != 10) // \n
655  {
656  while (curPos < text.length() && (uint32_hf)text[curPos] == 32) // blank space " "
657  {
658  curPos++;
659  }
660  }
661  lineStartPos = curPos;
662  }
663 
664  lineStartPos = curPos;
665  spacePos = -1;
666  curWidth = 0;
667  indentX = 0;
668  offsetY += lineSpacing;
669  }
670  else
671  curPos++;
672  } // end while
673 
674  if (lineStartPos < (int32_hf)text.length()) // write the last piece
675  {
676  if (renderString)
677  {
678  curString = text.substr(lineStartPos, text.length() - lineStartPos);
679  int32_hf strwidth = font->getStringWidth(curString.c_str(), scale);
680  int32_hf halignPosX = getHAlignPosX(halign, (int32_hf)rect.getX(),
681  (int32_hf)rect.getWidth(), strwidth);
682 
683  drawString(g, font, color, curString.c_str(), halignPosX, curPosY, scale);
684  }
685  offsetY += lineSpacing;
686  }
687  else if ((uint32_hf)curChar == 13) // \n
688  {
689  offsetY += lineSpacing;
690  }
691 
692 
693  return offsetY;// - lineSpacing;
694 }
695 
696 void RenderHelper::drawImage(Graphics *g, Image *img, Rect &srcRect,
697  fp32_hf x, fp32_hf y, fp32_hf alpha,
698  Graphics::DrawMode drawMode,
699  Graphics::MagFilter magFilter,
700  Graphics::MinFilter minFilter)
701 {
702  assert(g != NULL);
703  assert(img != NULL);
704 
705  if (mBatchRenderingEnabled)
706  {
707  Color color(255, 255, 255, (int32_hf)(255 * alpha));
708  if (srcRect == Rect::ZERO())
709  {
710  Rect destRect(x, y,
711  (fp32_hf)img->getWidth(),
712  (fp32_hf)img->getHeight());
713  g->drawImageBatch(img, destRect, Rect::ZERO(), color, 1.0f,
714  1.0f, 0.0f, drawMode, magFilter, minFilter);
715  }
716  else
717  {
718  Rect destRect(x, y,
719  srcRect.getWidth(),
720  srcRect.getHeight());
721  g->drawImageBatch(img, destRect, srcRect, color, 1.0f, 1.0f, 0.0f,
722  drawMode, magFilter, minFilter);
723  }
724  }
725  else
726  {
727  Color color(255, 255, 255);
728  enableColorization(g, color, alpha);
729  enableDrawMode(g, drawMode);
730 
731  g->pushTransform();
732  g->translate(x, y);
733  g->scale(1.0f, 1.0f); // to account for logicalScale if any:
734  if (srcRect == Rect::ZERO())
735  {
736  g->drawImage(img, magFilter, minFilter);
737  }
738  else
739  {
740  g->drawImage(img, srcRect, magFilter, minFilter);
741  }
742  g->popTransform();
743 
744  disableColorization(g);
745  resetDrawMode(g, drawMode);
746  }
747 }
748 
749 void RenderHelper::drawImageF(Graphics *g, Image *img, Rect &srcRect,
750  fp32_hf x, fp32_hf y, fp32_hf alpha, fp32_hf scaleX,
751  fp32_hf scaleY, fp32_hf rotation, Graphics::DrawMode drawMode,
752  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
753 {
754  assert(g != NULL);
755  assert(img != NULL);
756 
757  if (mBatchRenderingEnabled)
758  {
759  Color color(255, 255, 255, (int32_hf)(255 * alpha));
760  if (srcRect == Rect::ZERO())
761  {
762  Rect destRect(x, y, (fp32_hf)img->getWidth(), (fp32_hf)img->getHeight());
763  g->drawImageBatch(img, destRect, Rect::ZERO(), color, scaleX, scaleY,
764  rotation, drawMode, magFilter, minFilter);
765  }
766  else
767  {
768  Rect destRect(x, y, srcRect.getWidth(), srcRect.getHeight());
769  g->drawImageBatch(img, destRect, srcRect, color, scaleX, scaleY,
770  rotation, drawMode, magFilter, minFilter);
771  }
772  }
773  else
774  {
775  Color color(255, 255, 255);
776  enableColorization(g, color, alpha);
777  enableDrawMode(g, drawMode);
778 
779  g->pushTransform();
780  g->translate(x, y);
781  g->rotateZDeg(rotation);
782  g->scale(scaleX, scaleY);
783  if (srcRect == Rect::ZERO())
784  {
785  g->drawImage(img, magFilter, minFilter);
786  }
787  else
788  {
789  g->drawImage(img, srcRect, magFilter, minFilter);
790  }
791  g->popTransform();
792 
793  disableColorization(g);
794  resetDrawMode(g, drawMode);
795  }
796 }
797 
799  fp32_hf x, fp32_hf y, fp32_hf scaleX, fp32_hf scaleY,
800  fp32_hf alpha, Graphics::DrawMode drawMode,
801  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
802 {
803  assert(g != NULL);
804  assert(img != NULL);
805 
806  if (mBatchRenderingEnabled)
807  {
808  Color color(255, 255, 255, (int32_hf)(255 * alpha));
809  if (srcRect == Rect::ZERO())
810  {
811  Rect destRect(x, y, (fp32_hf)img->getWidth(), (fp32_hf)img->getHeight());
812  g->drawImageBatch(img, destRect, Rect::ZERO(), color, scaleX, scaleY, 0.0f,
813  drawMode, magFilter, minFilter);
814  }
815  else
816  {
817  Rect destRect(x, y, srcRect.getWidth(), srcRect.getHeight());
818  g->drawImageBatch(img, destRect, srcRect, color, scaleX, scaleY, 0.0f,
819  drawMode, magFilter, minFilter);
820  }
821  }
822  else
823  {
824  Color color(255, 255, 255);
825  enableColorization(g, color, alpha);
826  enableDrawMode(g, drawMode);
827 
828  g->pushTransform();
829  g->translate(x, y);
830  g->scale(scaleX, scaleY);
831  if (srcRect == Rect::ZERO())
832  {
833  g->drawImage(img, magFilter, minFilter);
834  }
835  else
836  {
837  g->drawImage(img, srcRect, magFilter, minFilter);
838  }
839  g->popTransform();
840 
841  disableColorization(g);
842  resetDrawMode(g, drawMode);
843  }
844 }
845 
847  fp32_hf y, fp32_hf rotation, fp32_hf scale, fp32_hf alpha,
848  Graphics::DrawMode drawMode, Graphics::MagFilter magFilter,
849  Graphics::MinFilter minFilter)
850 {
851  assert(g != NULL);
852  assert(img != NULL);
853 
854  if (mBatchRenderingEnabled)
855  {
856  Color color(255, 255, 255, (int32_hf)(255 * alpha));
857  if (srcRect == Rect::ZERO())
858  {
859  Rect destRect(x, y, (fp32_hf)img->getWidth(), (fp32_hf)img->getHeight());
860  g->drawImageBatch(img, destRect, Rect::ZERO(), color, scale, scale, rotation,
861  drawMode, magFilter, minFilter);
862  }
863  else
864  {
865  Rect destRect(x, y, srcRect.getWidth(), srcRect.getHeight());
866  g->drawImageBatch(img, destRect, srcRect, color, scale, scale, rotation,
867  drawMode, magFilter, minFilter);
868  }
869  }
870  else
871  {
872  Color color(255, 255, 255);
873  enableColorization(g, color, alpha);
874  enableDrawMode(g, drawMode);
875 
876  g->pushTransform();
877  g->translate(x, y);
878  g->rotateZDeg(rotation);
879  g->scale(scale, scale);
880  if (srcRect == Rect::ZERO())
881  {
882  g->drawImage(img, magFilter, minFilter);
883  }
884  else
885  {
886  g->drawImage(img, srcRect, magFilter, minFilter);
887  }
888  g->popTransform();
889 
890  disableColorization(g);
891  resetDrawMode(g, drawMode);
892  }
893 }
894 
896  fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scale,
897  fp32_hf alphaStart, fp32_hf alphaEnd, Graphics::DrawMode drawMode,
898  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
899 {
900  assert(g != NULL);
901  assert(img != NULL);
902 
903  fp32_hf alpha = getVal(startTime, duration, alphaStart, alphaEnd);
904 
905  if (mBatchRenderingEnabled)
906  {
907  Color color(255, 255, 255, (int32_hf)(255 * alpha));
908  if (srcRect == Rect::ZERO())
909  {
910  Rect destRect(imgX, imgY, (fp32_hf)img->getWidth(), (fp32_hf)img->getHeight());
911  g->drawImageBatch(img, destRect, Rect::ZERO(), color, scale, scale, 0.0f,
912  drawMode, magFilter, minFilter);
913  }
914  else
915  {
916  Rect destRect(imgX, imgY, srcRect.getWidth(), srcRect.getHeight());
917  g->drawImageBatch(img, destRect, srcRect, color, scale, scale, 0.0f,
918  drawMode, magFilter, minFilter);
919  }
920  }
921  else
922  {
923  Color color(255, 255, 255);
924  enableColorization(g, color, alpha);
925  enableDrawMode(g, drawMode);
926 
927  g->pushTransform();
928  g->translate(imgX, imgY);
929  g->scale(scale, scale);
930  if (srcRect == Rect::ZERO())
931  {
932  g->drawImage(img, magFilter, minFilter);
933  }
934  else
935  {
936  g->drawImage(img, srcRect, magFilter, minFilter);
937  }
938  g->popTransform();
939 
940  disableColorization(g);
941  resetDrawMode(g, drawMode);
942  }
943 
944  return alpha;
945 }
946 
948  fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scale,
949  fp32_hf alphaStart, fp32_hf alphaEnd, Graphics::DrawMode drawMode,
950  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
951 {
952  assert(g != NULL);
953  assert(img != NULL);
954 
955  fp32_hf alpha = getVal(startTime, duration, alphaStart, alphaEnd);
956 
957  if (mBatchRenderingEnabled)
958  {
959  Color color(255, 255, 255, (int32_hf)(255 * alpha));
960  if (srcRect == Rect::ZERO())
961  {
962  Rect destRect(imgX, imgY, (fp32_hf)img->getWidth(), (fp32_hf)img->getHeight());
963  g->drawImageBatch(img, destRect, Rect::ZERO(), color, scale, scale, 0.0f,
964  drawMode, magFilter, minFilter);
965  }
966  else
967  {
968  Rect destRect(imgX, imgY, srcRect.getWidth(), srcRect.getHeight());
969  g->drawImageBatch(img, destRect, srcRect, color, scale, scale, 0.0f,
970  drawMode, magFilter, minFilter);
971  }
972  }
973  else
974  {
975  Color color(255, 255, 255);
976  enableColorization(g, color, alpha);
977  enableDrawMode(g, drawMode);
978 
979  g->pushTransform();
980  g->translate(imgX, imgY);
981  g->scale(scale, scale);
982  if (srcRect == Rect::ZERO())
983  {
984  g->drawImage(img, magFilter, minFilter);
985  }
986  else
987  {
988  g->drawImage(img, srcRect, magFilter, minFilter);
989  }
990  g->popTransform();
991 
992  disableColorization(g);
993  resetDrawMode(g, drawMode);
994  }
995 
996  return alpha;
997 }
998 
1000  fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scaleStart,
1001  fp32_hf scaleEnd, Graphics::DrawMode drawMode,
1002  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
1003 {
1004  assert(g != NULL);
1005  assert(img != NULL);
1006 
1007  fp32_hf scale = getVal(startTime, duration, scaleStart, scaleEnd);
1008 
1009  drawImageScaled(g, img, srcRect, imgX, imgY, scale, scale, 1.0f,
1010  drawMode, magFilter, minFilter);
1011 
1012  return scale;
1013 }
1014 
1016  fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scaleStart,
1017  fp32_hf scaleEnd, Graphics::DrawMode drawMode,
1018  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
1019 {
1020  assert(g != NULL);
1021  assert(img != NULL);
1022 
1023  fp32_hf scale = getVal(startTime, duration, scaleStart, scaleEnd);
1024 
1025  drawImageScaled(g, img, srcRect, imgX, imgY, scale, scale, 1.0f,
1026  drawMode, magFilter, minFilter);
1027 
1028  return scale;
1029 }
1030 
1032  fp32_hf imgY, fp32_hf startTime, fp32_hf duration,
1033  fp32_hf rotationStart, fp32_hf rotationEnd, fp32_hf alpha,
1034  fp32_hf scale, Graphics::DrawMode drawMode,
1035  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
1036 {
1037  fp32_hf rotation = getVal(startTime, duration, rotationStart, rotationEnd);
1038 
1039  drawImageRotated(g, img, srcRect, imgX, imgY, rotation, scale, alpha, drawMode,
1040  magFilter, minFilter);
1041 
1042  return rotation;
1043 }
1044 
1046  fp32_hf fromY, fp32_hf toY, fp32_hf startTime, fp32_hf duration,
1047  fp32_hf scale, fp32_hf alpha, Graphics::DrawMode drawMode,
1048  Graphics::MagFilter magFilter,
1049  Graphics::MinFilter minFilter)
1050 {
1051  assert(g != NULL);
1052  assert(img != NULL);
1053 
1054  fp32_hf newPosY = getVal(startTime, duration, fromY, toY);
1055 
1056  if (scale == 1.0f)
1057  {
1058  drawImage(g, img, srcRect, posX, newPosY, alpha, drawMode,
1059  magFilter, minFilter);
1060  }
1061  else
1062  {
1063  drawImageScaled(g, img, srcRect, posX, newPosY, scale, scale,
1064  alpha, drawMode, magFilter, minFilter);
1065  }
1066 
1067  return newPosY;
1068 }
1069 
1071  fp32_hf fromX, fp32_hf toX, fp32_hf startTime, fp32_hf duration,
1072  fp32_hf scale, fp32_hf alpha, Graphics::DrawMode drawMode,
1073  Graphics::MagFilter magFilter,
1074  Graphics::MinFilter minFilter)
1075 {
1076  assert(g != NULL);
1077  assert(img != NULL);
1078 
1079  fp32_hf newPosX = getVal(startTime, duration, fromX, toX);
1080 
1081  if (scale == 1.0f)
1082  {
1083  drawImage(g, img, srcRect, newPosX, posY, alpha, drawMode,
1084  magFilter, minFilter);
1085  }
1086  else
1087  {
1088  drawImageScaled(g, img, srcRect, newPosX, posY, scale, scale,
1089  alpha, drawMode, magFilter, minFilter);
1090  }
1091 
1092  return newPosX;
1093 }
1094 
1095 void RenderHelper::moveTo(Graphics *g, Image *img, Rect &srcRect, fp32_hf fromX,
1096  fp32_hf toX, fp32_hf fromY, fp32_hf toY, fp32_hf startTime,
1097  fp32_hf duration, fp32_hf *newPosX, fp32_hf *newPosY, fp32_hf scale,
1098  fp32_hf alpha, Graphics::DrawMode drawMode,
1099  Graphics::MagFilter magFilter, Graphics::MinFilter minFilter)
1100 {
1101  assert(g != NULL);
1102  assert(img != NULL);
1103 
1104  // X/Y movement
1105  fp32_hf posX = getVal(startTime, duration, fromX, toX);
1106  fp32_hf posY = getVal(startTime, duration, fromY, toY);
1107 
1108  if (scale == 1.0f)
1109  {
1110  drawImage(g, img, srcRect, posX, posY, alpha, drawMode,
1111  magFilter, minFilter);
1112  }
1113  else
1114  {
1115  drawImageScaled(g, img, srcRect, posX, posY, scale, scale,
1116  alpha, drawMode, magFilter, minFilter);
1117  }
1118 
1119  *newPosX = posX;
1120  *newPosY = posY;
1121 
1122 }
unsigned int uint32_hf
A type definition for unsigned int.
Definition: HFDataTypes.h:354
virtual void setColor(Color color)=0
Set Color to use for subsequent drawing operations.
void endBatch(Graphics *g, bool render)
End current Batch.
virtual fp32_hf drawStringBatch(Graphics *g, const UString &str, Color color, fp32_hf x, fp32_hf y, fp32_hf scale=1)=0
Draw a string (batched).
Rect drawCenteredString(Graphics *g, Font *font, Color color, int32_hf y, int32_hf widgetPosX, int32_hf widgetWidth, const UString &string, fp32_hf scale=1.0f)
Draw a centered string.
virtual int32_hf getStringWidth(const UString &str, fp32_hf scale=1.0f)=0
Get the width of str.
virtual void endBatch(bool render)=0
End current Batch.
virtual void setAlpha(fp32_hf alpha)=0
Set the alpha value of the current Color.
fp32_hf getAlphaf() const
Get alpha color component as fp32_hf.
Definition: Color.cpp:126
virtual void renderBatchUI()=0
Render UI Widget content Batch.
fp32_hf drawString(Graphics *g, Font *font, Color color, const UString &string, int32_hf x, int32_hf y, fp32_hf scale=1.0f)
Draw a string.
virtual int32_hf getCharWidth(const wchar_t ch, fp32_hf scale=1.0f)=0
Get the width of a single character ch.
void clearBatchUI(Graphics *g)
Clear UI Widget Batch.
void beginBatchUI(Graphics *g, Rect clipRect=Rect::ZERO())
Begin Batch for UI Widget content using optional clipping Rect.
MinFilter
Minification filter to use for Images.
Definition: Graphics.h:177
Horizontal text alignment RIGHT.
Definition: RenderHelper.h:60
void drawImageScaled(Graphics *g, Image *img, fp32_hf x, fp32_hf y, fp32_hf scale, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw a Image scaled.
Definition: RenderHelper.h:588
void setCreateNewBatchRenderQueue(Graphics *g, bool create)
Determines whether to create a new Batch Render queue.
void disableClipRect(Graphics *g)
Disable clip Rect.
fp32_hf getVal(fp32_hf startTime, fp32_hf duration, fp32_hf start, fp32_hf end)
Get a value in the specified range.
Horizontal text alignment LEFT.
Definition: RenderHelper.h:58
fp32_hf moveToY(Graphics *g, Image *img, fp32_hf posX, fp32_hf fromY, fp32_hf toY, fp32_hf startTime, fp32_hf duration, fp32_hf scale=1.0f, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and move Image in Y direction.
Definition: RenderHelper.h:822
Interface for unicode string class UString.
Definition: UString.h:35
virtual int32_hf getLineSpacing()=0
Get Font line spacing.
virtual void clearBatch()=0
Clear current Batch.
void clearBatchAll(Graphics *g)
Clear Batch. (each available Graphics::BatchMode)
fp32_hf getWidth() const
Get Rect Width (or maxX).
Definition: Rect.h:168
int32_hf drawWordWrappedString(Graphics *g, Font *font, Color color, const Rect &rect, const UString &string, int32_hf lineSpacing=-1, int32_hf valign=TEXT_VALIGN_TOP, int32_hf halign=TEXT_HALIGN_LEFT, bool renderString=true, fp32_hf scale=1.0f)
Draw a word wrapped string within given rect Rect area and specified halign and valign horizontal and...
virtual void drawTriangle(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, fp32_hf x2, fp32_hf y2)=0
Draw a Triangle outline (not filled).
DrawMode
Draw / Blend modes.
Definition: Graphics.h:141
int int32_hf
A type definition for int.
Definition: HFDataTypes.h:349
virtual void clearBatchAll()=0
Clear Batch. (each available Graphics::BatchMode)
virtual void setColorizationEnabled(bool enabled)=0
Determines whether or not the color specified by setColor() will be used to colorize image drawing op...
Vertical text alignment CENTER.
Definition: RenderHelper.h:69
fp32_hf zoomOut(Graphics *g, Image *img, fp32_hf imgX, fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scaleStart=1.0f, fp32_hf scaleEnd=0.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and zoom out Image.
Definition: RenderHelper.h:753
virtual void fillTriangleBatch(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, fp32_hf x2, fp32_hf y2, Color color, DrawMode drawMode=DRAWMODE_NORMAL)=0
Draw a Triangle Batch (filled).
PrimitiveType
Primitive types used for Batch Rendering. (used internally)
Definition: Graphics.h:253
void drawRect(Graphics *g, fp32_hf x0, fp32_hf y0, fp32_hf w, fp32_hf h, Color color, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a Rect.
virtual void setDrawMode(DrawMode mode)=0
Set Graphics::DrawMode for subsequent drawing operations.
void drawRect(Graphics *g, const Rect &rect, Color color, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a Rect.
static Rect ZERO()
Initialize Rect with 0 for all members.
Definition: Rect.h:141
virtual void setCreateNewBatchRenderQueue(bool create)=0
Determines whether to create a new Batch Render queue.
virtual void drawLineBatch(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, Color color, DrawMode drawMode=DRAWMODE_NORMAL)=0
Draw a Line between two points Batch.
void endBatchUI(Graphics *g)
End Batch for UI Widget content.
virtual void beginBatch(BatchMode mode, Rect clipRect=Rect::ZERO())=0
Begin Batch using specified Graphics::BatchMode and optional clipping Rect.
virtual void scale(fp32_hf s)=0
Multiply the current matrix by a general scaling matrix.
int32_hf getHAlignPosX(int32_hf halign, int32_hf rectPosX, int32_hf rectWidth, int32_hf strWidth)
Get optimal horizontal position X based on alignment wanted.
void renderBatch(Graphics *g, Graphics::BatchMode mode)
Render Batch for given Graphics::BatchMode.
void drawLine(Graphics *g, fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, Color color, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a Line between two points.
virtual void drawImage(Image *img, MagFilter magFilter=MAGFILTER_LINEAR, MinFilter minFilter=MINFILTER_LINEAR)=0
Draw Image.
fp32_hf moveToX(Graphics *g, Image *img, fp32_hf posY, fp32_hf fromX, fp32_hf toX, fp32_hf startTime, fp32_hf duration, fp32_hf scale=1.0f, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and move Image in X direction.
Definition: RenderHelper.h:856
void drawCircle(Graphics *g, fp32_hf cx, fp32_hf cy, Color color, fp32_hf radius, int32_hf numSegments, bool filled, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a circle.
int32_hf getVAlignPosY(int32_hf valign, int32_hf rectPosY, int32_hf rectHeight, int32_hf strHeight)
Get optimal vertical position Y based on alignment wanted.
virtual void setCreateNewBatchPrimitiveQueue(bool create, PrimitiveType type)=0
Determines whether to create a new Batch Primitive queue.
virtual void pushTransform()=0
Push transforms onto the transform stack.
fp32_hf getY() const
Get Rect Y (or minY).
Definition: Rect.h:159
Horizontal text alignment CENTER.
Definition: RenderHelper.h:59
void drawPoint(Graphics *g, fp32_hf x, fp32_hf y, Color color, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a point.
Interface which act as a convenient rendering helper.
virtual void fillCircle(fp32_hf cx, fp32_hf cy, fp32_hf radius, int32_hf numSegments)=0
Draw a circle (filled).
virtual int32_hf getHeight()=0
Get Font height.
#define NULL
Convenient define for 0.
Definition: HFDataTypes.h:42
void drawImageRotated(Graphics *g, Image *img, fp32_hf x, fp32_hf y, fp32_hf rotation, fp32_hf scale, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw a Image rotated.
Definition: RenderHelper.h:618
int32_hf getWordWrappedHeight(Graphics *g, Font *font, const Rect &rect, const UString &line, int32_hf lineSpacing=-1)
Get word wrapped height for given line of text.
void clearBatch(Graphics *g)
Clear current Batch.
virtual void setClipRect(int32_hf x, int32_hf y, int32_hf width, int32_hf height)=0
Set the clipping Rect to use.
MagFilter
Magnification filter to use for Images.
Definition: Graphics.h:154
virtual void endBatchUI()=0
End Batch for UI Widget content.
Interface for RGBA Color.
Definition: Color.h:51
RenderHelper()
Constructor.
virtual void drawTriangleBatch(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, fp32_hf x2, fp32_hf y2, Color color, DrawMode drawMode=DRAWMODE_NORMAL)=0
Draw a Triangle outline Batch (not filled).
virtual void drawPoint(fp32_hf x, fp32_hf y)=0
Draw a point.
virtual void translate(fp32_hf x, fp32_hf y)=0
Multiply the current matrix by a translation matrix.
virtual void drawCircle(fp32_hf cx, fp32_hf cy, fp32_hf radius, int32_hf numSegments)=0
Draw a circle outline (not filled).
virtual void fillTriangle(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, fp32_hf x2, fp32_hf y2)=0
Draw a Triangle (filled).
fp32_hf getX() const
Get Rect X (or minX).
Definition: Rect.h:150
Vertical text alignment TOP.
Definition: RenderHelper.h:68
virtual ~RenderHelper()
Destructor.
void enableClipRect(Graphics *g, Rect clipRect)
Enable clip Rect.
virtual void enableClipRect(bool enable)=0
Determines whether to enable clipping Rect.
virtual void drawLine(fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1)=0
Draw a Line between two points.
void renderBatchUI(Graphics *g)
Render UI Widget content Batch.
virtual void beginBatchUI(Rect clipRect=Rect::ZERO())=0
Begin Batch for UI Widget content using optional clipping Rect.
virtual void popTransform()=0
Pop transforms from the transform stack.
fp32_hf fadeOut(Graphics *g, Image *img, fp32_hf imgX, fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scale=1.0f, fp32_hf alphaStart=1.0f, fp32_hf alphaEnd=0.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and fade out Image.
Definition: RenderHelper.h:688
virtual void drawEllipse(fp32_hf cx, fp32_hf cy, fp32_hf radiusw, fp32_hf radiush, int32_hf numSegments)=0
Draw a Ellipse outline (not filled).
Definition: Actor.h:34
Interface for Resource type Image.
Definition: Image.h:63
virtual fp32_hf drawString(Graphics *g, const UString &str, fp32_hf scale=1)=0
Draw a string (non batched).
Interface for Resource type Font.
Definition: Font.h:84
fp32_hf fadeIn(Graphics *g, Image *img, fp32_hf imgX, fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scale=1.0f, fp32_hf alphaStart=0.0f, fp32_hf alphaEnd=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and fade in Image.
Definition: RenderHelper.h:652
Singleton interface for platform specific things.
Draw mode default / normal.
Definition: Graphics.h:143
virtual void drawImageBatch(BatchInfo batchInfo)=0
Draw Image Batch.
void moveTo(Graphics *g, Image *img, fp32_hf fromX, fp32_hf toX, fp32_hf fromY, fp32_hf toY, fp32_hf startTime, fp32_hf duration, fp32_hf *newPosX, fp32_hf *newPosY, fp32_hf scale=1.0f, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and move Image in X and Y direction.
Definition: RenderHelper.h:893
void drawImage(Graphics *g, Image *img, fp32_hf x, fp32_hf y, fp32_hf alpha=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw a Image.
Definition: RenderHelper.h:530
BatchMode
Modes available for Batch Rendering.
Definition: Graphics.h:197
virtual void fillRect(fp32_hf x0, fp32_hf y0, fp32_hf w, fp32_hf h)=0
Draw a Rect (filled).
fp32_hf rotate(Graphics *g, Image *img, fp32_hf imgX, fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf rotationStart=0.0f, fp32_hf rotationEnd=360.0f, fp32_hf alpha=1.0f, fp32_hf scale=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and rotate Image.
Definition: RenderHelper.h:787
Specialized Boundary representing a Rect.
Definition: Rect.h:34
virtual void clearBatchUI()=0
Clear UI Widget Batch.
#define HFCORE_ENV
Get HFCore::Environment instance shortcut macro.
Definition: Environment.h:68
Interface for all rendering related things.
Definition: Graphics.h:120
virtual void rotateZDeg(fp32_hf angle)=0
Multiply the current matrix by a rotation matrix.
virtual void drawPointBatch(fp32_hf x, fp32_hf y, Color color, DrawMode drawMode=DRAWMODE_NORMAL)=0
Draw a Point Batch.
void beginBatch(Graphics *g, Graphics::BatchMode mode, Rect clipRect=Rect::ZERO())
Begin Batch using specified Graphics::BatchMode and optional clipping Rect.
Vertical text alignment BOTTOM.
Definition: RenderHelper.h:70
void setCreateNewBatchPrimitiveQueue(Graphics *g, bool create, Graphics::PrimitiveType type)
Determines whether to create a new Batch Primitive queue.
virtual int32_hf getHeight()=0
Get the Image original height.
fp32_hf getHeight() const
Get Rect Height (or maxY).
Definition: Rect.h:177
virtual void renderBatchAll()=0
Render Batch. (each available Graphics::BatchMode)
void renderBatchAll(Graphics *g)
Render Batch. (each available Graphics::BatchMode)
virtual void fillEllipse(fp32_hf cx, fp32_hf cy, fp32_hf radiusw, fp32_hf radiush, int32_hf numSegments)=0
Draw a Ellipse (filled).
void drawTriangle(Graphics *g, fp32_hf x0, fp32_hf y0, fp32_hf x1, fp32_hf y1, fp32_hf x2, fp32_hf y2, Color color, bool filled, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a triangle.
virtual void fillRectBatch(fp32_hf x0, fp32_hf y0, fp32_hf w, fp32_hf h, Color color, DrawMode drawMode=DRAWMODE_NORMAL)=0
Draw a Rect Batch (filled).
void drawEllipse(Graphics *g, fp32_hf cx, fp32_hf cy, Color color, fp32_hf radiusw, fp32_hf radiush, int32_hf numSegments, bool filled, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL)
Draw a Ellipse.
virtual int32_hf getWidth()=0
Get the Image original width.
virtual void renderBatch(BatchMode mode)=0
Render Batch for given Graphics::BatchMode.
fp32_hf zoomIn(Graphics *g, Image *img, fp32_hf imgX, fp32_hf imgY, fp32_hf startTime, fp32_hf duration, fp32_hf scaleStart=0.0f, fp32_hf scaleEnd=1.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw and zoom in Image.
Definition: RenderHelper.h:721
float fp32_hf
A type definition for float.
Definition: HFDataTypes.h:359
void drawImageF(Graphics *g, Image *img, fp32_hf x, fp32_hf y, fp32_hf alpha=1.0f, fp32_hf scaleX=1.0f, fp32_hf scaleY=1.0f, fp32_hf rotation=0.0f, Graphics::DrawMode drawMode=Graphics::DRAWMODE_NORMAL, Graphics::MagFilter magFilter=Graphics::MAGFILTER_LINEAR, Graphics::MinFilter minFilter=Graphics::MINFILTER_LINEAR)
Draw a Image.
Definition: RenderHelper.h:558