KittyCAD / modeling-app

The KittyCAD modeling app.
https://kittycad.io/modeling-app/download
MIT License
347 stars 29 forks source link

Add circle from center tool #1501

Open franknoirot opened 6 months ago

franknoirot commented 6 months ago

Add a sketch tool that generates a rectangle for the user.

User flow

  1. In sketch mode, click the Circle tool to equip it
  2. Click anywhere on the sketch plane to set your circle's center
  3. Move the mouse around to find an appropriate length for the radius
    1. During this, a circle made of a dashed line will appear centered on your first point with a radius to the mouse's position
  4. Click to finish the circle

Code generation

I don't think we should generate new functions for users automatically unless we are prepared to automatically reuse them intelligently on their behalf with later interactions. To avoid that complexity, here is my proposed code generation:

const sketch001 = startSketchOn('XY')

// Generated code: circle001
const circle001_center = [3, 3]
const circle001_radius = 7.1
const circle001 = startProfileAt([circle001_center[0] + circle001_radius, circle001_center[1]], sketch001)
  |> arc({
       angle_end: 360,
       angle_start: 0,
       radius: circle001_radius
     }, %)
  |> close(%)

Additional resources

jessfraz commented 6 months ago

We have a circle function tho so we should use that.

jessfraz commented 6 months ago

I think we should add a rectangle function too then to the stdlib. it just makes the code a lot cleaner

franknoirot commented 6 months ago

Yeah I'd like that @jessfraz as long as we can still tag each segment of the rectangle through the stdlib function.

I agree on the circle function but it's currently called unstable_stdlib_circle so I didn't think that should be included in generated code.

jessfraz commented 6 months ago

yeah we should make those first class and use them

Irev-Dev commented 6 months ago

Jess I disagree about stblib functions for rectangle, I like the proposal Frank had for the tag ability https://github.com/KittyCAD/modeling-app/issues/1500