Wednesday, July 14, 2010

Implement Plait as a PObject

Task: Implement Plait as a PObject
Date: 0701-0714.
In the previous Cornrow project, the main class is Curve, which is used to create the braids as dynamic objects. Curve is not a PObject and the PMethods are all of and in the CCEngine.
We need to modify the old design to make CC programmable.

The change: A new class Plait is added into CC.
1. Basic things about Plait
1.1 Plait is the composite unit of a braid. It is implemented as a PObject. So users can create a new plait by clicking 'create' in the menu, and created plaits will appear in the object panel.
1.2 Selecting a plait can be done in 2 ways: 1, click the plait on the draw panel. It is implemented in Plait.HitTest. 2, click the plait from the object panel. It is in Kernel.
1.3 About draw braids consisting of multiple plaits
I added a class: PlaitImage.The difference between Plait and PlaitImage is: Plait is a programmable object, users can get plait images by the PMethods it supports. In contrast, plait image is only a image for drawing. It is not a PObject.

2. PMethods in Plait
Currently, Plait has the following PMethods:
Duplicate
NextStep: the method for braiding
StartBraiding
GoToStartingAngle
Reflect
DilateByPercent
SetSize
TranslateByPercent
Rotate
SetColorSetImage: currently only take a String in the format of a '/'-separated path name that identifies the resource.

3. Things to be disscussed
3.1 StartBraiding VS GoTo, StartingAngle, + Reflect
Firstly, I added GoTo, StartingAngle, and Reflect for letting the users set up the starting parameters of a braid. But, then there is a problem: Reflect should be called as the last method for setting up the starting parameters. Orelse, reflection can't be done correctly. In the piecture below, the left braid is the original one, the right braid is the one got from reflection about the Y axis. The reflection is not correct, since when the reflection takes place the starting angle is the default 0, not the 90 degree later input by the user.It is possible to change the code to fix this. But which of the 3 ways should we have: only StartBraiding, only GoTo, StartingAngle, + Reflect, or both?
3.2 StartBraiding and Duplicate
Currently, StartBraiding only changes the position and angle of a plait. Users need to call duplicate to have the 1st plait image. Should we have StartBraiding do the duplicate itself?

4. Bug
When the application runs for a while, the texture of the plaits disappear.

No comments:

Post a Comment