Skip to content

Commit

Permalink
Update for 1.7.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Oct 25, 2023
1 parent 4195d29 commit 5bd03f1
Show file tree
Hide file tree
Showing 66 changed files with 8,178 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [1.7.1](https://github.com/nicklockwood/ShapeScript/releases/tag/1.7.1) (2023-10-23)

- Fixed spotlight debug shape orientation
- Added `Geometry.withoutLights()` method
- Added `Geometry.withoutGroupTransform()` method
- Deprecated `Geometry.with(name:)` method
- Added `point.isCurved` and `polygon.center` member properties
- Added `object` type logging and made logging less error-prone
- Added documentation for lights limit introduced in 1.7.0

## [1.7.0](https://github.com/nicklockwood/ShapeScript/releases/tag/1.7.0) (2023-10-14)

- Fixed ambiguity when calling functions with parenthesized arguments
Expand Down
4 changes: 2 additions & 2 deletions ShapeScript.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ShapeScript",
"version": "1.7.0",
"version": "1.7.1",
"license": {
"type": "MIT",
"file": "LICENSE.md"
Expand All @@ -10,7 +10,7 @@
"authors": "Nick Lockwood",
"source": {
"git": "https://github.com/nicklockwood/ShapeScript.git",
"tag": "1.7.0"
"tag": "1.7.1"
},
"source_files": ["ShapeScript", "LRUCache/Sources", "SVGPath/Sources"],
"requires_arc": true,
Expand Down
12 changes: 6 additions & 6 deletions ShapeScript.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
PRODUCT_MODULE_NAME = Viewer;
PRODUCT_NAME = "ShapeScript Viewer";
Expand Down Expand Up @@ -1344,7 +1344,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
PRODUCT_MODULE_NAME = Viewer;
PRODUCT_NAME = "ShapeScript Viewer";
Expand Down Expand Up @@ -1374,7 +1374,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
PRODUCT_MODULE_NAME = Viewer;
PRODUCT_NAME = ShapeScript;
Expand Down Expand Up @@ -1406,7 +1406,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
PRODUCT_MODULE_NAME = Viewer;
PRODUCT_NAME = ShapeScript;
Expand Down Expand Up @@ -1570,7 +1570,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
Expand Down Expand Up @@ -1607,7 +1607,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.7.0;
MARKETING_VERSION = 1.7.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
Expand Down
2 changes: 1 addition & 1 deletion ShapeScript/Interpreter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation

// MARK: Public interface

public let version = "1.7.0"
public let version = "1.7.1"

public protocol EvaluationDelegate: AnyObject {
func resolveURL(for path: String) -> URL
Expand Down
25 changes: 25 additions & 0 deletions Viewer/Mac/WhatsNew.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ What's New in ShapeScript?\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0

\f1\b\fs28 \cf2 ShapeScript 1.7.1 \'97 2023-10-23\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
\cf2 \kerning1\expnd0\expndtw0 \'95
\f0\b0 \expnd0\expndtw0\kerning0
Fixed spotlight debug shape orientation.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Added `Geometry.withoutLights()` method.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Added `Geometry.withoutGroupTransform()` method.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Deprecated `Geometry.with(name:)` method.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Added `point.isCurved` and `polygon.center` member properties.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Added `object` type logging and made logging less error-prone.\
\ \'95
\f0\b0 \expnd0\expndtw0\kerning0
Added documentation for lights limit introduced in 1.7.0.\
\
\f1\b\fs28 \cf2 ShapeScript 1.7.0 \'97 2023-10-14\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
Expand Down
26 changes: 26 additions & 0 deletions Viewer/iOS/WhatsNew.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@
\paperw11900\paperh16840\margl1440\margr1440\vieww24140\viewh18420\viewkind0
\deftab720

\f0\b \cf2 ShapeScript 1.7.1 \'97 2023-10-23\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
\cf2 \kerning1\expnd0\expndtw0
\f1\b0 \expnd0\expndtw0\kerning0 \'95
\f1\b0 \expnd0\expndtw0\kerning0
Fixed spotlight debug shape orientation.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Added `Geometry.withoutLights()` method.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Added `Geometry.withoutGroupTransform()` method.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Deprecated `Geometry.with(name:)` method.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Added `point.isCurved` and `polygon.center` member properties.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Added `object` type logging and made logging less error-prone.\
\ \'95
\f1\b0 \expnd0\expndtw0\kerning0
Added documentation for lights limit introduced in 1.7.0.\
\
\f0\b \cf2 ShapeScript 1.7.0 \'97 2023-10-14\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
Expand Down
84 changes: 84 additions & 0 deletions docs/1.7.1/ios/blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Blocks
---

A block is a nested list of instructions, contained inside `{ ... }` braces. Some commands, such as [builders](builders.md) or [CSG operations](csg.md), accept a block parameter instead of a simple value like a number or [vector](literals.md#vectors-and-tuples).

Instructions inside a block are executed within the [scope](scope.md) of the command that invoked them. Typically that means that any transforms or material changes made inside the block will only apply to geometry created inside the same block. This also applies to any symbols that you define inside the block.

You can define your own blocks using the `define` command. Here is a block that creates a five-pointed star:

```swift
define star {
path {
for 1 to 5 {
point 0 -0.5
rotate 1 / 5
point 0 -1
rotate 1 / 5
}
point 0 -0.5
}
}
```

You can call it by simply referencing its name, like this:

```swift
star
```

![Star](../../images/star.png)

**Note:** there is a subtle distinction between the code above and the code below:

```swift
define star path {
for 1 to 5 {
point 0 -0.5
rotate 1 / 5
point 0 -1
rotate 1 / 5
}
point 0 -0.5
}
```

In the original code, we defined a new block symbol that creates a star-shaped path. In the code above we've defined a symbol whose value is a star-shaped path. The former code is evaluated at the point when it is *called*, whereas the latter code is evaluated at the point when it is *defined*.

The end-result is the same in this case, so it may seem like the distinction doesn't matter, but the advantage of the former approach is that we can add *options* to vary the behavior of the code when it is called.

## Options

To add an option to a block, you use the `option` command. This works in a similar way to the [define](symbols.md) command, but it allows the specified value to be overridden by the caller.

The code below extends the `star` definition with options for the radius and number of points:

```swift
define star {
option radius 1
option points 5
path {
for 1 to points {
point 0 -0.5
rotate 1 / points
point 0 -radius
rotate 1 / points
}
point 0 -0.5
}
}
```

Now we can use those options to create a star with 6 points if we choose:

```swift
star {
points 6
radius 2
}
```

![Star](../../images/six-pointed-star.png)

---
[Index](index.md) | Next: [Scope](scope.md)
115 changes: 115 additions & 0 deletions docs/1.7.1/ios/bounds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Bounds
---

ShapeScript's [size](transforms.md#size) ands [scale](transforms.md#relative-transforms) commands let you control the relative size of a shape, but sometimes it's useful to know the exact dimensions.

A cube of size 1 has an easily-predicted size of one world unit square, but what about a more complex shape, such as a 5-pointed star (see the [procedural paths](paths.md#procedural-paths) and [blocks](blocks.md) sections for details):

```swift
define star path {
for 1 to 5 {
point 0 -0.5
rotate 1 / 5
point 0 -1
rotate 1 / 5
}
point 0 -0.5
}

// draw star
extrude {
color red
star
}

// draw cube
cube {
color green 0.5
}
```

![Star with unit cube](../../images/star-with-unit-cube.png)

We can see that the star is larger than the unit cube, but other than trial-and-error or complex math, how can we get the exact size? This is where the `bounds` [member property](expressions.md#members) comes in.

## Mesh Bounds

Paths and meshes both expose a `bounds` property that represents a bounding box around the shape. From this you can get the exact size and position needed to place a box around the star:

```swift
define star {
...
}

// define star shape
define shape extrude {
color red
star
}

// draw star
shape

// draw box around star
cube {
color green 0.5
position shape.bounds.center
size shape.bounds.size
}
```

![Star with fitted cube](../../images/star-with-fitted-cube.png)

## Path Bounds

In the example above we computed the bounds of a solid `mesh` (an extruded star-shaped `path`) but you can also get the bounds of a `path` directly. The following code draws the star path inside its bounding rectangle:

```swift
define star {
...
}

// draw star
star

// draw rectangle around star
square {
position shape.bounds.center
size shape.bounds.size
}
```

![Star with fitted rectangle](../../images/star-with-fitted-rect.png)

## Bounds Members

The `bounds` member property has the following sub-properties that you can use:

* `min` - The position of the corner of the box with the smallest X, Y and Z values relative to the origin.
* `max` - The position of the corner of the box with the largest X, Y and Z values relative to the origin.
* `center` - The position of the center of the box relative to the origin.
* `size` - The size (width, height and depth) of the box in world units.
* `width` - The width of the box along the X axis (equivalent to `size.width`)
* `height` - The height of the box along the Y axis (equivalent to `size.height`)
* `depth` - The depth of the box along the Z axis (equivalent to `size.depth`)

So, for example, to get the height of a shape, you could use:

```swift
print someShape.bounds.size.height
```

or just:

```swift
print someShape.bounds.height
```

And to get the X coordinate of its rightmost edge you could use:

```swift
print someShape.bounds.max.x
```

---
[Index](index.md) | Next: [Meshes](meshes.md)
Loading

0 comments on commit 5bd03f1

Please sign in to comment.