Skip to content

Commit

Permalink
Merge pull request #8 from pharo-contributions/development
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
jecisc authored Dec 19, 2018
2 parents f6d4665 + a204cb3 commit 3ecd01a
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 44 deletions.
11 changes: 1 addition & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ sudo: false

os:
- linux
- osx

smalltalk:
- Pharo-7.0
- Pharo64-7.0
- Pharo-6.1
- Pharo64-6.1

matrix:
fast_finish: true
allow_failures:
- smalltalk: Pharo-7.0
- smalltalk: Pharo64-7.0
- Pharo64-6.1
17 changes: 17 additions & 0 deletions src/Artefact-Core/PDFDocument.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ PDFDocument class >> FrameworkManual [
^ self comment
]

{ #category : #'instance creation' }
PDFDocument class >> element: anElement [
^ self elements: { anElement }
]

{ #category : #'instance creation' }
PDFDocument class >> elements: aCollection [
^ self new
addAll: aCollection;
yourself
]

{ #category : #action }
PDFDocument >> add: aPage [
"add a new page in the PDF document"
Expand All @@ -327,6 +339,11 @@ PDFDocument >> add: aPage [



]

{ #category : #action }
PDFDocument >> addAll: aCollection [
aCollection do: [ :each | self add: each ]
]

{ #category : #configuration }
Expand Down
7 changes: 6 additions & 1 deletion src/Artefact-Core/PDFPage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ Class {
#category : #'Artefact-Core-Base'
}

{ #category : #accessing }
{ #category : #'instance creation' }
PDFPage class >> element: anElement [
^ self elements: {anElement}
]

{ #category : #'instance creation' }
PDFPage class >> elements: aCollectionOfElements [
^ self new
elements: aCollectionOfElements;
Expand Down
100 changes: 67 additions & 33 deletions src/Artefact-Examples/PDFClockElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,98 @@ Class {

{ #category : #steps }
PDFClockElement class >> clockTutorialStep1 [
"PDFClockElement clockTutorialStep1"
"I will generate a PDF with the clock step example"

| doc |
doc := PDFDocument new.
doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
doc exportTo: 'clockTutorialStep1.pdf' asFileReference writeStream
<script>
(PDFDocument element: (PDFPage element: ((self from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current))) exportTo: (self streamNamed: 'clockTutorialStep1.pdf')
]

{ #category : #steps }
PDFClockElement class >> clockTutorialStep2 [
"PDFClockElement clockTutorialStep2"
"I will generate a PDF with the clock step example"

<script>
| doc |
doc := PDFDocument new.
doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
doc styleSheet > #clock drawColor: (PDFColor r:180 g: 24 b:24); fillColor: (PDFColor r:230 g: 230 b:10).
doc exportTo: 'clockTutorialStep2.pdf' asFileReference writeStream
doc := PDFDocument element: (PDFPage element: ((self from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
(doc styleSheet > #clock)
drawColor: (PDFColor r: 180 g: 24 b: 24);
fillColor: (PDFColor r: 230 g: 230 b: 10).
doc exportTo: (self streamNamed: 'clockTutorialStep2.pdf')
]

{ #category : #steps }
PDFClockElement class >> clockTutorialStep3 [
"PDFClockElement clockTutorialStep3"
"I will generate a PDF with the clock step example"

<script>
| doc |
doc := PDFDocument new.
doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
doc styleSheet > #clock drawColor: (PDFColor r:180 g: 24 b:24); fillColor: (PDFColor r:230 g: 230 b:10).
doc styleSheet > #clock > #arrow drawColor: (PDFColor r:0 g: 45 b:200).
doc exportTo: 'clockTutorialStep3.pdf' asFileReference writeStream
doc := PDFDocument element: (PDFPage element: ((self from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
(doc styleSheet > #clock)
drawColor: (PDFColor r: 180 g: 24 b: 24);
fillColor: (PDFColor r: 230 g: 230 b: 10).
doc styleSheet > #clock > #arrow drawColor: (PDFColor r: 0 g: 45 b: 200).
doc exportTo: (self streamNamed: 'clockTutorialStep3.pdf')
]

{ #category : #steps }
PDFClockElement class >> clockTutorialStep4 [
"PDFClockElement clockTutorialStep4"
"I will generate a PDF with the clock step example"

<script>
| doc |
doc := PDFDocument new.
doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
doc styleSheet > #clock drawColor: (PDFColor r:180 g: 24 b:24); fillColor: (PDFColor r:230 g: 230 b:10).
doc styleSheet > #clock > #hourHand drawColor: (PDFColor r:0 g: 45 b:200).
doc styleSheet > #clock > #minuteHand drawColor: (PDFColor r:0 g: 200 b:45).
doc exportTo: 'clockTutorialStep4.pdf' asFileReference writeStream
doc := PDFDocument element: (PDFPage element: ((self from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)).
(doc styleSheet > #clock)
drawColor: (PDFColor r: 180 g: 24 b: 24);
fillColor: (PDFColor r: 230 g: 230 b: 10).
doc styleSheet > #clock > #hourHand drawColor: (PDFColor r: 0 g: 45 b: 200).
doc styleSheet > #clock > #minuteHand drawColor: (PDFColor r: 0 g: 200 b: 45).
doc exportTo: (self streamNamed: 'clockTutorialStep4.pdf')
]

{ #category : #steps }
PDFClockElement class >> clockTutorialStep5 [
"PDFClockElement clockTutorialStep5"
"I will generate a PDF with the clock step example"

<script>
| doc |
doc := PDFDocument new.
doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current);
add: ((PDFClockElement from: 12 cm @ 2 cm to: 20 cm @ 10 cm) time: Time current; style: #apocalypseClock)).
doc styleSheet > #clock drawColor: (PDFColor r:180 g: 24 b:24); fillColor: (PDFColor r:230 g: 230 b:10).
doc styleSheet > #clock > #hourHand drawColor: (PDFColor r:0 g: 45 b:200).
doc styleSheet > #clock > #minuteHand drawColor: (PDFColor r:0 g: 200 b:45).
doc styleSheet > #apocalypseClock fillColor: (PDFColor r:244 g: 221 b:25); thickness: 2mm; roundCap: true.
doc styleSheet > #apocalypseClock > #minuteHand drawColor: (PDFColor r:240 g: 6 b: 7); thickness: 1 mm.
doc exportTo: 'clockTutorialStep5.pdf' asFileReference writeStream
doc := PDFDocument
element:
(PDFPage
elements:
{((self from: 2 cm @ 2 cm to: 10 cm @ 10 cm)
time: Time current;
yourself) . ((self from: 12 cm @ 2 cm to: 20 cm @ 10 cm)
time: Time current;
style: #apocalypseClock;
yourself)}).
(doc styleSheet > #clock)
drawColor: (PDFColor r: 180 g: 24 b: 24);
fillColor: (PDFColor r: 230 g: 230 b: 10).
doc styleSheet > #clock > #hourHand drawColor: (PDFColor r: 0 g: 45 b: 200).
doc styleSheet > #clock > #minuteHand drawColor: (PDFColor r: 0 g: 200 b: 45).
(doc styleSheet > #apocalypseClock)
fillColor: (PDFColor r: 244 g: 221 b: 25);
thickness: 2 mm;
roundCap: true.
(doc styleSheet > #apocalypseClock > #minuteHand)
drawColor: (PDFColor r: 240 g: 6 b: 7);
thickness: 1 mm.
doc exportTo: (self streamNamed: 'clockTutorialStep5.pdf')
]

{ #category : #tool }
PDFClockElement class >> streamNamed: aName [
| file |
file := aName asFileReference.
file ensureDelete.
self flag: #todo. "The next expression is a hack to correct a Pharo 6/7 compatibility.
We need a binary write stream to print on but the way to get one changed between Pharo 6 and 7. To improve the code we could add a Pharo^ compatibility package that would add #binaryWriteStream to Pharo 6, but I have not time for now, I just want to make demos work.
"
^ SystemVersion current major < 7
ifTrue: [ file writeStream
binary;
yourself ]
ifFalse: [ file binaryWriteStream ]
]

{ #category : #style }
Expand Down

0 comments on commit 3ecd01a

Please sign in to comment.