-- lua script for drawing Radial spokes
-- Based on the Radial script created by RJP74
-- some basic constants
local w_mid = width / 2
local h_mid = height / 2
local radius = math.sqrt((w_mid * w_mid) + (h_mid * h_mid)) * 2
local r2d =  180 / math.pi
local r, g, b

-- allow the user to specify the number of radial spokes and location
--@TBCONFIG SLIDER: X Axis, 50
--@TBCONFIG SLIDER: Y Axis, 50
--@TBCONFIG SLIDER: Spokes, 17
--@TBCONFIG SLIDER: Rotation, 0
--@TBCONFIG SLIDER: Thickness, 1

local ucenterX = math.floor(sliderVal1 * width)
local ucenterY = math.floor(sliderVal2 * height)
local uspokes =  math.floor((sliderVal3 * 100))
local uangle =  (sliderVal4  * math.pi * 2 / uspokes )
local size = math.floor((sliderVal5 * 20))
if size == 0 then size = 1 end

function round(x)
    local xf = math.floor(x)
    if (x - xf) <= 0.5 then 
        return xf
    else
        return math.ceil(x)
    end 
end

paint_open(1)
paint_select_brush("Art Tools - Cover Paints", "Plain Coverage Paint", 0)
paint_brush_size(size)
paint_brush_opacity(100)
for y = 0, uspokes - 1 do
  local w1, h1
  local angle = ((360 / uspokes) * y)/ r2d + uangle
  w1 = round(radius * math.cos(angle)  + ucenterX)
  h1 = round(radius * math.sin(angle)  + ucenterY)
  paint_line(ucenterX , ucenterY, w1, h1)
end
paint_close()


