1 #include <whycpp/color.h> 2 #include <whycpp/drawing.h> 3 #include <whycpp/types.h> 5 #include "../context.h" 6 #include "../holders/sprites_holder.h" 8 #include "../holders/video_memory_holder.h" 17 if (color.alpha == 0)
return;
27 i32 dx = std::abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
28 i32 dy = std::abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
29 i32 err = (dx > dy ? dx : -dy) / 2;
34 if (x0 == x1 && y0 == y1)
break;
47 for (
auto i = y; i < y + h; i++) {
48 DrawLine(ctx, x, i, x + w - 1, i, color);
52 DrawLine(ctx, x, y, x + w, y, color);
53 DrawLine(ctx, x, y, x, y + h, color);
55 DrawLine(ctx, x + w, y, x + w, y + h, color);
56 DrawLine(ctx, x, y + h, x + w, y + h, color);
64 SetPixel(context, x - x_, y + y_, color);
65 SetPixel(context, x + x_, y - y_, color);
67 SetPixel(context, x - y_, y - x_, color);
68 SetPixel(context, x + y_, y + x_, color);
70 if (r <= y_) err += ++y_ * 2 + 1;
71 if (r > x_ || err > y_) err += ++x_ * 2 + 1;
80 for (i32 i = x + x_; i <= x - x_; i++) {
83 for (i32 i = x + x_; i <= x - x_; i++) {
88 if (r <= y_) err += ++y_ * 2 + 1;
89 if (r > x_ || err > y_) err += ++x_ * 2 + 1;
93 void DrawSprite(
Context &context, i32 sprite_id, i32 screen_x, i32 screen_y, i32 sheet_x, i32 sheet_y, i32 width,
95 auto spr = context.Get<
SpritesHolder>()->GetSprite(sprite_id);
96 for (
auto y = 0; y < height; y++) {
97 for (
auto x = 0; x < width; x++) {
98 SetPixel(context, screen_x + x, screen_y + y, spr->Get(sheet_x + x, sheet_y + y));
void DrawLine(Context &ctx, i32 x0, i32 y0, i32 x1, i32 y1, const RGBA &color)
const RGBA GetPixel(const Context &ctx, i32 x, i32 y)
i32 GetDisplayHeight(const Context &ctx)
void DrawCircle(Context &context, i32 x, i32 y, i32 radius, const RGBA &color)
void SetPixel(Context &ctx, i32 x, i32 y, const RGBA &color)
void DrawClearScreen(Context &ctx, const RGBA &color)
void DrawCircleFill(Context &context, i32 x, i32 y, i32 radius, const RGBA &color)
void DrawRect(Context &ctx, i32 x, i32 y, i32 w, i32 h, const RGBA &color)
void DrawRectFill(Context &ctx, i32 x, i32 y, i32 w, i32 h, const RGBA &color)
i32 GetDisplayWidth(const Context &ctx)