Skip to content

Commit d480339

Browse files
committed
Update for 1.8.0 release
1 parent 61efc5a commit d480339

Some content is hidden

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

69 files changed

+8836
-12
lines changed

CHANGELOG.md

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

3+
## [1.8.0](https://github.com/nicklockwood/ShapeScript/releases/tag/1.8.0) (2023-11-25)
4+
5+
- Added `switch/case` statements
6+
- Added subscripting support for objects and tuples
7+
- Added `object` constructor command
8+
- Objects can now be cast to/from memberwise types
9+
- Added `light.shadow` property
10+
- The `opacity` property can now be set to a texture
11+
- Textures now use nearest-neighbor filtering for upscaling instead of linear
12+
- Added `normals` command for setting surface normals with a texture
13+
- Added `roughness` and `metallicity` properties for physically based rendering (PBR)
14+
- Added `material` command for setting all material properties at once
15+
- Combined `Material.color` and `texture` properties into single property internally
16+
- The `Material.isOpaque` property is now correctly computed when using a texture
17+
- Added `text.string`, `font`, `color` and `linespacing` members
18+
- You can now use `import` statements in expressions
19+
- Object values are now correctly unwrapped
20+
- Removed some deprecated methods
21+
322
## [1.7.1](https://github.com/nicklockwood/ShapeScript/releases/tag/1.7.1) (2023-10-23)
423

524
- Fixed spotlight debug shape orientation

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.7.1",
3+
"version": "1.8.0",
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.7.1"
13+
"tag": "1.8.0"
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
@@ -1332,7 +1332,7 @@
13321332
"$(inherited)",
13331333
"@executable_path/../Frameworks",
13341334
);
1335-
MARKETING_VERSION = 1.7.1;
1335+
MARKETING_VERSION = 1.8.0;
13361336
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
13371337
PRODUCT_MODULE_NAME = Viewer;
13381338
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1360,7 +1360,7 @@
13601360
"$(inherited)",
13611361
"@executable_path/../Frameworks",
13621362
);
1363-
MARKETING_VERSION = 1.7.1;
1363+
MARKETING_VERSION = 1.8.0;
13641364
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
13651365
PRODUCT_MODULE_NAME = Viewer;
13661366
PRODUCT_NAME = "ShapeScript Viewer";
@@ -1390,7 +1390,7 @@
13901390
"$(inherited)",
13911391
"@executable_path/Frameworks",
13921392
);
1393-
MARKETING_VERSION = 1.7.1;
1393+
MARKETING_VERSION = 1.8.0;
13941394
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
13951395
PRODUCT_MODULE_NAME = Viewer;
13961396
PRODUCT_NAME = ShapeScript;
@@ -1422,7 +1422,7 @@
14221422
"$(inherited)",
14231423
"@executable_path/Frameworks",
14241424
);
1425-
MARKETING_VERSION = 1.7.1;
1425+
MARKETING_VERSION = 1.8.0;
14261426
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptViewer;
14271427
PRODUCT_MODULE_NAME = Viewer;
14281428
PRODUCT_NAME = ShapeScript;
@@ -1586,7 +1586,7 @@
15861586
"@executable_path/../Frameworks",
15871587
"@loader_path/Frameworks",
15881588
);
1589-
MARKETING_VERSION = 1.7.1;
1589+
MARKETING_VERSION = 1.8.0;
15901590
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
15911591
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
15921592
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;
@@ -1623,7 +1623,7 @@
16231623
"@executable_path/../Frameworks",
16241624
"@loader_path/Frameworks",
16251625
);
1626-
MARKETING_VERSION = 1.7.1;
1626+
MARKETING_VERSION = 1.8.0;
16271627
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
16281628
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
16291629
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.ShapeScriptLib;

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.7.1"
14+
public let version = "1.8.0"
1515

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

Viewer/Mac/WhatsNew.rtf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,58 @@ What's New in ShapeScript?\
1111
\
1212
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
1313

14+
\f1\b\fs28 \cf2 ShapeScript 1.8.0 \'97 2023-11-25\
15+
\
16+
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
17+
\cf2 \kerning1\expnd0\expndtw0 \'95
18+
\f0\b0 \expnd0\expndtw0\kerning0
19+
Added `switch/case` statements.\
20+
\ \'95
21+
\f0\b0 \expnd0\expndtw0\kerning0
22+
Added subscripting support for objects and tuples.\
23+
\ \'95
24+
\f0\b0 \expnd0\expndtw0\kerning0
25+
Added `object` constructor command.\
26+
\ \'95
27+
\f0\b0 \expnd0\expndtw0\kerning0
28+
Objects can now be cast to/from memberwise types.\
29+
\ \'95
30+
\f0\b0 \expnd0\expndtw0\kerning0
31+
Added `light.shadow` property.\
32+
\ \'95
33+
\f0\b0 \expnd0\expndtw0\kerning0
34+
The `opacity` property can now be set to a texture.\
35+
\ \'95
36+
\f0\b0 \expnd0\expndtw0\kerning0
37+
Textures now use nearest-neighbor filtering for upscaling instead of linear.\
38+
\ \'95
39+
\f0\b0 \expnd0\expndtw0\kerning0
40+
Added `normals` command for setting surface normals with a texture.\
41+
\ \'95
42+
\f0\b0 \expnd0\expndtw0\kerning0
43+
Added `roughness` and `metallicity` properties for physically based rendering (PBR) .\
44+
\ \'95
45+
\f0\b0 \expnd0\expndtw0\kerning0
46+
Added `material` command for setting all material properties at once.\
47+
\ \'95
48+
\f0\b0 \expnd0\expndtw0\kerning0
49+
Combined `Material.color` and `texture` properties into single property internally.\
50+
\ \'95
51+
\f0\b0 \expnd0\expndtw0\kerning0
52+
The `Material.isOpaque` property is now correctly computed when using a texture.\
53+
\ \'95
54+
\f0\b0 \expnd0\expndtw0\kerning0
55+
Added `text.string`, `font`, `color` and `linespacing` members.\
56+
\ \'95
57+
\f0\b0 \expnd0\expndtw0\kerning0
58+
You can now use `import` statements in expressions.\
59+
\ \'95
60+
\f0\b0 \expnd0\expndtw0\kerning0
61+
Object values are now correctly unwrapped.\
62+
\ \'95
63+
\f0\b0 \expnd0\expndtw0\kerning0
64+
Removed some deprecated methods.\
65+
\
1466
\f1\b\fs28 \cf2 ShapeScript 1.7.1 \'97 2023-10-23\
1567
\
1668
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0

Viewer/iOS/WhatsNew.rtf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,59 @@
55
\paperw11900\paperh16840\margl1440\margr1440\vieww24140\viewh18420\viewkind0
66
\deftab720
77

8+
\f0\b \cf2 ShapeScript 1.8.0 \'97 2023-11-25\
9+
\
10+
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0
11+
\cf2 \kerning1\expnd0\expndtw0
12+
\f1\b0 \expnd0\expndtw0\kerning0 \'95
13+
\f1\b0 \expnd0\expndtw0\kerning0
14+
Added `switch/case` statements.\
15+
\ \'95
16+
\f1\b0 \expnd0\expndtw0\kerning0
17+
Added subscripting support for objects and tuples.\
18+
\ \'95
19+
\f1\b0 \expnd0\expndtw0\kerning0
20+
Added `object` constructor command.\
21+
\ \'95
22+
\f1\b0 \expnd0\expndtw0\kerning0
23+
Objects can now be cast to/from memberwise types.\
24+
\ \'95
25+
\f1\b0 \expnd0\expndtw0\kerning0
26+
Added `light.shadow` property.\
27+
\ \'95
28+
\f1\b0 \expnd0\expndtw0\kerning0
29+
The `opacity` property can now be set to a texture.\
30+
\ \'95
31+
\f1\b0 \expnd0\expndtw0\kerning0
32+
Textures now use nearest-neighbor filtering for upscaling instead of linear.\
33+
\ \'95
34+
\f1\b0 \expnd0\expndtw0\kerning0
35+
Added `normals` command for setting surface normals with a texture.\
36+
\ \'95
37+
\f1\b0 \expnd0\expndtw0\kerning0
38+
Added `roughness` and `metallicity` properties for physically based rendering (PBR) .\
39+
\ \'95
40+
\f1\b0 \expnd0\expndtw0\kerning0
41+
Added `material` command for setting all material properties at once.\
42+
\ \'95
43+
\f1\b0 \expnd0\expndtw0\kerning0
44+
Combined `Material.color` and `texture` properties into single property internally.\
45+
\ \'95
46+
\f1\b0 \expnd0\expndtw0\kerning0
47+
The `Material.isOpaque` property is now correctly computed when using a texture.\
48+
\ \'95
49+
\f1\b0 \expnd0\expndtw0\kerning0
50+
Added `text.string`, `font`, `color` and `linespacing` members.\
51+
\ \'95
52+
\f1\b0 \expnd0\expndtw0\kerning0
53+
You can now use `import` statements in expressions.\
54+
\ \'95
55+
\f1\b0 \expnd0\expndtw0\kerning0
56+
Object values are now correctly unwrapped.\
57+
\ \'95
58+
\f1\b0 \expnd0\expndtw0\kerning0
59+
Removed some deprecated methods.\
60+
\
861
\f0\b \cf2 ShapeScript 1.7.1 \'97 2023-10-23\
962
\
1063
\pard\tx220\tx720\pardeftab720\li720\fi-720\partightenfactor0

docs/1.8.0/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)

0 commit comments

Comments
 (0)