Allow different initial shapes besides rectangle
See original GitHub issueUseful for initial placeholder actors. If I want to draw a planet, it’d be nice to let Excalibur do it for me vs. me writing custom canvas code. Also, you can’t add an initial color because then Excalibur will draw the rectangle if you call super.draw
so you have to start with a null color.
Bonus: Changes shape of bounding box too.
Proposed Actor API
// default
protected defaultDraw(ctx, delta) {
// draw rect
}
// override
protected defaultDraw(ctx, delta) {
// custom drawing of shape or default draw
ex.Drawing.drawCircle(ctx, 5, this.color);
ex.Drawing.drawEllipse(ctx, 5, 6, this.color);
}
Circle
Assumes width and height are equal (use width / 2)
ctx.beginPath();
ctx.arc(0, 0, this.getWidth() / 2, 0, Math.PI * 2);
ctx.fillStyle = this.color.toString();
ctx.closePath();
ctx.fill();
Ellipse
Uses width / 2 and height / 2
- Scaling circle: http://stackoverflow.com/a/8372834
ellipse()
method
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Shape basics: resize, format, move and add text to shapes
A 2-D shape behaves like a rectangle. Select one or more shapes. You can select all shapes in the page by pressing Ctrl+A....
Read more >The 9 Most Common Shapes and How to Identify Them
Squares, rectangles, and rhombuses are all parallelograms. Squares and rectangles use the same basic formulas for area—length times height.
Read more >Two methods for creating non-standard shapes in PowerPoint
In this video I show two methods to create a non-standard shape. This can be useful when you are using an overlay on...
Read more >How to Draw Shapes with the Shape Tools in Photoshop
Click and hold on the Rectangle Tool's icon to open a fly-out menu showing the other shape tools hiding behind it. We'll look...
Read more >Create and customize shapes and masks in After Effects
Creating shapes · More videos on YouTube · Convert Vector Art Footage to Shape · Create a shape dragging with shape tools ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, it’s a good idea to open up a work in progress PR so we can keep up with what you’re working on and discuss any questions or design ideas you have!
On Fri, May 4, 2018, 21:54 jedeen notifications@github.com wrote:
Yep! Take a look at our updated contributing guide, and go ahead!
I’ll assign this issue to myself for tracking. Let us know if you have any questions!