Friday, April 20, 2018

23. draw_rect and draw_circle

We use a root Node2D and attach a script.


In the script, we draw a circle and rectangle.


This is the script to draw the 2 shapes:



extends Node2D

func _draw():
    var cen = Vector2(25, 25)
    var rad = 20
    var col = Color(0, 0, 1)
    draw_circle (cen, rad, col)
    col = Color(1, 0, 0)
    var rect = Rect2(Vector2(50, 50),Vector2(50, 50))
    draw_rect(rect, col)


The circle has 25-pixel radius and rectangle has size of 50 by 50 pixel as shown below:


No comments:

Post a Comment