include fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
|
||||
#include "Size.hpp"
|
||||
|
||||
@@ -10,7 +11,7 @@ namespace frame
|
||||
int32_t y;
|
||||
|
||||
Vector() = default;
|
||||
Vector(int32_t x, int32_t)
|
||||
Vector(int32_t x, int32_t y)
|
||||
: x(x)
|
||||
, y(y)
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace frame
|
||||
|
||||
Vector(Size const& size)
|
||||
: x(size.width)
|
||||
, y(size.width)
|
||||
, y(size.height)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,4 +54,9 @@ namespace frame
|
||||
return a;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, Vector const& v)
|
||||
{
|
||||
return os << "x: "<< v.x << " y: " << v.y;
|
||||
}
|
||||
|
||||
} // namespace frame
|
||||
@@ -2,14 +2,27 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
#include "display/EPD_7in5_V2.hpp"
|
||||
#include "render/RenderTarget.hpp"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
double const pi = 3.14159;
|
||||
|
||||
std::cout << "pi: " << pi << " " << 3.14159f << std::endl;
|
||||
std::cout << "pi / 180;" << pi / 180.f << std::endl;
|
||||
for(int i = 0; i < 360; i += 45)
|
||||
{
|
||||
std::cout << "(i): " << i << std::endl;
|
||||
std::cout << "rad: " << (float)i * pi / 180.f << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
frame::display::EPD_7in5_V2 display{};
|
||||
|
||||
@@ -21,15 +34,28 @@ int main()
|
||||
|
||||
frame::Vector const center = (display.getSize() / 2);
|
||||
|
||||
frame::Vector v = {10, 12};
|
||||
std::cout << "Main: " << v << std::endl;
|
||||
|
||||
target.DrawPixel({10, 10}, frame::BLACK);
|
||||
target.DrawLine({10, 12}, {100, 12}, frame::BLACK);
|
||||
target.DrawLine(v, {100, 12}, frame::BLACK);
|
||||
|
||||
for(int i = 0; i < 360; i += 45)
|
||||
{
|
||||
auto end = center;
|
||||
end.x += (int)std::cos(i * 0.01745329);
|
||||
end.y += (int)std::sin(i * 0.01745329);
|
||||
|
||||
double const cos_ = i * 0.01745329;
|
||||
std::cout << i << " cos: " << cos_ << std::endl;
|
||||
double x = std::cos(cos_);
|
||||
double y = std::sin(i * 0.01745329);
|
||||
x *= 50.f;
|
||||
y *= 50.f;
|
||||
std::cout << x << " " << (int)x << " " << y << std::endl;
|
||||
end.x += (int)x;
|
||||
end.y += (int)y;
|
||||
|
||||
|
||||
std::cout << end << std::endl;
|
||||
target.DrawLine(center, end);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "RenderTarget.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
namespace frame::render
|
||||
{
|
||||
|
||||
@@ -26,6 +29,7 @@ namespace frame::render
|
||||
auto pos = start;
|
||||
auto E = 2 * deltaY - deltaX;
|
||||
|
||||
std::cout << "Start: " << start << " End: " << end << std::endl;
|
||||
DrawPixel(pos, color);
|
||||
|
||||
while(pos != end)
|
||||
@@ -42,6 +46,7 @@ namespace frame::render
|
||||
|
||||
E += 2 * deltaY - 2 * deltaX;
|
||||
}
|
||||
std::cout << pos << std::endl;
|
||||
DrawPixel(pos, color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user