Add drawTriangle engine function - #39
Open
ItzAditya43 wants to merge 1 commit into
Open
Conversation
Adds a drawTriangle(x1, y1, x2, y2, x3, y3, [outline], [thickness]) engine function, resolving ArcadeMakerSources#38. The declaration mirrors the existing drawRect / drawEllipse primitives, taking its coordinates as required parameters and both outline and thickness as optional ones. MonoGame.Extended exposes DrawPolygon on SpriteBatch for the outlined case, but its only solid-fill helper is FillRectangle, so filled triangles are rasterized as a series of horizontal scanlines. This keeps the fill inside the existing SpriteBatch pass without requiring a separate PrimitiveBatch.
Owner
|
Hey, thank u very much! 🙏🏼 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38
Adds a
drawTriangle(...)engine function, following the three-part structure described in the issue.Changes
ArcadeMaker.Core/IGame.Funcs.cs— declaration with[EngineFunc]/[Param]attributes.Engines/MonoGame/Core/ArcadeMakerMonoGame.cs— MonoGame implementation.ArcadeMaker.IDE/Debugging/FutileGame.cs— futile implementation.Usage
Two notes / questions
1. Optional
outlineandthicknessThe issue suggested
[EngineFunc(7)]with a requiredoutline. I used[EngineFunc(6, 7, 8)]instead, so that the signature mirrors the neighbouringdrawRect/drawEllipse, which both take their 4 coordinates plus an optionaloutlineand an optionalthickness:This keeps the primitive-drawing functions consistent with each other, and defaults to an outline like the others do. Happy to change it back to a strict 7 parameters if you'd prefer to stay with the issue's signature.
2. Filled triangles
MonoGame.Extended's
ShapeExtensionsgivesSpriteBatchaDrawPolygon(...)for outlines, but the only solid helper it exposes isFillRectangle(...)— there is no filled-polygon method onSpriteBatch(DrawSolidPolygonlives onVectorDraw.PrimitiveDrawing, which needs its ownPrimitiveBatch).Rather than throw for the filled case (as
drawEllipsecurrently does), I filled the triangle by rasterizing it as a series of horizontal scanlines, each drawn withFillRectangle. It stays inside the existingSpriteBatchpass, so it needs no extra graphics state or render-target juggling.If you'd rather introduce a
PrimitiveBatchand get a single-draw-call filled polygon out of it, that would be more efficient for large triangles and would letdrawEllipsebe filled too — but it felt like a bigger change than this issue called for, so I kept it self-contained. Let me know if you'd prefer that direction.Feedback very welcome — this is my first contribution here.