readme
This commit is contained in:
parent
a5cd9cd35e
commit
c95f53aac2
26
README.md
26
README.md
|
@ -112,8 +112,10 @@ Here are some examples of using Pixie for realtime rendering with some popular w
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
`git clone https://github.com/treeform/pixie` to run examples.
|
||||||
|
|
||||||
### Text
|
### Text
|
||||||
[examples/text.nim](examples/text.nim)
|
nim c -r [examples/text.nim](examples/text.nim)
|
||||||
```nim
|
```nim
|
||||||
var font = readFont("examples/data/Roboto-Regular_1.ttf")
|
var font = readFont("examples/data/Roboto-Regular_1.ttf")
|
||||||
font.size = 20
|
font.size = 20
|
||||||
|
@ -125,7 +127,7 @@ image.fillText(font.typeset(text, vec2(180, 180)), translate(vec2(10, 10)))
|
||||||
![example output](examples/text.png)
|
![example output](examples/text.png)
|
||||||
|
|
||||||
### Text spans
|
### Text spans
|
||||||
[examples/text_spans.nim](examples/text_spans.nim)
|
nim c -r [examples/text_spans.nim](examples/text_spans.nim)
|
||||||
```nim
|
```nim
|
||||||
let typeface = readTypeface("examples/data/Ubuntu-Regular_1.ttf")
|
let typeface = readTypeface("examples/data/Ubuntu-Regular_1.ttf")
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ image.fillText(typeset(spans, vec2(180, 180)), translate(vec2(10, 10)))
|
||||||
![example output](examples/text_spans.png)
|
![example output](examples/text_spans.png)
|
||||||
|
|
||||||
### Square
|
### Square
|
||||||
[examples/square.nim](examples/square.nim)
|
nim c -r [examples/square.nim](examples/square.nim)
|
||||||
```nim
|
```nim
|
||||||
let ctx = newContext(image)
|
let ctx = newContext(image)
|
||||||
ctx.fillStyle = rgba(255, 0, 0, 255)
|
ctx.fillStyle = rgba(255, 0, 0, 255)
|
||||||
|
@ -162,7 +164,7 @@ ctx.fillRect(rect(pos, wh))
|
||||||
![example output](examples/square.png)
|
![example output](examples/square.png)
|
||||||
|
|
||||||
### Line
|
### Line
|
||||||
[examples/line.nim](examples/line.nim)
|
nim c -r [examples/line.nim](examples/line.nim)
|
||||||
```nim
|
```nim
|
||||||
let ctx = newContext(image)
|
let ctx = newContext(image)
|
||||||
ctx.strokeStyle = "#FF5C00"
|
ctx.strokeStyle = "#FF5C00"
|
||||||
|
@ -177,7 +179,7 @@ ctx.strokeSegment(segment(start, stop))
|
||||||
![example output](examples/line.png)
|
![example output](examples/line.png)
|
||||||
|
|
||||||
### Rounded rectangle
|
### Rounded rectangle
|
||||||
[examples/rounded_rectangle.nim](examples/rounded_rectangle.nim)
|
nim c -r [examples/rounded_rectangle.nim](examples/rounded_rectangle.nim)
|
||||||
```nim
|
```nim
|
||||||
let ctx = newContext(image)
|
let ctx = newContext(image)
|
||||||
ctx.fillStyle = rgba(0, 255, 0, 255)
|
ctx.fillStyle = rgba(0, 255, 0, 255)
|
||||||
|
@ -192,7 +194,7 @@ ctx.fillRoundedRect(rect(pos, wh), r)
|
||||||
![example output](examples/rounded_rectangle.png)
|
![example output](examples/rounded_rectangle.png)
|
||||||
|
|
||||||
### Heart
|
### Heart
|
||||||
[examples/heart.nim](examples/heart.nim)
|
nim c -r [examples/heart.nim](examples/heart.nim)
|
||||||
```nim
|
```nim
|
||||||
image.fillPath(
|
image.fillPath(
|
||||||
"""
|
"""
|
||||||
|
@ -209,7 +211,7 @@ image.fillPath(
|
||||||
![example output](examples/heart.png)
|
![example output](examples/heart.png)
|
||||||
|
|
||||||
### Masking
|
### Masking
|
||||||
[examples/masking.nim](examples/masking.nim)
|
nim c -r [examples/masking.nim](examples/masking.nim)
|
||||||
```nim
|
```nim
|
||||||
let ctx = newContext(lines)
|
let ctx = newContext(lines)
|
||||||
ctx.strokeStyle = "#F8D1DD"
|
ctx.strokeStyle = "#F8D1DD"
|
||||||
|
@ -234,7 +236,7 @@ image.draw(lines)
|
||||||
![example output](examples/masking.png)
|
![example output](examples/masking.png)
|
||||||
|
|
||||||
### Gradient
|
### Gradient
|
||||||
[examples/gradient.nim](examples/gradient.nim)
|
nim c -r [examples/gradient.nim](examples/gradient.nim)
|
||||||
```nim
|
```nim
|
||||||
let paint = newPaint(pkGradientRadial)
|
let paint = newPaint(pkGradientRadial)
|
||||||
paint.gradientHandlePositions = @[
|
paint.gradientHandlePositions = @[
|
||||||
|
@ -262,7 +264,7 @@ image.fillPath(
|
||||||
![example output](examples/gradient.png)
|
![example output](examples/gradient.png)
|
||||||
|
|
||||||
### Image tiled
|
### Image tiled
|
||||||
[examples/image_tiled.nim](examples/image_tiled.nim)
|
nim c -r [examples/image_tiled.nim](examples/image_tiled.nim)
|
||||||
```nim
|
```nim
|
||||||
let path = newPath()
|
let path = newPath()
|
||||||
path.polygon(
|
path.polygon(
|
||||||
|
@ -280,7 +282,7 @@ image.fillPath(path, paint)
|
||||||
![example output](examples/image_tiled.png)
|
![example output](examples/image_tiled.png)
|
||||||
|
|
||||||
### Shadow
|
### Shadow
|
||||||
[examples/shadow.nim](examples/shadow.nim)
|
nim c -r [examples/shadow.nim](examples/shadow.nim)
|
||||||
```nim
|
```nim
|
||||||
let path = newPath()
|
let path = newPath()
|
||||||
path.polygon(vec2(100, 100), 70, sides = 8)
|
path.polygon(vec2(100, 100), 70, sides = 8)
|
||||||
|
@ -301,7 +303,7 @@ image.draw(polygonImage)
|
||||||
![example output](examples/shadow.png)
|
![example output](examples/shadow.png)
|
||||||
|
|
||||||
### Blur
|
### Blur
|
||||||
[examples/blur.nim](examples/blur.nim)
|
nim c -r [examples/blur.nim](examples/blur.nim)
|
||||||
```nim
|
```nim
|
||||||
let path = newPath()
|
let path = newPath()
|
||||||
path.polygon(vec2(100, 100), 70, sides = 6)
|
path.polygon(vec2(100, 100), 70, sides = 6)
|
||||||
|
@ -318,7 +320,7 @@ image.draw(blur)
|
||||||
![example output](examples/blur.png)
|
![example output](examples/blur.png)
|
||||||
|
|
||||||
### Tiger
|
### Tiger
|
||||||
[examples/tiger.nim](examples/tiger.nim)
|
nim c -r [examples/tiger.nim](examples/tiger.nim)
|
||||||
```nim
|
```nim
|
||||||
let tiger = readImage("examples/data/tiger.svg")
|
let tiger = readImage("examples/data/tiger.svg")
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import algorithm, os, osproc, sequtils, strutils
|
import os, osproc, strutils
|
||||||
|
|
||||||
proc cutBetween(str, a, b: string): string =
|
proc cutBetween(str, a, b: string): string =
|
||||||
let
|
let
|
||||||
|
@ -32,7 +32,7 @@ for path in exampleFiles:
|
||||||
if innerCode != "":
|
if innerCode != "":
|
||||||
let path = path.replace("\\", "/")
|
let path = path.replace("\\", "/")
|
||||||
md.add "### " & path.splitFile().name.replace("_", " ").capitalizeAscii()
|
md.add "### " & path.splitFile().name.replace("_", " ").capitalizeAscii()
|
||||||
md.add "[" & path & "](" & path & ")"
|
md.add "nim c -r [" & path & "](" & path & ")"
|
||||||
md.add "```nim"
|
md.add "```nim"
|
||||||
md.add innerCode.strip()
|
md.add innerCode.strip()
|
||||||
md.add "```"
|
md.add "```"
|
||||||
|
@ -46,6 +46,7 @@ let at = readme.find("## Examples")
|
||||||
if at != -1:
|
if at != -1:
|
||||||
readme = readme[0 .. at]
|
readme = readme[0 .. at]
|
||||||
readme.add("# Examples\n\n")
|
readme.add("# Examples\n\n")
|
||||||
|
readme.add("`git clone https://github.com/treeform/pixie` to run examples.\n\n")
|
||||||
readme.add(md.join("\n"))
|
readme.add(md.join("\n"))
|
||||||
|
|
||||||
writeFile("README.md", readme)
|
writeFile("README.md", readme)
|
||||||
|
|
Loading…
Reference in a new issue