Debugging Ruby
Posted: Sun Jul 13, 2014 9:17 pm
Hey I am trying to port the drawing of the Multi Stage env to Ruby.
I have written the code and as far as I can see it should work, but obviously does not.
I am getting rather annoyed with a cryptic syntax error saying "unexpected keyword_end, expecting $end" What the hell does that mean? all my "end"s are in the right place.
Been staring at the code for ages now and need a fresh pair of eyes to take a look see if I am missing something obvious!
I've attached the fsm also.
Thanks for any help!
Also any tips for debugging in Ruby? I've been developing in Java the last few years and am now feeling rather spoiled with my fancy IDE
I have written the code and as far as I can see it should work, but obviously does not.
I am getting rather annoyed with a cryptic syntax error saying "unexpected keyword_end, expecting $end" What the hell does that mean? all my "end"s are in the right place.
Been staring at the code for ages now and need a fresh pair of eyes to take a look see if I am missing something obvious!
Code: Select all
def draw v
pBrush = Brush.new Color.new(128,128,255,255),@pointSize
pPen = Pen.new Color.new(128,128,255,255),@curvePointSize
curvePen = Pen.new Color.new (128,128,255,255), 0.1
@w = v.width-1
@h = v.height-1
pHalf = @pointSize *0.5
## Draw section points
0.step(@sections,1) do |i|
v.drawEllipse pBrush , [((@xArray[i]*@zoom)*@w)-pHalf,@yArray[i]*@h,@pointSize,@pointSize]
end
## Draw curve points
0.step(@sections-1,1) do |i|
x = (((@xArray[i+1]-@xArray[i])*0.5)+@xArray[i])
y = (((@yArray[i+1]-@yArray[i])*@curveArray[i]) + @yArray[i])
v.drawEllipse pPen , [x*@w*@zoom - @curvePointSize*0.5,y*@h - @curvePointSize*0.5 + 0.5,@pointSize,@pointSize]
startX = @xArray[i]*@w
startY = @yArray[i]*@h
endX = @xArray[i+1]*@w
endY = @yArray[i+1]*@h
yRange = endY - startY
xRange = endX - startX
areaStep = xRange / 128
curvePlot = [128]
frac = 0.00790514
invert = 1/@curveArray[i]
##Plot the curve
0.step(128,1) do |j|
accum = j*frac
t1 = (1 - invert) * (accum-1) + accum
t2 = (1/t1) * accum * -2
curvePlot[j] = [ startX + i*areaStep, t2*yRange + startY]
end
##Draw the curve
v.drawLines curvePen, curvePlot
end
endI've attached the fsm also.
Thanks for any help!
Also any tips for debugging in Ruby? I've been developing in Java the last few years and am now feeling rather spoiled with my fancy IDE