Add line example.
This commit is contained in:
parent
8241b23de7
commit
c3cfc456f4
5 changed files with 36 additions and 2 deletions
19
README.md
19
README.md
|
@ -33,6 +33,21 @@ image.fillPath(p, rgba(255, 0, 0, 255))
|
||||||
```
|
```
|
||||||

|

|
||||||
|
|
||||||
|
### Line
|
||||||
|
[examples/line.nim](examples/line.nim)
|
||||||
|
```nim
|
||||||
|
var p: Path
|
||||||
|
p.moveTo(25, 25)
|
||||||
|
p.lineTo(175, 175)
|
||||||
|
|
||||||
|
image.strokePath(
|
||||||
|
p,
|
||||||
|
parseHtmlColor("#FF5C00").rgba,
|
||||||
|
strokeWidth = 10,
|
||||||
|
)
|
||||||
|
```
|
||||||
|

|
||||||
|
|
||||||
### Rounded rectangle
|
### Rounded rectangle
|
||||||
[examples/rounded_rectangle.nim](examples/rounded_rectangle.nim)
|
[examples/rounded_rectangle.nim](examples/rounded_rectangle.nim)
|
||||||
```nim
|
```nim
|
||||||
|
@ -71,7 +86,7 @@ image.fillPath(
|
||||||
[examples/shadow.nim](examples/shadow.nim)
|
[examples/shadow.nim](examples/shadow.nim)
|
||||||
```nim
|
```nim
|
||||||
var p: Path
|
var p: Path
|
||||||
p.polygon(100, 100, 70, sides=8)
|
p.polygon(100, 100, 70, sides = 8)
|
||||||
p.closePath()
|
p.closePath()
|
||||||
|
|
||||||
var polyImage = newImage(200, 200)
|
var polyImage = newImage(200, 200)
|
||||||
|
@ -91,7 +106,7 @@ image.draw(polyImage)
|
||||||
[examples/blur.nim](examples/blur.nim)
|
[examples/blur.nim](examples/blur.nim)
|
||||||
```nim
|
```nim
|
||||||
var p: Path
|
var p: Path
|
||||||
p.polygon(100, 100, 70, sides=6)
|
p.polygon(100, 100, 70, sides = 6)
|
||||||
p.closePath()
|
p.closePath()
|
||||||
|
|
||||||
let mask = newMask(200, 200)
|
let mask = newMask(200, 200)
|
||||||
|
|
18
examples/line.nim
Normal file
18
examples/line.nim
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import chroma, pixie, vmath
|
||||||
|
|
||||||
|
let
|
||||||
|
image = newImage(200, 200)
|
||||||
|
|
||||||
|
image.fill(rgba(255, 255, 255, 255))
|
||||||
|
|
||||||
|
var p: Path
|
||||||
|
p.moveTo(25, 25)
|
||||||
|
p.lineTo(175, 175)
|
||||||
|
|
||||||
|
image.strokePath(
|
||||||
|
p,
|
||||||
|
parseHtmlColor("#FF5C00").rgba,
|
||||||
|
strokeWidth = 10,
|
||||||
|
)
|
||||||
|
|
||||||
|
image.writeFile("examples/line.png")
|
BIN
examples/line.png
Normal file
BIN
examples/line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
@ -12,6 +12,7 @@ var md: seq[string]
|
||||||
|
|
||||||
var exampleFiles = [
|
var exampleFiles = [
|
||||||
"examples/square.nim",
|
"examples/square.nim",
|
||||||
|
"examples/line.nim",
|
||||||
"examples/rounded_rectangle.nim",
|
"examples/rounded_rectangle.nim",
|
||||||
"examples/heart.nim",
|
"examples/heart.nim",
|
||||||
"examples/shadow.nim",
|
"examples/shadow.nim",
|
||||||
|
|
Loading…
Reference in a new issue