diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eff2e5..d1c23b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ file(GLOB_RECURSE TESTS test/*.cpp) set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library") include_directories(${LIB_PATH}/include) -add_executable(SimpleDraw ${SOURCES} ${HEADERS} main/main.cpp src/DrawRender.cpp src/DrawRender.hpp src/Circle.cpp src/Circle.hpp src/Rectangle.cpp src/Rectangle.hpp src/utils.cpp src/utils.hpp src/Shapes.cpp src/Shapes.hpp src/Cursor.cpp src/Cursor.hpp) +add_executable(SimpleDraw ${SOURCES} ${HEADERS} main/main.cpp) target_link_libraries(SimpleDraw ${LIB_PATH}/lib/liblibrary.a) diff --git a/src/Circle.cpp b/src/Circle.cpp index 56e044b..d086aa9 100644 --- a/src/Circle.cpp +++ b/src/Circle.cpp @@ -32,11 +32,11 @@ Circle::Circle(vkvm::Coordinates center, int radius, int penWidth, bool brush) { distance = utils::squareOfDistance(temp, center); if(!brush) { - if( distance < (radius * radius) && distance > ((radius - penWidth) * (radius - penWidth))) + if( distance <= (radius * radius) && distance >= ((radius - penWidth) * (radius - penWidth))) circle[y_draw][x_draw] = true; } else { - if( distance < (radius * radius)) + if( distance <= (radius * radius)) circle[y_draw][x_draw] = true; } } diff --git a/src/DrawRender.cpp b/src/DrawRender.cpp index 8fdd4a4..085a3f2 100644 --- a/src/DrawRender.cpp +++ b/src/DrawRender.cpp @@ -96,6 +96,8 @@ void DrawRender::clear() { vkvm::setPixel(x, y, backgroundColor); } } + + shapes = Shapes(); } void DrawRender::cursorCreator() { @@ -144,7 +146,6 @@ void DrawRender::clearToSharedMemory(std::vector> shape, int s else { vkvm::setPixel(currentX, currentY, penColor); } - } currentX++; } diff --git a/src/Shapes.cpp b/src/Shapes.cpp index 8810d3d..816bf67 100644 --- a/src/Shapes.cpp +++ b/src/Shapes.cpp @@ -19,18 +19,19 @@ void Shapes::addShape(std::vector> shape, int startX, int star endXs[count-1] = endX; endYs[count-1] = endY; - shapes[count-1].resize(shape.size()); - for(int y = 0; y < shape.size(); y++) { - shapes[count-1][y].resize(shape[y].size()); - for(int x = 0; x < shape[y].size(); x++) { - shapes[count-1][y][x] = shape[y][x]; - } - } +// shapes[count-1].resize(shape.size()); +// for(int y = 0; y < shape.size(); y++) { +// shapes[count-1][y].resize(shape[y].size()); +// for(int x = 0; x < shape[y].size(); x++) { +// shapes[count-1][y][x] = shape[y][x]; +// } +// } + shapes[count-1] = shape; } bool Shapes::containsPixel(int x, int y) { for(int i = 0; i < count; i++) { - if(x > startXs[i] && x < endXs[i] && y > startYs[i] && y < endYs[i]) { + if(x >= startXs[i] && x < endXs[i] && y >= startYs[i] && y < endYs[i]) { if(shapes[i][y-startYs[i]][x-startXs[i]]) { return true; }