Tuesday, August 10, 2010

Freedom Quilt Demo

Flying Goose

Star

ShooflyMonkey Wrench
Log Cabin
Hourglass
Drunkard's Path
Corssroads
Bear's Paw

Start to do the Freedom Quilt project

Task: Start to do the Freedom Quilt project
Date: 0729-0810

1. User Interface of FQ

1.1 Interface for Moving a Shape
Move (int direction, float distance)
User can specify the direction and distance of the movement.
For now, I use 1, 2, 3, 4 to stand for up, down, left, right. Some better way is needed.

Log Cabin Move (int direction)
Doing Log Cabin is a typical iterative process.
To construct a layer clockwise, the user needs to move the rectangle as below
1, Move down, and then move left
2, Move up and then move left
3, Move up and then move right
The distance of each movement is the same: m_cx / 2 - m_cy / 2, where m_cx and m_cy are the length and width of the rectangle.

To start a new layer, the user needs do something special:
1, Move the rectangle rightward m_cx/2+m_cy/2
2, Move it down m_cx/2 - m_cy/2
3, make it longer by 2*m_cy: m_cx = m_cx + 2*m_cy;
All these are done in the codelet Log Cabin New layer()

1.2 Interface for Reflection
The freedom quilt patterns involve much reflection. So I provide more support for reflection.

StartShapeListReflection(int x_reflection, int y_reflection, float x_coord, float y_coord)
EndShapeListReflection()
The above pair of codelets allow the user to reflect the list of shapes constructed between them.

ReflectionAboutPoint(int x_reflection, int y_reflection, float x_coord, float y_coord)
Reflect the current shape about the point specified by (x_coord, y_coord)

Reflection(int x_reflection, int y_reflection)
Reflect the current shape about the center of the shape

1.3 Add 2 codelets for changing the size of a shape along X or Y dimension
Set X Dimension Size( float percent)
Set Y Dimension Size( float percent)

1.4 Add 1 codelet for inverting the color of a shape, as the freedom quilt involves changing the color of the shape often
Invert Color()

1.5 Select Base Shape(int shape_type)
The base shapes in FQ are: Parallelogram, Quartcirc, Rectangle, Square, Triangle

2. About code reuse

Freedom Quilt (FQ), Mangbetu (MG) and Cornrow Curve (CC) are similar to a large extent. They are tools for manipulating images/shapes.
So I can reuse code when implementing the 3 tools.
MG and CC can use almost the same classes. Not yet. I need to modify the code of CC.
For FQ, I tried to reuse of code of MG. But later, I decided to write a new class for FQ: QuiltShape.java. The reason is that FQ's functionalities are different from MG and CC.
In MG and CC, the moving of the shape is driven by a vector.
In FQ, the moving of the shapes is decided by the Quilt patterns.
So the inside logic of QuiltShape is different from Shape. We need a new class.

3 Pending
3.1 Save and reload file is not working properly. I need to fix this.
3.2 I need to modify the code of CC to make it up to date.