Fix ascii diagram and remove unused code
This commit is contained in:
parent
a64d87eb61
commit
d91ace98ec
2 changed files with 18 additions and 19 deletions
|
|
@ -167,11 +167,10 @@ func NewShape(shapeType string, box *geo.Box) Shape {
|
|||
// p is the prev point (used to calculate slope)
|
||||
// s is the point on the actual shape border that'll be returned
|
||||
//
|
||||
// p
|
||||
// │
|
||||
// │
|
||||
// ▼
|
||||
//
|
||||
// p
|
||||
// │
|
||||
// │
|
||||
// ▼
|
||||
// ┌────r─────────────────────────┐
|
||||
// │ │
|
||||
// │ │ │
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package shape
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"oss.terrastruct.com/d2/lib/geo"
|
||||
"oss.terrastruct.com/d2/lib/svg"
|
||||
)
|
||||
|
||||
type shapeDoubleCircle struct {
|
||||
|
|
@ -18,20 +19,19 @@ func NewDoubleCircle(box *geo.Box) Shape {
|
|||
}
|
||||
}
|
||||
|
||||
func doubleCirclePath(box *geo.Box) *svg.SvgPathContext {
|
||||
// halfYFactor := 43.6 / 87.3
|
||||
pc := svg.NewSVGPathContext(box.TopLeft, box.Width, box.Height)
|
||||
pc.StartAt(pc.Absolute(0.25, 0))
|
||||
// pc
|
||||
return pc
|
||||
func (s shapeDoubleCircle) AspectRatio1() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s shapeDoubleCircle) GetDimensionsToFit(width, height, padding float64) (float64, float64) {
|
||||
radius := math.Ceil(math.Sqrt(math.Pow(width/2, 2)+math.Pow(height/2, 2))) + padding
|
||||
return radius * 2, radius * 2
|
||||
}
|
||||
|
||||
func (s shapeDoubleCircle) GetInsidePlacement(width, height, padding float64) geo.Point {
|
||||
return *geo.NewPoint(s.Box.TopLeft.X+math.Ceil(s.Box.Width/2-width/2), s.Box.TopLeft.Y+math.Ceil(s.Box.Height/2-height/2))
|
||||
}
|
||||
|
||||
func (s shapeDoubleCircle) Perimeter() []geo.Intersectable {
|
||||
return doubleCirclePath(s.Box).Path
|
||||
}
|
||||
|
||||
func (s shapeDoubleCircle) GetSVGPathData() []string {
|
||||
return []string{
|
||||
doubleCirclePath(s.Box).PathData(),
|
||||
}
|
||||
return []geo.Intersectable{geo.NewEllipse(s.Box.Center(), s.Box.Width/2, s.Box.Height/2)}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue