How to draw primitives with alpha channel?

TTaykAHTTaykAH Posts: 4Member
edited June 9 in GUI

Hello, should be said that I'm new in Godot and don't now much, but resently I faced a problem with drawing transparent primitives. I need to draw grid that won't overlap background images a lot. For example I built simple tree:

And I have this code in DrawGrid node's script:

extends Control

export var lenX = 50
export var lenY = 28
export var tile_size = 16
var screenx
var screeny

func _ready():
    screenx = get_viewport_rect().size[0]
    screeny = get_viewport_rect().size[1] 

func _draw():

    for i in range(lenX):
        var x = i*tile_size
        draw_line(Vector2(x, 0), Vector2(x, screeny), Color(255, 255, 255, 100))

    for i in range(lenY):
        var y = i*tile_size
        draw_line(Vector2(0, y+1), Vector2(screenx, y+1), Color(255, 255, 255, 100))`

Despite I specified alpha channel as 100, It drawing with alpha=255. How can I fix this and is it even possible?
P.S. Sorry for my English, I still learning :0

Best Answer

  • TwistedTwiglegTwistedTwigleg Posts: 2,663
    Accepted Answer

    Welcome to the forums @TTaykAH!

    I do not remember right off, but I think the color constructor takes (or can take) values from 0-1, so maybe try the following and see if it works: Color(1, 1, 1, 0.5)?

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file