mosaic fun with openoffice calc

Download Mosaic Fun with OpenOffice Calc

If you can't read please download the document

Upload: imacat-

Post on 16-Apr-2017

2.501 views

Category:

Technology


5 download

TRANSCRIPT

Apache OpenOffice Presentation Template

Mosaic Fun with OpenOffice Calc

imacat (Yang Shih-Ching)

2012/11/6

Mosaic Fun with OpenOffice Calc is created by imacat (Yang Shih-Ching),and licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License

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

WasA Sun/Oracle freelance lecturer

An OpenOffice RD for 1 year

A web application developer for 8 years

This session is all about multimedia and fun.So please relax and enjoy!

After all, Im not a show business professional.Im a developer.Please forgive me if this is not cool enough. :p

Since this is all about multimedia,before we start,lets get some multimedia first! ^_*

Lets Gangnam Style!

Feeling spirited now? ^_^

I will start by telling a story

Long time ago in the far, far landwhen I was still a child

Long time ago in the far, far landwhen I was still a childWell, actually it was only in this August. :p

I saw on my RSS reader...

So I followed the story and watched the video

Its cool, isnt it?

Its cool, isnt it?Yes, its SO COOL!

I forwarded it onto our Google Plus,our Facebook fans page,our forums, local forum, etc.

I forwarded it onto our Google Plus,our Facebook fans page,our forums, local forum, etc.Then I put it awayand return to my textbook.

Until I saw Rob talking about this video the next day

So I watched it again, and also the behind the scenes

Well, I think

Well, I thinkYeah, I can do it

Well, I thinkYeah, I can do itprogrammatically!

Creating mosaic art involvescalculating the average colors of image blocks.Since neither OpenOffice BASIC nor UNO API has any methodto obtain the colors of individual pixels,I have use Java to do this.

So here it is ^_^

(demonstration)

Its cool, isnt it?

No.

No, thats not cool.Its uglier than the original Stop-Motion Excel.Its not the eye candy that I imagined.

Why?The original Stop-Motion Excelwas painted manually, cell by cell.MysteryGuitarMan painted it with a fixed palette, but not average colors.It looks sharp. It feels like an animation.

Comparing Hand-Painted Colors
with Mosaic Average Colors

So I need to find something more cool,something sharp,something with a high contrast.

That is not an easy task.

The idea of Calc Mosaicis not only to create mosaic arts,but also to create stop-motion animations.

But it takes averagely 20 secondsto create a spreadsheet of mosaic artwith the Java UNO application.I cannot run the animationby creating the mosaic art at real-time.

So I turn to another method,to create each frame with a spreadsheet,and play them in sequence,as a stop-motion animation.

But then a spreadsheet document can only contain a maximum of 256 spreadsheets.

Since I only have 256 frames,this cannot be long.

I remembered there is the iPod Ad

The iPod Ad

Has only 31 seconds, corresponding to 8 FPS if we are having 256 frames.

The iPod Ad

Has only 31 seconds, corresponding to 8 FPS if we are having 256 frames.

Has sharp images, high contrasts.

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.

So here it is

(demonstration)

At the same time, Villeroy responded to my Calc Mosaic on the forum, using a different approach.

Villeroys Response

So here it is

(demonstration)

As you can see,Villeroy places the color values in the cells.The OpenOffice BASIC macro can read and update the cell background colors accordingly.OpenOffice BASIC is a lot fasterthan Java UNO.This makes it possible to animate at real time.

Villeroys approach still has some disadvantages

Disadvantages of
Villeroys Approach

You still need to have the color values first.

Disadvantages of
Villeroys Approach

You still need to have the color values first.

The frame rate is still low.

Disadvantages of
Villeroys 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.

This is a different approach than me.But I still got greatly inspired.

The color values can be saved in the sheets,and painted with OpenOffice BASIC.This can make it a lot faster.

And I know there is the setDataArray()in the interface XCellRangeData.I can populate all the color values at onceinstead of hundreds of UNO callsto set the CellBackColor propertyOf SheetCell.

The New Process Will Be

Calculates the average colors of mosaic cells with the Java application.

The New Process Will Be

Calculates the average colors of mosaic cells with the Java application.

Passes the color values from Java to OpenOffice BASIC.

The New Process Will Be

Calculates the average colors of mosaic cells with the Java application.

Passes the color values from Java to OpenOffice BASIC.

Paints the background colors of the spreadsheet cells with the OpenOffice BASIC macro.

So the problem becomes:Writing an applicationboth in Java and OpenOffice BASIC.

So the problem becomes:Writing an applicationboth in Java and OpenOffice BASIC.Or, simply,Creating the OpenOffice BASIC macrosthrough the UNO API with Java.

In the unpublished UNO API,there is a BasicLibraries propertyin OfficeDocumentthat application developers canaccess, insert or delete the BASIC macros.

Theres also the XScriptProvider interfacethat I can use it to invokethe existing OpenOffice macros.

So I use them to inject the BASIC macrosinto the newly-created spreadsheet document,and run these macros.

In fact, I dont even need to use setDataArray()to paste the color values into the spreadsheets.I can pass the color values as parametersto the invoked BASIC macros.

This is troublesome,but the result is amazing.It is 8 times faster then before!

When I prepare for this presentation,I became more and more greedy.

I want something new,something hot,something gets people excited!

Then I came across this

Something hot

Well, again, I think

Well, again, I thinkYeah, I can do it!

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.)

I can then concatenate the 10 recorded videos,join them into one,and create an OpenOffice Calc Style.

So here is it. Enjoy!

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

Thank you.Any questions?