How to change Marker2D Colors and/or width? Not just length

Godot Version

4.5

Question

Where may I find the option to edit the Marker2D’s colors so I can see them better?

Concurrently, how may I edit the color of the XY coordinates?

The usage of red and green in Marker2D & the coordinate system is useless for someone with red/green colorblindness when not on a black background. Rotating helps but of course it looks ugly.

I’ve searched the Editor’s Color settings and while the options are vast, I don’t think these colors are exposed to the user afaik.

It’s not possible to modify its width or colors but you can quickly re-create a similar node yourself. Something like:

@tool
class_name MyMarker2D extends Node2D


@export var gizmo_extents := 10.0:
	set(value):
		gizmo_extents = value
		queue_redraw()


@export var width := 1.0:
	set(value):
		width = value
		queue_redraw()


@export var horizontal_color := Color.RED:
	set(value):
		horizontal_color = value
		queue_redraw()


@export var vertical_color := Color.GREEN:
	set(value):
		vertical_color = value
		queue_redraw()


func _draw() -> void:
	if not Engine.is_editor_hint():
		return

	draw_line(Vector2(-gizmo_extents, 0), Vector2(gizmo_extents, 0), horizontal_color, width, false)
	draw_line(Vector2(0, -gizmo_extents), Vector2(0, gizmo_extents), vertical_color, width, false)
1 Like

Thank you! This made my day almost a month ago.

I’ve been fiddling with it. Here’s the current iteration.

If I was confident in my C++ skills, I’d PR exposing the parameters exposed here.

@tool
class_name Marker2De
extends Node2D


@export var gizmo_extents: float = 16.0:
	set(v):
		gizmo_extents = v
		queue_redraw()
@export var width: float = 0.4:
	set(v):
		width = v
		queue_redraw()
@export_range(0.01, 1.0, 0.01) var transparency: float = 0.25:
	set(v):
		transparency = v
		queue_redraw()
@export var horizontal_color_east: Color = Color.BLUE:
	set(v):
		horizontal_color_east = v
		queue_redraw()
@export var horizontal_color_west: Color = Color.PURPLE:
	set(v):
		horizontal_color_west = v
		queue_redraw()
@export var vertical_color_north: Color = Color.ORANGE:
	set(v):
		vertical_color_north = v
		queue_redraw()
@export var vertical_color_south: Color = Color.YELLOW:
	set(v):
		vertical_color_south = v
		queue_redraw()


func _draw() -> void:
	if not Engine.is_editor_hint():
		return
	_build_marker_line(Vector2(0, -gizmo_extents), vertical_color_north)
	_build_marker_line(Vector2(0, +gizmo_extents), vertical_color_south)
	_build_marker_line(Vector2(+gizmo_extents, 0), horizontal_color_east)
	_build_marker_line(Vector2(-gizmo_extents, 0), horizontal_color_west)

func _build_marker_line(to: Vector2, color: Color) -> void:
	color.a = transparency
	draw_line(Vector2.ZERO, to, color, width)