Skip to content

Commit cbbc667

Browse files
committed
Update for 1.5.10 release
1 parent 38067a9 commit cbbc667

Some content is hidden

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

63 files changed

+6927
-10
lines changed

CHANGELOG.md

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

3+
## [1.5.10](https://github.com/nicklockwood/ShapeScript/releases/tag/1.5.10) (2022-10-29)
4+
5+
- Improved documentation for strings and trigonometry functions
6+
- Fixed empty bounds returned for lathe, fill, extrude and loft shapes
7+
- Fixed runtime warning about postscript font names
8+
- Fixed range bug in error formatting logic
9+
- Fixed inconsistent handling of functions that return tuples
10+
- Fixed inconsistent member lookup handling
11+
- Bumped Euclid to version 0.6.0
12+
- Fixed Linux build warnings
13+
314
## [1.5.9](https://github.com/nicklockwood/ShapeScript/releases/tag/1.5.9) (2022-10-06)
415

516
- Fixed getting started link in Welcome modal

Euclid/Euclid.xcodeproj/project.pbxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,6 @@
650650
ONLY_ACTIVE_ARCH = YES;
651651
SDKROOT = macosx;
652652
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
653-
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
654653
SWIFT_VERSION = 4.2;
655654
VERSIONING_SYSTEM = "apple-generic";
656655
VERSION_INFO_PREFIX = "";

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.9",
3+
"version": "1.5.10",
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.9"
13+
"tag": "1.5.10"
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
@@ -1109,7 +1109,7 @@
11091109
"$(inherited)",
11101110
"@executable_path/../Frameworks",
11111111
);
1112-
MARKETING_VERSION = 1.5.9;
1112+
MARKETING_VERSION = 1.5.10;
11131113
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11141114
PRODUCT_MODULE_NAME = Viewer;
11151115
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1137,7 +1137,7 @@
11371137
"$(inherited)",
11381138
"@executable_path/../Frameworks",
11391139
);
1140-
MARKETING_VERSION = 1.5.9;
1140+
MARKETING_VERSION = 1.5.10;
11411141
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11421142
PRODUCT_MODULE_NAME = Viewer;
11431143
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1167,7 +1167,7 @@
11671167
"$(inherited)",
11681168
"@executable_path/Frameworks",
11691169
);
1170-
MARKETING_VERSION = 1.5.9;
1170+
MARKETING_VERSION = 1.5.10;
11711171
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
11721172
PRODUCT_MODULE_NAME = Viewer;
11731173
PRODUCT_NAME = ShapeScript;
@@ -1199,7 +1199,7 @@
11991199
"$(inherited)",
12001200
"@executable_path/Frameworks",
12011201
);
1202-
MARKETING_VERSION = 1.5.9;
1202+
MARKETING_VERSION = 1.5.10;
12031203
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
12041204
PRODUCT_MODULE_NAME = Viewer;
12051205
PRODUCT_NAME = ShapeScript;
@@ -1363,7 +1363,7 @@
13631363
"@executable_path/../Frameworks",
13641364
"@loader_path/Frameworks",
13651365
);
1366-
MARKETING_VERSION = 1.5.9;
1366+
MARKETING_VERSION = 1.5.10;
13671367
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
13681368
PRODUCT_NAME = ShapeScript;
13691369
SKIP_INSTALL = YES;
@@ -1394,7 +1394,7 @@
13941394
"@executable_path/../Frameworks",
13951395
"@loader_path/Frameworks",
13961396
);
1397-
MARKETING_VERSION = 1.5.9;
1397+
MARKETING_VERSION = 1.5.10;
13981398
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
13991399
PRODUCT_NAME = ShapeScript;
14001400
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.9"
14+
public let version = "1.5.10"
1515

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

docs/1.5.10/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.10/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 needs 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)