Skip to content

Commit cfb04f6

Browse files
authored
Merge pull request #32 from temoki/develop
Fix bug: penSize state are shared in tortoises.
2 parents 106ddea + df27c91 commit cfb04f6

File tree

8 files changed

+8
-14
lines changed

8 files changed

+8
-14
lines changed

PlaygroundBook/template/Contents/Manifest.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<key>ContentIdentifier</key>
1212
<string>com.temoki.playgroundbook.TortoiseGraphics</string>
1313
<key>ContentVersion</key>
14-
<string>0.13.0</string>
14+
<string>0.13.1</string>
1515
<key>ImageReference</key>
1616
<string>icon.png</string>
1717
<key>DeploymentTarget</key>

Sources/CommandColor.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,7 @@ class CommandColor: Command {
3232
}
3333

3434
func exexute(in state: State, with context: CGContext) -> State {
35-
let newState = test(in: state)
36-
switch type {
37-
case .pen:
38-
context.setStrokeColor(newState.penColor)
39-
case .fill:
40-
context.setFillColor(newState.fillColor)
41-
}
42-
return newState
35+
return test(in: state)
4336
}
4437

4538
}

Sources/CommandForward.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CommandForward: Command {
2323
if newState.isPenDown {
2424
context.saveGState()
2525
context.setStrokeColor(newState.penColor)
26+
context.setLineWidth(newState.penSize)
2627
context.move(to: state.position)
2728
context.addLine(to: newState.position)
2829
context.strokePath()

Sources/CommandPenSize.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ class CommandPenSize: Command {
1515
}
1616

1717
func exexute(in state: State, with context: CGContext) -> State {
18-
let newState = test(in: state)
19-
context.setLineWidth(newState.penSize)
20-
return newState
18+
return test(in: state)
2119
}
2220

2321
}

Sources/CommandSetPosition.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class CommandSetPosition: Command {
1919
if newState.isPenDown {
2020
context.saveGState()
2121
context.setStrokeColor(newState.penColor)
22+
context.setLineWidth(newState.penSize)
2223
context.move(to: state.position)
2324
context.addLine(to: newState.position)
2425
context.strokePath()

Sources/Tortoise.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class Tortoise {
4949

5050
func drawTortoise(_ cgContext: CGContext, state: State) {
5151
cgContext.saveGState()
52+
cgContext.setLineWidth(state.penSize)
5253
cgContext.setStrokeColor(state.penColor)
5354
cgContext.setFillColor(state.fillColor)
5455
let transform = CGAffineTransform(translationX: state.position.x, y: state.position.y)

TortoiseGraphics.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'TortoiseGraphics'
3-
s.version = '0.13.0'
3+
s.version = '0.13.1'
44
s.summary = 'A turtle graphics (a key feature of the Logo) engine written in Swift.'
55
s.description = 'A turtle graphics (a key feature of the Logo) engine written in Swift. The commands were implemented with reference to the turtle in Python 3 standard libraries.'
66
s.homepage = 'https://github.com/temoki/TortoiseGraphics'

TortoiseGraphics.xcodeproj/TortoiseGraphics_Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.13.0</string>
18+
<string>0.13.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)