Mosaic Fun with OpenOffice Calc

2,404 views

Published on

Presented at ApacheCon Europe 2012.
Sinsheim, Germany, 6 November 2012, OpenOffice Track

Get Calc Mosaic at http://sf.net/p/calcmosaic

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,404
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
14
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Mosaic Fun with OpenOffice Calc

  1. 1. Mosaic Fun with OpenOffice Calc imacat (Yang Shih-Ching)<imacat@mail.imacat.idv.tw> 2012/11/6
  2. 2. “Mosaic Fun with OpenOffice Calc” is created by imacat (Yang Shih-Ching),and licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
  3. 3. imacat / Yang Shih-Ching● From Taiwan local OpenOffice community● A graduate student from the Computer Science Education Laboratory, National Taiwan Normal University● A member of Women in FOSS in Taiwan● Was… – A Sun/Oracle freelance lecturer – An OpenOffice RD for 1 year – A web application developer for 8 years
  4. 4. This session is all about multimedia and fun. So please relax and enjoy!
  5. 5. After all, I’m not a show business professional. I’m a developer.Please forgive me if this is not cool enough. :p
  6. 6. Since this is all about multimedia, before we start,lets get some multimedia first! ^_*’
  7. 7. Lets Gangnam Style!
  8. 8. Feeling spirited now? ^_^
  9. 9. I will start by telling a story…
  10. 10. Long time ago in the far, far land when I was still a child…
  11. 11. Long time ago in the far, far land when I was still a child…Well, actually it was only in this August. :p
  12. 12. I saw on my RSS reader...
  13. 13. So I followed the story and watched the video…
  14. 14. It’s cool, isn’t it?
  15. 15. It’s cool, isn’t it?Yes, it’s SO COOL!
  16. 16. I forwarded it onto our Google Plus, our Facebook fans page, our forums, local forum, etc.
  17. 17. I forwarded it onto our Google Plus, our Facebook fans page, our forums, local forum, etc. Then I put it away and return to my textbook.
  18. 18. Until I saw Rob talking about this video the next day…
  19. 19. So I watched it again, and also the “behind the scenes”…
  20. 20. Well, I think…
  21. 21. Well, I think…Yeah, I can do it…
  22. 22. Well, I think…Yeah, I can do it…programmatically!
  23. 23. Creating mosaic art involvescalculating the average colors of image blocks.Since neither OpenOffice BASIC nor UNO API has any method to obtain the colors of individual pixels, I have use Java to do this.
  24. 24. So here it is… ^_^
  25. 25. (demonstration)
  26. 26. It’s cool, isn’t it?
  27. 27. No.
  28. 28. No, that’s not cool.It’s uglier than the original “Stop-Motion Excel”. It’s not the “eye candy” that I imagined.
  29. 29. Why? The original “Stop-Motion Excel” was painted manually, cell by cell.MysteryGuitarMan painted it with a fixed palette, but not “average colors”.It looks sharp. It feels like an animation.
  30. 30. Comparing Hand-Painted Colors with Mosaic Average Colors
  31. 31. So I need to find something more cool, something sharp, something with a high contrast.
  32. 32. That is not an easy task.
  33. 33. The idea of Calc Mosaic is not only to create mosaic arts,but also to create stop-motion animations.
  34. 34. But it takes averagely 20 secondsto create a spreadsheet of mosaic art with the Java UNO application. I cannot run the animationby creating the mosaic art at real-time.
  35. 35. So I turn to another method,to create each frame with a spreadsheet, and play them in sequence, as a stop-motion animation.
  36. 36. But then a spreadsheet document can only contain a maximum of 256 spreadsheets.
  37. 37. Since I only have 256 frames, this cannot be long.
  38. 38. I remembered there is the iPod Ad
  39. 39. The iPod Ad…● Has only 31 seconds, corresponding to 8 FPS if we are having 256 frames.
  40. 40. The iPod Ad…● Has only 31 seconds, corresponding to 8 FPS if we are having 256 frames.● Has sharp images, high contrasts.
  41. 41. The iPod Ad…● Has only 31 seconds, corresponding to 8 FPS if we are having 256 frames.● Has sharp images, high contrasts.● Is very famous.
  42. 42. So here it is…
  43. 43. (demonstration)
  44. 44. At the same time, Villeroy responded to myCalc Mosaic on the forum, using a different approach.
  45. 45. Villeroy’s Response
  46. 46. So here it is…
  47. 47. (demonstration)
  48. 48. As you can see, Villeroy places the color values in the cells. The OpenOffice BASIC macro can read andupdate the cell background colors accordingly. OpenOffice BASIC is a lot faster than Java UNO.This makes it possible to animate at real time.
  49. 49. Villeroy’s approach still has some disadvantages…
  50. 50. Disadvantages of Villeroy’s Approach● You still need to have the color values first.
  51. 51. Disadvantages of Villeroy’s Approach● You still need to have the color values first.● The frame rate is still low.
  52. 52. Disadvantages of Villeroy’s Approach● You still need to have the color values first.● The frame rate is still low.● Villeroy updates the colors with styles. – A lot faster than painting the background color cell by cell. – The number of colors to use is limited. That is why it is gray-scaled.
  53. 53. This is a different approach than me. But I still got greatly inspired.
  54. 54. The color values can be saved in the sheets, and painted with OpenOffice BASIC. This can make it a lot faster.
  55. 55. And I know there is the setDataArray() in the interface XCellRangeData.I can populate all the color values at once instead of hundreds of UNO calls to set the CellBackColor property Of SheetCell.
  56. 56. The New Process Will Be…1.Calculates the average colors of mosaic cells with the Java application.
  57. 57. The New Process Will Be…1.Calculates the average colors of mosaic cells with the Java application.2.Passes the color values from Java to OpenOffice BASIC.
  58. 58. The New Process Will Be…1.Calculates the average colors of mosaic cells with the Java application.2.Passes the color values from Java to OpenOffice BASIC.3.Paints the background colors of the spreadsheet cells with the OpenOffice BASIC macro.
  59. 59. So the problem becomes: Writing an applicationboth in Java and OpenOffice BASIC.
  60. 60. So the problem becomes: Writing an application both in Java and OpenOffice BASIC. Or, simply,Creating the OpenOffice BASIC macros through the UNO API with Java.
  61. 61. In the unpublished UNO API, there is a BasicLibraries property in OfficeDocument that application developers canaccess, insert or delete the BASIC macros.
  62. 62. There’s also the XScriptProvider interface that I can use it to invoke the existing OpenOffice macros.
  63. 63. So I use them to “inject” the BASIC macrosinto the newly-created spreadsheet document, and run these macros.
  64. 64. In fact, I don’t even need to use setDataArray()to paste the color values into the spreadsheets. I can pass the color values as parameters to the invoked BASIC macros.
  65. 65. This is troublesome, but the result is amazing.It is 8 times faster then before!
  66. 66. When I prepare for this presentation, I became more and more greedy.
  67. 67. I want something new, something hot,something gets people excited!
  68. 68. Then I came across this…
  69. 69. Something hot…
  70. 70. Well, again, I think…
  71. 71. Well, again, I think… Yeah, I can do it!
  72. 72. The Gangnam Style song is 4:12 long. That is 252 seconds. With 10 FPS, it needs 2520 spreadsheets. That is 10 spreadsheet documents.(Each has a maximum of 256 spreadsheets.)
  73. 73. I can then concatenate the 10 recorded videos, join them into one, and create an OpenOffice Calc Style.
  74. 74. So here is it. Enjoy!
  75. 75. Get Calc Mosaic!http://sf.net/p/calcmosaic
  76. 76. Thank you.Any questions?

×