Skip to content

Commit 9089562

Browse files
committed
Update for 1.5.14 release
1 parent becefc1 commit 9089562

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6986
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [1.5.14](https://github.com/nicklockwood/ShapeScript/releases/tag/1.5.14) (2022-12-18)
4+
5+
- Added support for C-style block comments using /* ... */ syntax
6+
- Fixed bug where source file could incorrectly be inferred as UTF-7, causing parsing errors
7+
- Fixed issue where error messages would sometimes suggest the same identifier you already used
8+
- Improved script execution performance by making source location lookup lazy
9+
- Bumped Euclid to version 0.6.6
10+
311
## [1.5.13](https://github.com/nicklockwood/ShapeScript/releases/tag/1.5.13) (2022-12-08)
412

513
- Fixed crash when importing external .shape files

ShapeScript.podspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ShapeScript",
3-
"version": "1.5.13",
3+
"version": "1.5.14",
44
"license": {
55
"type": "MIT",
66
"file": "LICENSE.md"
@@ -10,7 +10,7 @@
1010
"authors": "Nick Lockwood",
1111
"source": {
1212
"git": "https://github.com/nicklockwood/ShapeScript.git",
13-
"tag": "1.5.13"
13+
"tag": "1.5.14"
1414
},
1515
"source_files": ["ShapeScript", "LRUCache/Sources", "SVGPath/Sources"],
1616
"requires_arc": true,

ShapeScript.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
"$(inherited)",
11161116
"@executable_path/../Frameworks",
11171117
);
1118-
MARKETING_VERSION = 1.5.13;
1118+
MARKETING_VERSION = 1.5.14;
11191119
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11201120
PRODUCT_MODULE_NAME = Viewer;
11211121
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1143,7 +1143,7 @@
11431143
"$(inherited)",
11441144
"@executable_path/../Frameworks",
11451145
);
1146-
MARKETING_VERSION = 1.5.13;
1146+
MARKETING_VERSION = 1.5.14;
11471147
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11481148
PRODUCT_MODULE_NAME = Viewer;
11491149
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1173,7 +1173,7 @@
11731173
"$(inherited)",
11741174
"@executable_path/Frameworks",
11751175
);
1176-
MARKETING_VERSION = 1.5.13;
1176+
MARKETING_VERSION = 1.5.14;
11771177
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11781178
PRODUCT_MODULE_NAME = Viewer;
11791179
PRODUCT_NAME = ShapeScript;
@@ -1205,7 +1205,7 @@
12051205
"$(inherited)",
12061206
"@executable_path/Frameworks",
12071207
);
1208-
MARKETING_VERSION = 1.5.13;
1208+
MARKETING_VERSION = 1.5.14;
12091209
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
12101210
PRODUCT_MODULE_NAME = Viewer;
12111211
PRODUCT_NAME = ShapeScript;
@@ -1368,7 +1368,7 @@
13681368
"@executable_path/../Frameworks",
13691369
"@loader_path/Frameworks",
13701370
);
1371-
MARKETING_VERSION = 1.5.13;
1371+
MARKETING_VERSION = 1.5.14;
13721372
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
13731373
PRODUCT_NAME = ShapeScript;
13741374
SKIP_INSTALL = YES;
@@ -1399,7 +1399,7 @@
13991399
"@executable_path/../Frameworks",
14001400
"@loader_path/Frameworks",
14011401
);
1402-
MARKETING_VERSION = 1.5.13;
1402+
MARKETING_VERSION = 1.5.14;
14031403
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
14041404
PRODUCT_NAME = ShapeScript;
14051405
SKIP_INSTALL = YES;

ShapeScript/Interpreter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111

1212
// MARK: Public interface
1313

14-
public let version = "1.5.13"
14+
public let version = "1.5.14"
1515

1616
public protocol EvaluationDelegate: AnyObject {
1717
func resolveURL(for path: String) -> URL

docs/1.5.14/ios/blocks.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Blocks
2+
---
3+
4+
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).
5+
6+
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.
7+
8+
You can define your own blocks using the `define` command. Here is a block that creates a five-pointed star:
9+
10+
```swift
11+
define star {
12+
path {
13+
for 1 to 5 {
14+
point 0 -0.5
15+
rotate 1 / 5
16+
point 0 -1
17+
rotate 1 / 5
18+
}
19+
point 0 -0.5
20+
}
21+
}
22+
```
23+
24+
You can call it by simply referencing its name, like this:
25+
26+
```swift
27+
star
28+
```
29+
30+
![Star](../../images/star.png)
31+
32+
**Note:** there is a subtle distinction between the code above and the code below:
33+
34+
```swift
35+
define star path {
36+
for 1 to 5 {
37+
point 0 -0.5
38+
rotate 1 / 5
39+
point 0 -1
40+
rotate 1 / 5
41+
}
42+
point 0 -0.5
43+
}
44+
```
45+
46+
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*.
47+
48+
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.
49+
50+
## Options
51+
52+
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.
53+
54+
The code below extends the `star` definition with options for the radius and number of points:
55+
56+
```swift
57+
define star {
58+
option radius 1
59+
option points 5
60+
path {
61+
for 1 to points {
62+
point 0 -0.5
63+
rotate 1 / points
64+
point 0 -radius
65+
rotate 1 / points
66+
}
67+
point 0 -0.5
68+
}
69+
}
70+
```
71+
72+
Now we can use those options to create a star with 6 points if we choose:
73+
74+
```swift
75+
star {
76+
points 6
77+
radius 2
78+
}
79+
```
80+
81+
![Star](../../images/six-pointed-star.png)
82+
83+
---
84+
[Index](index.md) | Next: [Scope](scope.md)

docs/1.5.14/ios/bounds.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Bounds
2+
---
3+
4+
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.
5+
6+
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):
7+
8+
```swift
9+
define star path {
10+
for 1 to 5 {
11+
point 0 -0.5
12+
rotate 1 / 5
13+
point 0 -1
14+
rotate 1 / 5
15+
}
16+
point 0 -0.5
17+
}
18+
19+
// draw star
20+
extrude {
21+
color red
22+
star
23+
}
24+
25+
// draw cube
26+
cube {
27+
color green 0.5
28+
}
29+
```
30+
31+
![Star with unit cube](../../images/star-with-unit-cube.png)
32+
33+
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.
34+
35+
## Mesh Bounds
36+
37+
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:
38+
39+
```swift
40+
define star {
41+
...
42+
}
43+
44+
// define star shape
45+
define shape extrude {
46+
color red
47+
star
48+
}
49+
50+
// draw star
51+
shape
52+
53+
// draw box around star
54+
cube {
55+
color green 0.5
56+
position shape.bounds.center
57+
size shape.bounds.size
58+
}
59+
```
60+
61+
![Star with fitted cube](../../images/star-with-fitted-cube.png)
62+
63+
## Path Bounds
64+
65+
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:
66+
67+
```swift
68+
define star {
69+
...
70+
}
71+
72+
// draw star
73+
star
74+
75+
// draw rectangle around star
76+
square {
77+
position shape.bounds.center
78+
size shape.bounds.size
79+
}
80+
```
81+
82+
![Star with fitted rectangle](../../images/star-with-fitted-rect.png)
83+
84+
## Bounds Members
85+
86+
The `bounds` member property has the following sub-properties that you can use:
87+
88+
* `min` - The position of the corner of the box with the smallest X, Y and Z values relative to the origin.
89+
* `max` - The position of the corner of the box with the largest X, Y and Z values relative to the origin.
90+
* `center` - The position of the center of the box relative to the origin.
91+
* `size` - The size (width, height and depth) of the box in world units.
92+
* `width` - The width of the box along the X axis (equivalent to `size.width`)
93+
* `height` - The height of the box along the Y axis (equivalent to `size.height`)
94+
* `depth` - The depth of the box along the Z axis (equivalent to `size.depth`)
95+
96+
So, for example, to get the height of a shape, you could use:
97+
98+
```swift
99+
print someShape.bounds.size.height
100+
```
101+
102+
or just:
103+
104+
```swift
105+
print someShape.bounds.height
106+
```
107+
108+
And to get the X coordinate of its rightmost edge you could use:
109+
110+
```swift
111+
print someShape.bounds.max.x
112+
```
113+
114+
---
115+
[Index](index.md) | Next: [Groups](groups.md)

0 commit comments

Comments
 (0)