Skip to content

Commit

Permalink
filled sectors
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesims committed Mar 12, 2024
1 parent ed2bd28 commit 8d1e1a3
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 19 deletions.
14 changes: 14 additions & 0 deletions src/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,20 @@ void Canvas::fillSegment(int X, int Y, int X1, int Y1, int X2, int Y2)
}


void Canvas::fillSector(int X, int Y, int X1, int Y1, int X2, int Y2)
{
moveTo(X, Y);
Primitive p;
p.cmd = PrimitiveCmd::FillSector;
// Use a Rect as a convenience to pass 2 points
// NB arc is always drawn anti-clockwise, with X1,Y1 as the start point
// and X2,Y2 as the end point, which is used to calculate the angle
// (i.e. the end point does not have to lie on circumference)
p.rect = Rect(X1, Y1, X2, Y2);
m_displayController->addPrimitive(p);
}


void Canvas::drawGlyph(int X, int Y, int width, int height, uint8_t const * data, int index)
{
Primitive p;
Expand Down
14 changes: 14 additions & 0 deletions src/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,20 @@ class Canvas {
*/
void fillSegment(int X, int Y, int X1, int Y1, int X2, int Y2);

/**
* @brief Draws a filled sector of a circle specifying center, start and endpoints, using current brush color.
* The circle arc is drawn anticlockwise.
* The endpoint is used to work out the angle to the end point of the arc, rather than being on the arc itself.
*
* @param X Horizontal coordinate of the circle center.
* @param Y Vertical coordinate of the circle center.
* @param X1 Horizontal coordinate of the start point.
* @param Y1 Vertical coordinate of the start point.
* @param X2 Horizontal coordinate of the end point.
* @param Y2 Vertical coordinate of the end point.
*/
void fillSector(int X, int Y, int X1, int Y1, int X2, int Y2);

/**
* @brief Fills an ellipse specifying center and size, using current brush color.
*
Expand Down
7 changes: 7 additions & 0 deletions src/dispdrivers/vga16controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ void VGA16Controller::fillSegment(Rect const & rect, Rect & updateRect)
}


void VGA16Controller::fillSector(Rect const & rect, Rect & updateRect)
{
auto mode = paintState().paintOptions.mode;
genericFillSector(rect, updateRect, getPixelLambda(mode), fillRowLambda(mode));
}


void VGA16Controller::clear(Rect & updateRect)
{
hideSprites(updateRect);
Expand Down
3 changes: 3 additions & 0 deletions src/dispdrivers/vga16controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class VGA16Controller : public VGAPalettedController {
// abstract method of BitmappedDisplayController
void fillSegment(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void fillSector(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void clear(Rect & updateRect);

Expand Down
7 changes: 7 additions & 0 deletions src/dispdrivers/vga2controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ void VGA2Controller::fillSegment(Rect const & rect, Rect & updateRect)
}


void VGA2Controller::fillSector(Rect const & rect, Rect & updateRect)
{
auto mode = paintState().paintOptions.mode;
genericFillSector(rect, updateRect, getPixelLambda(mode), fillRowLambda(mode));
}


void VGA2Controller::clear(Rect & updateRect)
{
hideSprites(updateRect);
Expand Down
3 changes: 3 additions & 0 deletions src/dispdrivers/vga2controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class VGA2Controller : public VGAPalettedController {
// abstract method of BitmappedDisplayController
void fillSegment(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void fillSector(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void clear(Rect & updateRect);

Expand Down
7 changes: 7 additions & 0 deletions src/dispdrivers/vga4controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ void VGA4Controller::fillSegment(Rect const & rect, Rect & updateRect)
}


void VGA4Controller::fillSector(Rect const & rect, Rect & updateRect)
{
auto mode = paintState().paintOptions.mode;
genericFillSector(rect, updateRect, getPixelLambda(mode), fillRowLambda(mode));
}


void VGA4Controller::clear(Rect & updateRect)
{
hideSprites(updateRect);
Expand Down
3 changes: 3 additions & 0 deletions src/dispdrivers/vga4controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ class VGA4Controller : public VGAPalettedController {
// abstract method of BitmappedDisplayController
void fillSegment(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void fillSector(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void clear(Rect & updateRect);

Expand Down
7 changes: 7 additions & 0 deletions src/dispdrivers/vga8controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ void VGA8Controller::fillSegment(Rect const & rect, Rect & updateRect)
}


void VGA8Controller::fillSector(Rect const & rect, Rect & updateRect)
{
auto mode = paintState().paintOptions.mode;
genericFillSector(rect, updateRect, getPixelLambda(mode), fillRowLambda(mode));
}


void VGA8Controller::clear(Rect & updateRect)
{
hideSprites(updateRect);
Expand Down
3 changes: 3 additions & 0 deletions src/dispdrivers/vga8controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class VGA8Controller : public VGAPalettedController {
// abstract method of BitmappedDisplayController
void fillSegment(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void fillSector(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void clear(Rect & updateRect);

Expand Down
7 changes: 7 additions & 0 deletions src/dispdrivers/vgacontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ void IRAM_ATTR VGAController::fillSegment(Rect const & rect, Rect & updateRect)
}


void IRAM_ATTR VGAController::fillSector(Rect const & rect, Rect & updateRect)
{
auto mode = paintState().paintOptions.mode;
genericFillSector(rect, updateRect, getPixelLambda(mode), fillRowLambda(mode));
}


void IRAM_ATTR VGAController::clear(Rect & updateRect)
{
hideSprites(updateRect);
Expand Down
3 changes: 3 additions & 0 deletions src/dispdrivers/vgacontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ class VGAController : public VGABaseController {
// abstract method of BitmappedDisplayController
void fillSegment(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void fillSector(Rect const & rect, Rect & updateRect);

// abstract method of BitmappedDisplayController
void clear(Rect & updateRect);

Expand Down
3 changes: 3 additions & 0 deletions src/displaycontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ void IRAM_ATTR BitmappedDisplayController::execPrimitive(Primitive const & prim,
case PrimitiveCmd::FillSegment:
fillSegment(prim.rect, updateRect);
break;
case PrimitiveCmd::FillSector:
fillSector(prim.rect, updateRect);
break;
case PrimitiveCmd::Clear:
updateRect = updateRect.merge(Rect(0, 0, getViewPortWidth() - 1, getViewPortHeight() - 1));
clear(updateRect);
Expand Down
Loading

0 comments on commit 8d1e1a3

Please sign in to comment.