Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Circle): Add counterclockwise parameter to Circle class #9670

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

lbordowitz
Copy link
Contributor

Description

This resolves issue #9653 to implement orientation to the circle. I have also taken the liberty of tidying the documentation, per #9654 , to emphasize that the angle is in degrees and will stay that way.

In Action

I used npm start node and the following code snippet for index.mjs:

const canvas = new fabric.StaticCanvas(null, { width: 500, height: 500 });
    const circle1 = new fabric.Circle({
      left: 100,
      top: 100,
      radius: 20,
      originX: 'center',
      originY: 'center',
      fill: 'rgba(0,0,0,0)',
      noScaleCache: false,
      strokeUniform: true,
      strokeWidth: 1,
      stroke: '#00ff00',
      selectable: false,
      hasControls: false,
      lockScalingX: true,
      lockScalingY: true,
      startAngle: 45,
      endAngle: 270,
    })
    const circle2 = new fabric.Circle({
      left: 200,
      top: 100,
      radius: 20,
      originX: 'center',
      originY: 'center',
      fill: 'rgba(0,0,0,0)',
      noScaleCache: false,
      strokeUniform: true,
      strokeWidth: 1,
      stroke: '#00ff00',
      selectable: false,
      hasControls: false,
      lockScalingX: true,
      lockScalingY: true,
      startAngle: 45,
      endAngle: 270,
      clockwise: false,
    })
    canvas.add(circle1, circle2);
    canvas.renderAll();

This is the resulting snapshot:

2024-02-15_21-17-31

Note that they sweep out complementary angles.

Copy link

codesandbox bot commented Feb 16, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good
I am not sure if how we should name the flag
Maybe it doesn't matter
Anyways we want to align to MDN at least with the default value, I would align also with the flag name
What do you think?

src/shapes/Circle.ts Outdated Show resolved Hide resolved
src/shapes/Circle.ts Outdated Show resolved Hide resolved
src/shapes/Circle.ts Outdated Show resolved Hide resolved
@ShaMan123
Copy link
Contributor

The PR is missing a changelog entry and prettier (npm run prettier:write)
You can read the contribution guide for more context

@ShaMan123
Copy link
Contributor

We might want to add the visual as a test, @asturur ?

@lbordowitz lbordowitz force-pushed the larry-cw branch 2 times, most recently from 6f669e9 to 568f69e Compare February 16, 2024 14:30
@ShaMan123 ShaMan123 changed the title feat(Circle): Add clockwise parameter to Circle class feat(Circle): Add counterclockwise parameter to Circle class Feb 17, 2024
Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

src/shapes/Circle.ts Outdated Show resolved Hide resolved
src/shapes/Circle.ts Outdated Show resolved Hide resolved
test/unit/circle.js Outdated Show resolved Hide resolved
src/shapes/Circle.ts Outdated Show resolved Hide resolved
@asturur
Copy link
Member

asturur commented Feb 17, 2024

Just to make clear how things seems obvious but aren't, i understood this would behave completely different,
a circle from 0 to 30 in counter clockwise for me would have created a sector of 30 degrees turning counter clockwise and not a circle of 360-30.

src/shapes/Circle.ts Outdated Show resolved Hide resolved
@asturur
Copy link
Member

asturur commented Feb 18, 2024

I m ok also without the visual test, since for now.
I would like to use this occasion to try to add the token with the permissions to actually execute those extra checks from forks, i ll merge it monday/tuesday when i can try to work on the token

Copy link
Contributor

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asturur I will not merge n case you want to work on the tokens

@asturur
Copy link
Member

asturur commented Feb 25, 2024

The token thing is not as easy as it seems.
Or at least is not so straight forward.
I created a personal token and i added it in the repo, with granular permission on how to write.
Now i have to figure out how to make it appear as an env variable in the actions and have the apis use it.

@asturur asturur merged commit 8d962d7 into fabricjs:master Feb 25, 2024
20 of 22 checks passed
@lbordowitz lbordowitz deleted the larry-cw branch April 8, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants