Advertisement
nezvers

Custom draw line

Jan 27th, 2020
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. func _draw():
  2.     var minX = floor(min(start.x, end.x))
  3.     var maxX = floor(max(start.x, end.x))
  4.     var minY = floor(min(start.y, end.y))
  5.     var maxY = floor(max(start.y, end.y))
  6.     var width = maxX - minX
  7.     var height = maxY - minY
  8.     for y in range(height): #might need adjustments for first or last pixel
  9.         var x = floor((y/height) * width)   #x offset
  10.         #didn't find draw_point so this is a workaround
  11.         var point = Vector2(minX + x, minY + y)
  12.         draw_line(point, point+Vector2.RIGHT, Color.white)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement