Euphoria
image_draw.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "core/image.h"
4 #include "base/rgb.h"
5 #include "base/rect.h"
6 #include "base/vec2.h"
7 #include "core/rgb_blend.h"
8 
9 
10 
11 
12 namespace eu::core
13 {
14  struct LoadedFont;
15 
16  // get a Rect encompassing the whole image
17  Recti
18  on_whole_image(const Image& image);
19 
20  void
21  clear(Image* image, const Rgbai& color);
22 
23  void
24  draw_rect(Image* image, const Rgbai& color, const Recti& rect);
25 
26  void
27  draw_square(Image* image, const Rgbai& color, int x, int y, int size);
28 
29  void
30  fill_poly(Image* image, const Rgbai& color, const std::vector<vec2f>& poly);
31 
32  void
34  (
35  Image* image,
36  const Rgb& color,
37  const vec2i& center,
38  float radius,
39  float softness = 0.0f,
40  float inner = -1.0f
41  );
42 
43  void
45  (
46  Image* image,
47  const Rgbai& color,
48  const vec2i& from,
49  const vec2i& to
50  );
51 
52  void
54  (
55  Image* image,
56  const Rgb& color,
57  const vec2f& from,
58  const vec2f& to
59  );
60 
61  void
63  (
64  Image* image,
65  const Rgb& color,
66  const vec2i& from,
67  const vec2i& to
68  );
69 
70  // position is lower left of text
71  void
72  draw_text
73  (
74  Image* image,
75  const vec2i& start_pos,
76  const std::string& text,
77  const Rgbai& color,
78  const LoadedFont& font
79  );
80 
81  enum class PixelsOutside
82  {
83  assert,
84  discard
85  };
86 
87  void
89  (
90  // destination: paste to this image
91  Image* dest_image,
92  // bottom left
93  const vec2i& position,
94  // source: paste from this image
95  const Image& source_image,
96  // how to blend
98  // how to handle pixels that fall outside
100  );
101 
102  void
103  draw_arrow
104  (
105  Image* image,
106  const vec2f& from,
107  const vec2f& to,
108  const Rgbai& color,
109  float size
110  );
111 
112 }
Rgb blend(const Rgb &top, const Rgb &bottom, BlendMode mode)
Definition: rgb_blend.cc:402
void clear(Image *image, const Rgbai &color)
Definition: image_draw.cc:32
void draw_text(Image *image, const vec2i &start_pos, const std::string &text, const Rgbai &color, const LoadedFont &font)
Definition: image_draw.cc:519
void draw_circle(Image *image, const Rgb &color, const vec2i &center, float radius, float softness, float inner)
Definition: image_draw.cc:175
void draw_arrow(Image *image, const vec2f &from, const vec2f &to, const Rgbai &color, float size)
Definition: image_draw.cc:648
void fill_poly(Image *image, const Rgbai &color, const std::vector< vec2f > &poly)
Definition: image_draw.cc:146
void draw_line_fast(Image *image, const Rgbai &color, const vec2i &from, const vec2i &to)
Definition: image_draw.cc:254
Recti on_whole_image(const Image &image)
Definition: image_draw.cc:21
void draw_line_antialiased(Image *image, const Rgb &color, const vec2i &from, const vec2i &to)
Definition: image_draw.cc:342
void draw_square(Image *image, const Rgbai &color, int x, int y, int size)
Definition: image_draw.cc:67
void paste_image(Image *dest_image, const vec2i &position, const Image &source_image, BlendMode blend_mode, PixelsOutside clip)
Definition: image_draw.cc:553
void draw_rect(Image *image, const Rgbai &color, const Recti &rect)
Definition: image_draw.cc:39
constexpr ShaderAttribute color
Definition: rgb.h:45
Definition: vec2.h:33
Definition: vec2.h:72