Skip to content

Commit 85786e2

Browse files
committed
Chapter optimization.
1 parent 697f3bb commit 85786e2

File tree

10 files changed

+104
-243
lines changed

10 files changed

+104
-243
lines changed

FanOfAscii.xcodeproj/project.pbxproj

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* Begin PBXBuildFile section */
1010
5E086DD32051E3A3004D8D25 /* Manifest.plist in Copy Book Contents */ = {isa = PBXBuildFile; fileRef = 5E086DCF2051DF0F004D8D25 /* Manifest.plist */; };
1111
5E551EC52371FC3F00784365 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E551EC42371FC3F00784365 /* Assets.xcassets */; };
12-
5E6F7E592367B529008CC191 /* UserModules in Copy Book Contents */ = {isa = PBXBuildFile; fileRef = 5E6F7E582367B51E008CC191 /* UserModules */; };
1312
5E70679F23678DC30094BDEF /* Modules in Copy Book Contents */ = {isa = PBXBuildFile; fileRef = 5E70679E23678DC00094BDEF /* Modules */; };
1413
5EA2E3CA2056F35B00416A35 /* LiveViewTestAppLaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EA2E3C82056F35B00416A35 /* LiveViewTestAppLaunchScreen.storyboard */; };
1514
5EA2E3D42056F36800416A35 /* libBookCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EF2F9AB2054BBF300191409 /* libBookCore.a */; };
@@ -51,7 +50,6 @@
5150
71DEC1D123F7A2650091A700 /* MagnivierContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71DEC1CA23F7A2650091A700 /* MagnivierContainerView.swift */; };
5251
B99F601776463D11A9D27562 /* RawImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B99F64A84845D64CE275B689 /* RawImage.swift */; };
5352
B99F698C51828CE1EDB67F31 /* EventListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = B99F62E8DB3B358AE077D14A /* EventListener.swift */; };
54-
B99F6A0539C60909F28B9D78 /* RawImage+BookAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B99F609D7C49788B520D9C59 /* RawImage+BookAPI.swift */; };
5553
B99F6F92FC79077F0AF4C414 /* HistogramToolBarButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B99F60BCF4AD4401FD95EBC5 /* HistogramToolBarButtonView.swift */; };
5654
/* End PBXBuildFile section */
5755

@@ -93,20 +91,6 @@
9391
remoteGlobalIDString = 5E6F7E602368FB6A008CC191;
9492
remoteInfo = BookAPI;
9593
};
96-
5E6F7E7B2368FF1D008CC191 /* PBXContainerItemProxy */ = {
97-
isa = PBXContainerItemProxy;
98-
containerPortal = 5E2A7ADD204F611300F4E17A /* Project object */;
99-
proxyType = 1;
100-
remoteGlobalIDString = 5E6F7E602368FB6A008CC191;
101-
remoteInfo = BookAPI;
102-
};
103-
5E6F7E7E2368FF3D008CC191 /* PBXContainerItemProxy */ = {
104-
isa = PBXContainerItemProxy;
105-
containerPortal = 5E2A7ADD204F611300F4E17A /* Project object */;
106-
proxyType = 1;
107-
remoteGlobalIDString = 5E6F7E732368FF15008CC191;
108-
remoteInfo = UserModule;
109-
};
11094
5EA2E3CF2056F36100416A35 /* PBXContainerItemProxy */ = {
11195
isa = PBXContainerItemProxy;
11296
containerPortal = 5E2A7ADD204F611300F4E17A /* Project object */;
@@ -140,7 +124,6 @@
140124
5E086DD32051E3A3004D8D25 /* Manifest.plist in Copy Book Contents */,
141125
5EF2F9B72054E6FB00191409 /* Chapters in Copy Book Contents */,
142126
5E70679F23678DC30094BDEF /* Modules in Copy Book Contents */,
143-
5E6F7E592367B529008CC191 /* UserModules in Copy Book Contents */,
144127
);
145128
name = "Copy Book Contents";
146129
runOnlyForDeploymentPostprocessing = 0;
@@ -168,10 +151,8 @@
168151
5E0E37542065A065008FA4BE /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
169152
5E2A7AE6204F630600F4E17A /* BaseBuildSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = BaseBuildSettings.xcconfig; sourceTree = "<group>"; };
170153
5E551EC42371FC3F00784365 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
171-
5E6F7E582367B51E008CC191 /* UserModules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = UserModules; sourceTree = "<group>"; };
172154
5E6F7E612368FB6A008CC191 /* libBookAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBookAPI.a; sourceTree = BUILT_PRODUCTS_DIR; };
173155
5E6F7E6D2368FC9A008CC191 /* ModuleOverridingBuildSettings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ModuleOverridingBuildSettings.xcconfig; sourceTree = "<group>"; };
174-
5E6F7E742368FF15008CC191 /* libUserModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libUserModule.a; sourceTree = BUILT_PRODUCTS_DIR; };
175156
5E70679E23678DC00094BDEF /* Modules */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Modules; sourceTree = "<group>"; };
176157
5E80DF292342971E00595EB4 /* LiveViewTestApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LiveViewTestApp.entitlements; sourceTree = "<group>"; };
177158
5EA2E3BD2056F35A00416A35 /* LiveViewTestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LiveViewTestApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -228,13 +209,6 @@
228209
);
229210
runOnlyForDeploymentPostprocessing = 0;
230211
};
231-
5E6F7E712368FF15008CC191 /* Frameworks */ = {
232-
isa = PBXFrameworksBuildPhase;
233-
buildActionMask = 2147483647;
234-
files = (
235-
);
236-
runOnlyForDeploymentPostprocessing = 0;
237-
};
238212
5EA2E3BA2056F35A00416A35 /* Frameworks */ = {
239213
isa = PBXFrameworksBuildPhase;
240214
buildActionMask = 2147483647;
@@ -259,7 +233,6 @@
259233
5E086DC02051C5A7004D8D25 /* Fan of ASCII.playgroundbook */,
260234
5EF2F9AB2054BBF300191409 /* libBookCore.a */,
261235
5E6F7E612368FB6A008CC191 /* libBookAPI.a */,
262-
5E6F7E742368FF15008CC191 /* libUserModule.a */,
263236
5EA2E3BD2056F35A00416A35 /* LiveViewTestApp.app */,
264237
);
265238
name = Products;
@@ -270,7 +243,6 @@
270243
children = (
271244
5E086DCF2051DF0F004D8D25 /* Manifest.plist */,
272245
5E70679B23678D810094BDEF /* Modules */,
273-
5E7067A023678DED0094BDEF /* UserModules */,
274246
5EF2F9792054B64800191409 /* PrivateResources */,
275247
5EF2F9B62054E6F900191409 /* Chapters */,
276248
5EF2F9A42054BB9500191409 /* Supporting Content */,
@@ -363,14 +335,6 @@
363335
path = Sources;
364336
sourceTree = "<group>";
365337
};
366-
5E7067A023678DED0094BDEF /* UserModules */ = {
367-
isa = PBXGroup;
368-
children = (
369-
7177B9B323FA408200744423 /* FanOfAscii.playgroundmodule */,
370-
);
371-
path = UserModules;
372-
sourceTree = "<group>";
373-
};
374338
5EA2E3BE2056F35A00416A35 /* LiveViewTestApp */ = {
375339
isa = PBXGroup;
376340
children = (
@@ -434,26 +398,10 @@
434398
isa = PBXGroup;
435399
children = (
436400
5E70679E23678DC00094BDEF /* Modules */,
437-
5E6F7E582367B51E008CC191 /* UserModules */,
438401
);
439402
name = "Supporting Content";
440403
sourceTree = "<group>";
441404
};
442-
7177B9B323FA408200744423 /* FanOfAscii.playgroundmodule */ = {
443-
isa = PBXGroup;
444-
children = (
445-
7177B9B423FA4EE200744423 /* Sources */,
446-
);
447-
path = FanOfAscii.playgroundmodule;
448-
sourceTree = "<group>";
449-
};
450-
7177B9B423FA4EE200744423 /* Sources */ = {
451-
isa = PBXGroup;
452-
children = (
453-
);
454-
path = Sources;
455-
sourceTree = "<group>";
456-
};
457405
71C6D8DF23F975EA005333B3 /* Frameworks */ = {
458406
isa = PBXGroup;
459407
children = (
@@ -629,7 +577,6 @@
629577
dependencies = (
630578
5EF2F9B52054BDD100191409 /* PBXTargetDependency */,
631579
5E6F7E6F2368FD7C008CC191 /* PBXTargetDependency */,
632-
5E6F7E7F2368FF3D008CC191 /* PBXTargetDependency */,
633580
);
634581
name = FanOfAscii;
635582
productName = PlaygroundBook;
@@ -653,23 +600,6 @@
653600
productReference = 5E6F7E612368FB6A008CC191 /* libBookAPI.a */;
654601
productType = "com.apple.product-type.library.static";
655602
};
656-
5E6F7E732368FF15008CC191 /* UserModule */ = {
657-
isa = PBXNativeTarget;
658-
buildConfigurationList = 5E6F7E782368FF15008CC191 /* Build configuration list for PBXNativeTarget "UserModule" */;
659-
buildPhases = (
660-
5E6F7E702368FF15008CC191 /* Sources */,
661-
5E6F7E712368FF15008CC191 /* Frameworks */,
662-
);
663-
buildRules = (
664-
);
665-
dependencies = (
666-
5E6F7E7C2368FF1D008CC191 /* PBXTargetDependency */,
667-
);
668-
name = UserModule;
669-
productName = UserModule;
670-
productReference = 5E6F7E742368FF15008CC191 /* libUserModule.a */;
671-
productType = "com.apple.product-type.library.static";
672-
};
673603
5EA2E3BC2056F35A00416A35 /* LiveViewTestApp */ = {
674604
isa = PBXNativeTarget;
675605
buildConfigurationList = 5EA2E3CE2056F35B00416A35 /* Build configuration list for PBXNativeTarget "LiveViewTestApp" */;
@@ -723,9 +653,6 @@
723653
5E6F7E602368FB6A008CC191 = {
724654
CreatedOnToolsVersion = 11.1;
725655
};
726-
5E6F7E732368FF15008CC191 = {
727-
CreatedOnToolsVersion = 11.1;
728-
};
729656
5EA2E3BC2056F35A00416A35 = {
730657
CreatedOnToolsVersion = 9.3;
731658
LastSwiftMigration = 1110;
@@ -752,7 +679,6 @@
752679
5E086DBF2051C5A7004D8D25 /* FanOfAscii */,
753680
5EF2F9AA2054BBF300191409 /* BookCore */,
754681
5E6F7E602368FB6A008CC191 /* BookAPI */,
755-
5E6F7E732368FF15008CC191 /* UserModule */,
756682
5EA2E3BC2056F35A00416A35 /* LiveViewTestApp */,
757683
);
758684
};
@@ -819,14 +745,6 @@
819745
);
820746
runOnlyForDeploymentPostprocessing = 0;
821747
};
822-
5E6F7E702368FF15008CC191 /* Sources */ = {
823-
isa = PBXSourcesBuildPhase;
824-
buildActionMask = 2147483647;
825-
files = (
826-
B99F6A0539C60909F28B9D78 /* RawImage+BookAPI.swift in Sources */,
827-
);
828-
runOnlyForDeploymentPostprocessing = 0;
829-
};
830748
5EA2E3B92056F35A00416A35 /* Sources */ = {
831749
isa = PBXSourcesBuildPhase;
832750
buildActionMask = 2147483647;
@@ -879,16 +797,6 @@
879797
target = 5E6F7E602368FB6A008CC191 /* BookAPI */;
880798
targetProxy = 5E6F7E6E2368FD7C008CC191 /* PBXContainerItemProxy */;
881799
};
882-
5E6F7E7C2368FF1D008CC191 /* PBXTargetDependency */ = {
883-
isa = PBXTargetDependency;
884-
target = 5E6F7E602368FB6A008CC191 /* BookAPI */;
885-
targetProxy = 5E6F7E7B2368FF1D008CC191 /* PBXContainerItemProxy */;
886-
};
887-
5E6F7E7F2368FF3D008CC191 /* PBXTargetDependency */ = {
888-
isa = PBXTargetDependency;
889-
target = 5E6F7E732368FF15008CC191 /* UserModule */;
890-
targetProxy = 5E6F7E7E2368FF3D008CC191 /* PBXContainerItemProxy */;
891-
};
892800
5EA2E3D02056F36100416A35 /* PBXTargetDependency */ = {
893801
isa = PBXTargetDependency;
894802
target = 5E086DBF2051C5A7004D8D25 /* FanOfAscii */;
@@ -1083,20 +991,6 @@
1083991
};
1084992
name = Release;
1085993
};
1086-
5E6F7E792368FF15008CC191 /* Debug */ = {
1087-
isa = XCBuildConfiguration;
1088-
baseConfigurationReference = 5E6F7E6D2368FC9A008CC191 /* ModuleOverridingBuildSettings.xcconfig */;
1089-
buildSettings = {
1090-
};
1091-
name = Debug;
1092-
};
1093-
5E6F7E7A2368FF15008CC191 /* Release */ = {
1094-
isa = XCBuildConfiguration;
1095-
baseConfigurationReference = 5E6F7E6D2368FC9A008CC191 /* ModuleOverridingBuildSettings.xcconfig */;
1096-
buildSettings = {
1097-
};
1098-
name = Release;
1099-
};
1100994
5EA2E3CC2056F35B00416A35 /* Debug */ = {
1101995
isa = XCBuildConfiguration;
1102996
buildSettings = {
@@ -1199,15 +1093,6 @@
11991093
defaultConfigurationIsVisible = 0;
12001094
defaultConfigurationName = Release;
12011095
};
1202-
5E6F7E782368FF15008CC191 /* Build configuration list for PBXNativeTarget "UserModule" */ = {
1203-
isa = XCConfigurationList;
1204-
buildConfigurations = (
1205-
5E6F7E792368FF15008CC191 /* Debug */,
1206-
5E6F7E7A2368FF15008CC191 /* Release */,
1207-
);
1208-
defaultConfigurationIsVisible = 0;
1209-
defaultConfigurationName = Release;
1210-
};
12111096
5EA2E3CE2056F35B00416A35 /* Build configuration list for PBXNativeTarget "LiveViewTestApp" */ = {
12121097
isa = XCConfigurationList;
12131098
buildConfigurations = (

FanOfAscii/Chapters/01-FanOfAscii.playgroundchapter/Pages/02-HowImagesComposed.playgroundpage/main.swift

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ PlaygroundPage.current.needsIndefiniteExecution = true
1313

1414
//#-end-hidden-code
1515
/*:
16-
# How Images Composed
16+
# Basics: How Images Composed
1717

1818
## Pixels
1919

20-
Images are made up of **pixels**tiny square blocks with a single, solid color.
20+
Images are made of **pixels**. Each pixel is a tiny square block with a single, solid color.
2121

2222
### 🔬Pixel Discovery
2323

@@ -27,58 +27,56 @@ Images are made up of **pixels** — tiny square blocks with a single, solid col
2727

2828
## Red, Green & Blue
2929

30-
Colors are measured in **color models**. The **RGB Color model** is the one mostly used in digital world.
30+
Colors are measured in **color models**. The **RGB Color model** is close to the way how screens work and therefore the
31+
mostly used color model in digital world.
3132

3233
In **RGB color model**, all colors can be produced by lights in **red, green and blue**, while most images also include
3334
an extra **alpha** channel to describe the opacity of a color.
3435

3536
![RGB Color Model](rgb-model.png)
3637

37-
The RGB model is close to the way how screens work. Lighting units in these three colors can be seen with a close-up
38-
look on many old monitors with low resolution.
39-
40-
![Close-up Look of LCD Screen](lcd-screen-closeup.jpg)
41-
4238
## Filters
4339

44-
**Filtering** is a general technique for image processing. A digital image filter resembles a mathematical function,
45-
which receives pixel colors as a sequence, performing some calculations and returns a new image.
40+
**Filtering** is a general technique for image processing. A **digital image filter** resembles a mathematical function,
41+
which receives a raw image as a sequence of colors, performing a specific calculation and returns a new image.
4642

4743
### 🔨Your First Image Filter
4844

4945
* Experiment:
50-
* You'll build a simple filter which separates red, green or blue component from the source image.
46+
* You'll build a simple filter which separates red, green or blue component out from the source image.
5147
* Try completing following code snippet. Run your code and tap the *R, G and B* button to verify whether it works.
5248
*/
5349

5450
//#-code-completion(everything, hide)
55-
//#-code-completion(literal, show, float, integer)
51+
//#-code-completion(literal, show, float, double, integer)
5652
//#-code-completion(identifier, show, factorRed, factorGreen, factorBlue)
5753
//#-editable-code
5854
func applyRGBFilter(redEnabled: Bool,
5955
greenEnabled: Bool,
6056
blueEnabled: Bool,
6157
rawImage: RawImage) {
58+
// Use these factors to selectively filters out specific color component.
6259
let factorRed, factorGreen, factorBlue: Double
6360
factorRed = (redEnabled ? 1 : 0)
6461
factorGreen = (greenEnabled ? 1 : 0)
6562
factorBlue = (blueEnabled ? 1 : 0)
6663

64+
// For most digital images, color components are arranged in the order of red, green, blue and alpha, pre pixel basis.
65+
// For alpha channel, 1 stands for opaque while 0 stands for transparent.
6766
var filterMatrix: [Double] = [
6867
<#T##Red##Double#>, 0, 0, 0,
6968
0, <#T##Green##Double#>, 0, 0,
7069
0, 0, <#T##Blue##Double#>, 0,
7170
0, 0, 0, <#T##Alpha##Double#>
7271
]
73-
7472
rawImage.multiplyByMatrix(matrix4x4: filterMatrix)
7573
}
7674

7775
//#-end-editable-code
7876
/*:
7977
* Note:
80-
In this code snippet, we transform the image by multiplying it with a transform matrix. If you're not familiar
81-
with linear algebra, the following figure explains how this transform matrix works.
78+
This code snippet transforms an image by multiplying it with a transform matrix. If you're not familiar with linear
79+
algebra, the following figure explains how this transform matrix works.
8280
(图)
8381
*/
8482
//#-hidden-code

0 commit comments

Comments
 (0)