Skip to content

Commit

Permalink
ch09: WIP, all examples in place
Browse files Browse the repository at this point in the history
  • Loading branch information
e8johan committed Nov 12, 2021
1 parent c99fb99 commit 149a1dd
Show file tree
Hide file tree
Showing 5 changed files with 393 additions and 9 deletions.
8 changes: 7 additions & 1 deletion docs/ch09-shapes/gradients.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@

discuss how gradients and fills work

<<< @/docs/ch09-shapes/src/shapes/gradients.qml#global
<<< @/docs/ch09-shapes/src/shapes/fillmode.qml#oddeven
<<< @/docs/ch09-shapes/src/shapes/fillmode.qml#winding

<<< @/docs/ch09-shapes/src/shapes/gradients.qml#solid
<<< @/docs/ch09-shapes/src/shapes/gradients.qml#linear
<<< @/docs/ch09-shapes/src/shapes/gradients.qml#conical
<<< @/docs/ch09-shapes/src/shapes/gradients.qml#radial
24 changes: 23 additions & 1 deletion docs/ch09-shapes/paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@ discuss the various path elements available

<<< @/docs/ch09-shapes/src/shapes/basic.qml#global


PathMove, PathLine

<<< @/docs/ch09-shapes/src/shapes/paths.qml#line


PathPolyline, PathMultiline

<<< @/docs/ch09-shapes/src/shapes/paths.qml#polyline


PathArc, PathAngleArc

<<< @/docs/ch09-shapes/src/shapes/paths.qml#arc

PathQuad

<<< @/docs/ch09-shapes/src/shapes/paths.qml#quad
<<< @/docs/ch09-shapes/src/shapes/paths.qml#cube

PathCube

<<< @/docs/ch09-shapes/src/shapes/paths.qml#cubic

PathCurve

<<< @/docs/ch09-shapes/src/shapes/paths.qml#curve

PathSvg
105 changes: 105 additions & 0 deletions docs/ch09-shapes/src/shapes/fillmode.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
Copyright (c) 2021-2021, Juergen Bocklage Ryannel and Johan Thelin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// #region global
import QtQuick
import QtQuick.Shapes

Rectangle {
id: root
width: 400
height: 200

// #region oddeven
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"
fillColor: "orange"

fillRule: ShapePath.OddEvenFill

PathPolyline {
path: [
Qt.point(100, 20),
Qt.point(150, 180),
Qt.point( 20, 75),
Qt.point(180, 75),
Qt.point( 50, 180),
Qt.point(100, 20),
]
}
}
}
// #endregion oddeven

// #region winding
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"
fillColor: "orange"

fillRule: ShapePath.WindingFill

PathPolyline {
path: [
Qt.point(300, 20),
Qt.point(350, 180),
Qt.point(220, 75),
Qt.point(380, 75),
Qt.point(250, 180),
Qt.point(300, 20),
]
}
}
}
// #endregion winding

Text {
x: 0
y: 180
width: 200

text: "OddEvenFill"
horizontalAlignment: Text.AlignHCenter
}
Text {
x: 200
y: 180
width: 200

text: "WindingFill"
horizontalAlignment: Text.AlignHCenter
}


}
// #endregion global
200 changes: 200 additions & 0 deletions docs/ch09-shapes/src/shapes/gradients.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/*
Copyright (c) 2021-2021, Juergen Bocklage Ryannel and Johan Thelin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// #region global
import QtQuick
import QtQuick.Shapes

Rectangle {
id: root
width: 400
height: 400

// #region solid
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"

fillColor: "lightgreen"

startX: 20; startY: 140

PathLine {
x: 180
y: 140
}
PathArc {
x: 20
y: 140
radiusX: 80
radiusY: 80
direction: PathArc.Counterclockwise
useLargeArc: true
}
}
}
// #endregion solid

// #region conical
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"

fillGradient: ConicalGradient {
centerX: 300; centerY: 100
angle: 360

GradientStop { position: 0.0; color: "lightgreen" }
GradientStop { position: 0.7; color: "yellow" }
GradientStop { position: 1.0; color: "darkgreen" }
}

startX: 220; startY: 140

PathLine {
x: 380
y: 140
}
PathArc {
x: 220
y: 140
radiusX: 80
radiusY: 80
direction: PathArc.Counterclockwise
useLargeArc: true
}
}
}
// #endregion conical

// #region linear
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"

fillGradient: LinearGradient {
x1: 50; y1: 300
x2: 150; y2: 280

GradientStop { position: 0.0; color: "lightgreen" }
GradientStop { position: 0.7; color: "yellow" }
GradientStop { position: 1.0; color: "darkgreen" }
}

startX: 20; startY: 340

PathLine {
x: 180
y: 340
}
PathArc {
x: 20
y: 340
radiusX: 80
radiusY: 80
direction: PathArc.Counterclockwise
useLargeArc: true
}
}
}
// #endregion linear

// #region radial
Shape {
ShapePath {
strokeWidth: 3
strokeColor: "darkgray"

fillGradient: RadialGradient {
centerX: 300; centerY: 250; centerRadius: 120
focalX: 300; focalY: 220; focalRadius: 10

GradientStop { position: 0.0; color: "lightgreen" }
GradientStop { position: 0.7; color: "yellow" }
GradientStop { position: 1.0; color: "darkgreen" }
}

startX: 220; startY: 340

PathLine {
x: 380
y: 340
}
PathArc {
x: 220
y: 340
radiusX: 80
radiusY: 80
direction: PathArc.Counterclockwise
useLargeArc: true
}
}
}
// #endregion radial

Text {
x: 0
y: 150
width: 200

text: "Solid Colour"
horizontalAlignment: Text.AlignHCenter
}
Text {
x: 200
y: 150
width: 200

text: "ConicalGradient"
horizontalAlignment: Text.AlignHCenter
}
Text {
x: 0
y: 350
width: 200

text: "LinearGradient"
horizontalAlignment: Text.AlignHCenter
}
Text {
x: 200
y: 350
width: 200

text: "RadialGradient"
horizontalAlignment: Text.AlignHCenter
}


}
// #endregion global
Loading

0 comments on commit 149a1dd

Please sign in to comment.