Skip to content

Commit

Permalink
Fixed README code indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoz committed Aug 17, 2014
1 parent 16032bb commit 3111b50
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions README.markdown
Expand Up @@ -37,83 +37,83 @@ Examples

### Point
```ruby
point = Geometry::Point[3,4] # 2D Point at coordinate 3, 4
point = Geometry::Point[3,4] # 2D Point at coordinate 3, 4

# Copy constructors
point2 = Geometry::Point[point]
point2 = Geometry::Point[Vector[5,6]]
# Copy constructors
point2 = Geometry::Point[point]
point2 = Geometry::Point[Vector[5,6]]

# Accessors
point.x
point.y
point[2] # Same as point.z
# Accessors
point.x
point.y
point[2] # Same as point.z

# Zero
PointZero.new # A Point full of zeros of unspecified length
Point.zero # Another way to do the same thing
Point.zero(3) # => Point[0,0,0]
# Zero
PointZero.new # A Point full of zeros of unspecified length
Point.zero # Another way to do the same thing
Point.zero(3) # => Point[0,0,0]
```

### Line
```ruby
# Two-point constructors
line = Geometry::Line[[0,0], [10,10]]
line = Geometry::Line[Geometry::Point[0,0], Geometry::Point[10,10]]
line = Geometry::Line[Vector[0,0], Vector[10,10]]

# Slope-intercept constructors
Geometry::Line[Rational(3,4), 5] # Slope = 3/4, Intercept = 5
Geometry::Line[0.75, 5]

# Point-slope constructors
Geometry::Line(Geometry::Point[0,0], 0.75)
Geometry::Line(Vector[0,0], Rational(3,4))

# Special constructors (2D only)
Geometry::Line.horizontal(y=0)
Geometry::Line.vertical(x=0)
# Two-point constructors
line = Geometry::Line[[0,0], [10,10]]
line = Geometry::Line[Geometry::Point[0,0], Geometry::Point[10,10]]
line = Geometry::Line[Vector[0,0], Vector[10,10]]

# Slope-intercept constructors
Geometry::Line[Rational(3,4), 5] # Slope = 3/4, Intercept = 5
Geometry::Line[0.75, 5]

# Point-slope constructors
Geometry::Line(Geometry::Point[0,0], 0.75)
Geometry::Line(Vector[0,0], Rational(3,4))

# Special constructors (2D only)
Geometry::Line.horizontal(y=0)
Geometry::Line.vertical(x=0)
```

### Rectangle
```ruby
# A Rectangle made from two corner points
Geometry::Rectangle.new [1,2], [2,3]
Geometry::Rectangle.new from:[1,2], to:[2,3]
# A Rectangle made from two corner points
Geometry::Rectangle.new [1,2], [2,3]
Geometry::Rectangle.new from:[1,2], to:[2,3]

Geometry::Rectangle.new center:[1,2], size:[1,1] # Using a center point and a size
Geometry::Rectangle.new origin:[1,2], size:[1,1] # Using an origin point and a size
Geometry::Rectangle.new center:[1,2], size:[1,1] # Using a center point and a size
Geometry::Rectangle.new origin:[1,2], size:[1,1] # Using an origin point and a size

# A Rectangle with its origin at [0, 0] and a size of [10, 20]
Geometry::Rectangle.new size: [10, 20]
Geometry::Rectangle.new size: Size[10, 20]
Geometry::Rectangle.new width: 10, height: 20
# A Rectangle with its origin at [0, 0] and a size of [10, 20]
Geometry::Rectangle.new size: [10, 20]
Geometry::Rectangle.new size: Size[10, 20]
Geometry::Rectangle.new width: 10, height: 20
```

### Circle
```ruby
# A circle at Point[1,2] with a radius of 3
circle = Geometry::Circle.new center:[1,2], radius:3
# A circle at Point[1,2] with a radius of 3
circle = Geometry::Circle.new center:[1,2], radius:3
```

### Polygon
```ruby
# A polygon that looks a lot like a square
polygon = Geometry::Polygon.new [0,0], [1,0], [1,1], [0,1]
# A polygon that looks a lot like a square
polygon = Geometry::Polygon.new [0,0], [1,0], [1,1], [0,1]
```
### Regular Polygon
```ruby
# Everyone loves a good hexagon
hexagon = Geometry::RegularPolygon.new 6, :diameter => 3
# Everyone loves a good hexagon
hexagon = Geometry::RegularPolygon.new 6, :diameter => 3
```

### Zeros and Ones
```ruby
# For when you know you need a zero, but you don't know how big it should be
zero = Point.zero # Returns a Point of indeterminate length that always compares equal to zero
# For when you know you need a zero, but you don't know how big it should be
zero = Point.zero # Returns a Point of indeterminate length that always compares equal to zero

# Oh, you wanted ones instead? No problem.
ones = Point.one # => Point[1,1,1...1]
# Oh, you wanted ones instead? No problem.
ones = Point.one # => Point[1,1,1...1]

# Looking for something more exotic that a mere 1?
iso = Point.iso(5) # => Point[5,5,5...5]
# Looking for something more exotic that a mere 1?
iso = Point.iso(5) # => Point[5,5,5...5]
```

0 comments on commit 3111b50

Please sign in to comment.