Closed crapper closed 9 months ago
For 1, I agree that we should have two commands, AddLinearSegment
and AddCurveSegment
.
For 2, I also agree
For 3, I think this is because this.path.segments[index...]
is needed in convertToCubic
, but not in convertToLine
. I think we can just keep it
For 4, I will add them to the Segment class.
For 5, I think I can change some of though
Resolved
Is your feature request related to a problem? Please describe. After reading the structure of the AddSegment, ConvertSegment, and Segment classes, I have the following concerns about these three classes:
For AddSegment, I believe that using a variable variant to determine what will be executed violated SRP, I believe there should be two command classes called
AddLinearSegment
andAddCurveSegment
instead of the current one.For ConvertSegment, I believe that the function
convertToLine
should be renamed asconvertToLinear
Furthermore, there is a section for checking the existence of the target modify segment in the path for function
convertToCurve
, https://github.com/Jerrylum/path.jerryio/blob/42f066990269a61df698f3aa008047150621c86d/src/core/Command.ts#L500-L503 But this section does not exist incovertToLine
https://github.com/Jerrylum/path.jerryio/blob/42f066990269a61df698f3aa008047150621c86d/src/core/Command.ts#L496-L498 Please investigate whether this validation is required or not for both of functionFor the Segment class, I believe there should contain functions that are similar to the following suggestion
And modify the usage of checking the type of line for the segment, for example, https://github.com/Jerrylum/path.jerryio/blob/42f066990269a61df698f3aa008047150621c86d/src/app/SegmentPointsHitBoxElement.tsx#L47 to
if (props.segment.isLinear)
For the enum of
SegmentVariant
, I suggest implementing it as the following:To prevent any direct comparison with the string that may appear in the future, which may harm the readability of the codes. (I know currently the actual value of the enum does not bother for the code readability).