Guest User

Untitled

a guest
Feb 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. ## This is a prototype Shoes app to make Mapnik stylesheet editing a little bit easier.
  2. ## More of a proof of concept -- manysuchthings are hardcoded (image sizes, file names)
  3. #
  4. class DebugShoes < Shoes # Shoes got you down? DebugShoes won't fail silently on ya...
  5. def self.app(*args, &blk)
  6. super(*args) do
  7. begin
  8. self.instance_eval(&blk)
  9. rescue => e
  10. error(e) # log the error and inform the user!
  11. @err_bar = flow :width => 1.0, :height => 32, :top => self.height-32, :left => 0 do
  12. background lightgrey
  13. stack :width => self.width-100
  14. stack :width => 20, :margin => 4 do image "#{DIR}/static/icon-error.png" end;
  15. stack :width => 80 do para(link("#{Shoes.log.length} Errors!", :stroke => red) { Shoes.show_log }) end;
  16. end
  17. end
  18. end
  19. end
  20. end
  21.  
  22. class Image
  23. def reload
  24. self.path = "./" + path # reload hack, cache begone!
  25. self.hide.show
  26. end
  27. end
  28.  
  29. DebugShoes.app :width => 1360, :height => 720, :title => 'MappinPrototype' do
  30. STYLE_XML = 'style.xml'
  31. IMAGE_PNG = 'cali.png'
  32. MAP_APP = './cali ~/src/mapnik'
  33.  
  34. animate(2) do
  35. if @render then
  36. @render = false
  37. `#{MAP_APP}` # shell out to run Map app
  38. @bg.reload
  39. end
  40. end
  41.  
  42. background black
  43. flow do
  44. stack :width=>820, :margin=>15 do
  45. @bg = image IMAGE_PNG, :width=>800, :height=>680
  46. end
  47. stack :width => 530, :margin=>15 do
  48. background lightgrey, :curve => 12
  49. para "Layers"
  50. @e = edit_box "Would that I...", :width => 500, :height => 620
  51. @e.text = IO.read(STYLE_XML)
  52. button "Render!", :margin=>5 do
  53. warn "Rendering..."
  54. open(STYLE_XML, 'w') { |f| f.puts @e.text }
  55. @bg.blur 10
  56. @bg.hide.show # reload
  57. @render = true # defer rendering so that blur effect becomes visible
  58. end
  59. end
  60. end
  61. end
Add Comment
Please, Sign In to add comment