mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Add an action to draw a torus with the shape painter object (#5981)
- Thanks @trp02
This commit is contained in:
@@ -158,6 +158,28 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension& extension) {
|
||||
.AddParameter("expression", _("Bottom Y position"))
|
||||
.AddParameter("expression", _("Chamfer (in pixels)"))
|
||||
.SetFunctionName("DrawChamferRectangle");
|
||||
|
||||
|
||||
obj.AddAction("Torus",
|
||||
_("Torus"),
|
||||
_("Draw a torus on screen"),
|
||||
_("Draw at _PARAM1_;_PARAM2_ a torus with inner radius"
|
||||
"_PARAM3_ and outer radius _PARAM4_ and "
|
||||
"with start arc _PARAM5_° and end arc _PARAM6_°"
|
||||
"with _PARAM0_"),
|
||||
_("Drawing"),
|
||||
"res/actions/torus24.png",
|
||||
"res/actions/torus.png")
|
||||
|
||||
.AddParameter("object", _("Shape Painter object"), "Drawer")
|
||||
.AddParameter("expression", _("X position of center"))
|
||||
.AddParameter("expression", _("Y position of center"))
|
||||
.AddParameter("expression", _("Inner Radius (in pixels)"))
|
||||
.AddParameter("expression", _("Outer Radius (in pixels)"))
|
||||
.AddParameter("expression", _("Start Arc (in degrees)"))
|
||||
.AddParameter("expression", _("End Arc (in degrees)"))
|
||||
.SetFunctionName("DrawTorus");
|
||||
|
||||
|
||||
obj.AddAction("RegularPolygon",
|
||||
_("Regular Polygon"),
|
||||
|
@@ -54,6 +54,8 @@ class PrimitiveDrawingJsExtension : public gd::PlatformExtension {
|
||||
.SetFunctionName("drawChamferRectangle");
|
||||
GetAllActionsForObject("PrimitiveDrawing::Drawer")["PrimitiveDrawing::RegularPolygon"]
|
||||
.SetFunctionName("drawRegularPolygon");
|
||||
GetAllActionsForObject("PrimitiveDrawing::Drawer")["PrimitiveDrawing::Torus"]
|
||||
.SetFunctionName("drawTorus");
|
||||
GetAllActionsForObject("PrimitiveDrawing::Drawer")["PrimitiveDrawing::Star"]
|
||||
.SetFunctionName("drawStar");
|
||||
GetAllActionsForObject("PrimitiveDrawing::Drawer")["PrimitiveDrawing::Arc"]
|
||||
|
@@ -155,6 +155,33 @@ namespace gdjs {
|
||||
this.invalidateBounds();
|
||||
}
|
||||
|
||||
drawTorus(
|
||||
x1: float,
|
||||
y1: float,
|
||||
innerRadius: float,
|
||||
outerRadius: float,
|
||||
startArc: float,
|
||||
endArc: float
|
||||
) {
|
||||
this.updateOutline();
|
||||
this._graphics.beginFill(
|
||||
this._object._fillColor,
|
||||
this._object._fillOpacity / 255
|
||||
);
|
||||
//@ts-ignore from @pixi/graphics-extras
|
||||
this._graphics.drawTorus(
|
||||
x1,
|
||||
y1,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
startArc ? gdjs.toRad(startArc) : 0,
|
||||
endArc ? gdjs.toRad(endArc) : 0
|
||||
);
|
||||
this._graphics.closePath();
|
||||
this._graphics.endFill();
|
||||
this.invalidateBounds();
|
||||
}
|
||||
|
||||
drawRegularPolygon(
|
||||
x1: float,
|
||||
y1: float,
|
||||
|
@@ -242,6 +242,24 @@ namespace gdjs {
|
||||
);
|
||||
}
|
||||
|
||||
drawTorus(
|
||||
centerX: float,
|
||||
centerY: float,
|
||||
innerRadius: float,
|
||||
outerRadius: float,
|
||||
startArc: float,
|
||||
endArc: float
|
||||
) {
|
||||
this._renderer.drawTorus(
|
||||
centerX,
|
||||
centerY,
|
||||
innerRadius,
|
||||
outerRadius,
|
||||
startArc,
|
||||
endArc
|
||||
);
|
||||
}
|
||||
|
||||
drawRegularPolygon(
|
||||
centerX: float,
|
||||
centerY: float,
|
||||
|
BIN
newIDE/app/public/res/actions/torus.png
Normal file
BIN
newIDE/app/public/res/actions/torus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
newIDE/app/public/res/actions/torus24.png
Normal file
BIN
newIDE/app/public/res/actions/torus24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user