Replaced pixels with squares for control points, finished bezier_1
This commit is contained in:
parent
2328815a55
commit
c06312f7f0
@ -74,6 +74,8 @@ void MyWindow::on_segmentSlider_valueChanged(int val)
|
|||||||
segment_count = val;
|
segment_count = val;
|
||||||
QString str(("Ilosc segmentow: " + std::to_string(segment_count)).c_str());
|
QString str(("Ilosc segmentow: " + std::to_string(segment_count)).c_str());
|
||||||
ui->segmentLabel->setText(str);
|
ui->segmentLabel->setText(str);
|
||||||
|
DrawBezier();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -292,6 +294,17 @@ void MyWindow::DrawCircle(int x1, int y1, int x2, int y2){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyWindow::DrawSquare(int x, int y, int size, QColor color){
|
||||||
|
size /= 2;
|
||||||
|
for(int x1 = x - size; x1 < x + size; x1++){
|
||||||
|
for(int y1 = y - size; y1 < y + size; y1++){
|
||||||
|
if(x1 >= szer || y1 >= wys || x1 < 0 || y1 < 0)
|
||||||
|
continue;
|
||||||
|
DrawPixel(img, x1, y1, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MyWindow::DrawEllipse(int x1, int y1, int x2, int y2){
|
void MyWindow::DrawEllipse(int x1, int y1, int x2, int y2){
|
||||||
if(x2 >= szer || y2 >= wys || x2 < 0 || y2 < 0)
|
if(x2 >= szer || y2 >= wys || x2 < 0 || y2 < 0)
|
||||||
return;
|
return;
|
||||||
@ -324,7 +337,7 @@ void MyWindow::DrawEllipse(int x1, int y1, int x2, int y2){
|
|||||||
void MyWindow::DrawBezier(){
|
void MyWindow::DrawBezier(){
|
||||||
ClearImage(img);
|
ClearImage(img);
|
||||||
for(int i = 0; i < bezier_points.size(); i+=1){
|
for(int i = 0; i < bezier_points.size(); i+=1){
|
||||||
DrawPixel(img, bezier_points[i].x, bezier_points[i].y);
|
DrawSquare(bezier_points[i].x, bezier_points[i].y, 15, QColor(255, 0, 0));
|
||||||
}
|
}
|
||||||
for(int i = 1; i < bezier_points.size(); i+=3){
|
for(int i = 1; i < bezier_points.size(); i+=3){
|
||||||
if(i + 2 >= bezier_points.size())
|
if(i + 2 >= bezier_points.size())
|
||||||
|
@ -125,6 +125,7 @@ private:
|
|||||||
void DrawLine(int x1, int y1, int x2, int y2, QImage *img);
|
void DrawLine(int x1, int y1, int x2, int y2, QImage *img);
|
||||||
void DrawCircle(int x1, int y1, int x2, int y2);
|
void DrawCircle(int x1, int y1, int x2, int y2);
|
||||||
void DrawEllipse(int x1, int y1, int x2, int y2);
|
void DrawEllipse(int x1, int y1, int x2, int y2);
|
||||||
|
void DrawSquare(int x, int y, int size, QColor color = QColor(255,255,255));
|
||||||
void DrawBezier();
|
void DrawBezier();
|
||||||
void ClearImage(QImage *img);
|
void ClearImage(QImage *img);
|
||||||
void UpdateTempImage();
|
void UpdateTempImage();
|
||||||
|
Loading…
Reference in New Issue
Block a user