git.s-ol.nu watch-cad / master library / place.moon
master

Tree @master (Download .tar.gz)

place.moon @masterraw · history · blame

=>
  @init {}

  if INPUT\mouse_down!
    @start\set INPUT.mouse

  if INPUT\mouse_held!
    if INPUT\key_held 'lshift'
      size = INPUT.mouse - @start!
      draw.rect @start! - size, @start! + size
    else
      draw.rect @start!, INPUT.mouse

  if INPUT\mouse_up!
    size = INPUT.mouse - @start!
    if INPUT\key_held 'lshift'
      table.insert @!, pos: @start!, size: size*2
    else
      table.insert @!, pos: @start! + size/2, size: size

  for o in *@!
    op.add o.pos, o.size