Hi,
I am trying to draw a polygon with the help of the method drawpolygon method.
The drawpolygon method requires a PoolVector2Array() and PoolColorArray as parameters.
I want to do 3 things:
(a) Draw a rectangle through this method under the virtual function _draw()
(b) Set the colour of the rectangle in consonance with the position of a VSlider node.
(c) Change the colour of the rectangle at runtime by moving the slider position up and down.
I am not sure if I am correctly passing values in the parameters, for I am getting a triangle as opposed to a rectangle. And, neither am I able to get the desired colour nor am I able to change colours by sliding the VSlider at runtime.
Here is my code:
extends Control
onready var slider =$VSlider
func _ready():
slider.value = 100
func _draw():
var col = {}
var points = PoolVector2Array()
var colour = PoolColorArray()
points = [Vector2(100,100), Vector2(200,100), Vector2(200,200),Vector2(100,200)]
colour = [slider.value,1,1,1]
draw_polygon(points,colour)
Here is the output that I am getting:
Image Link
Please help.