Skip to content

Commit

Permalink
Add blend2d submodule + build docs via gh workflow
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <georgelemon@protonmail.com>
  • Loading branch information
georgelemon committed Nov 20, 2024
1 parent 8c25d84 commit 02535ad
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 11 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ on:
push:
tags:
- '*.*.*'
# branches:
# - main
branches:
- main
env:
mainModule: 'blend2d'
nim-version: 'stable'
nim-src: src/${{ github.event.repository.name }}.nim
nim-src: src/${{ env.mainModule }}.nim
deploy-dir: .gh-pages
jobs:
docs:
Expand All @@ -21,16 +22,16 @@ jobs:
- run: nim doc --index:on --project --path:. --out:${{ env.deploy-dir }} ${{ env.nim-src }}

- name: "Rename to index.html"
run: mv ${{ env.deploy-dir }}/${{ github.event.repository.name }}.html ${{ env.deploy-dir }}/index.html
run: mv ${{ env.deploy-dir }}/${{ env.mainModule }}.html ${{ env.deploy-dir }}/index.html

- name: "Find and replace (index.html)"
run: sed -i 's/${{ github.event.repository.name }}.html/index.html/g' ${{ env.deploy-dir }}/index.html
run: sed -i 's/${{ env.mainModule }}.html/index.html/g' ${{ env.deploy-dir }}/index.html

# - name: "Find and replace (idx)"
# run: sed -i 's/${{ github.event.repository.name }}.html/index.html/g' ${{ env.deploy-dir }}/${{ github.event.repository.name }}.idx

- name: "Find and replace (theindex.html)"
run: sed -i 's/${{ github.event.repository.name }}.html/index.html/g' ${{ env.deploy-dir }}/theindex.html
run: sed -i 's/${{ env.mainModule }}.html/index.html/g' ${{ env.deploy-dir }}/theindex.html

- name: Deploy documents
uses: peaceiris/actions-gh-pages@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/blend2d/bindings/blend2d_source"]
path = src/blend2d/bindings/blend2d_source
url = https://github.com/blend2d/blend2d.git
2 changes: 1 addition & 1 deletion src/blend2d.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# Made by Humans from OpenPeeps
# https://github.com/openpeeps/blend2d-nim
import ./blend2d/[image, geometry, context, font, color]
export image, geometry, context, font, color
export image, geometry, context, font, color
6 changes: 3 additions & 3 deletions src/blend2d/bindings/bl_context.nim
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ proc blContextFillAllExt*(self: ptr BLContextCore; style: pointer): BLResult
proc blContextFillRectI*(self: ptr BLContextCore; rect: ptr BLRectI): BLResult
proc blContextFillRectIRgba32*(self: ptr BLContextCore; rect: ptr BLRectI; rgba32: uint32): BLResult
proc blContextFillRectIRgba64*(self: ptr BLContextCore; rect: ptr BLRectI; rgba64: uint64): BLResult
proc blContextFillRectIExt*(self: ptr BLContextCore; rect: ptr BLRectI; style: ptr BLUnknown): BLResult
proc blContextFillRectIExt*(self: ptr BLContextCore; rect: ptr BLRectI; style: pointer #[ptr BLUnknown]#): BLResult
proc blContextFillRectD*(self: ptr BLContextCore; rect: ptr BLRect): BLResult
proc blContextFillRectDRgba32*(self: ptr BLContextCore; rect: ptr BLRect; rgba32: uint32): BLResult
proc blContextFillRectDRgba64*(self: ptr BLContextCore; rect: ptr BLRect; rgba64: uint64): BLResult
Expand All @@ -275,7 +275,7 @@ proc blContextFillPathDExt*(self: ptr BLContextCore; origin: ptr BLPoint; path:
proc blContextFillGeometry*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer): BLResult
proc blContextFillGeometryRgba32*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; rgba32: uint32): BLResult
proc blContextFillGeometryRgba64*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; rgba64: uint64): BLResult
proc blContextFillGeometryExt*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; style: ptr BLUnknown): BLResult
proc blContextFillGeometryExt*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; style: pointer #[ptr BLUnknown]#): BLResult
proc blContextFillUtf8TextI*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint): BLResult
proc blContextFillUtf8TextIRgba32*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint; rgba32: uint32): BLResult
proc blContextFillUtf8TextIRgba64*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint; rgba64: uint64): BLResult
Expand Down Expand Up @@ -331,7 +331,7 @@ proc blContextStrokePathDExt*(self: ptr BLContextCore; origin: ptr BLPoint; path
proc blContextStrokeGeometry*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer): BLResult
proc blContextStrokeGeometryRgba32*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; rgba32: uint32): BLResult
proc blContextStrokeGeometryRgba64*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; rgba64: uint64): BLResult
proc blContextStrokeGeometryExt*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; style: ptr BLUnknown): BLResult
proc blContextStrokeGeometryExt*(self: ptr BLContextCore; `type`: BLGeometryType; data: pointer; style: pointer #[ptr BLUnknown]#): BLResult
proc blContextStrokeUtf8TextI*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint): BLResult
proc blContextStrokeUtf8TextIRgba32*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint; rgba32: uint32): BLResult
proc blContextStrokeUtf8TextIRgba64*(self: ptr BLContextCore; origin: ptr BLPointI; font: ptr BLFontCore; text: cstring; size: uint; rgba64: uint64): BLResult
Expand Down
1 change: 1 addition & 0 deletions src/blend2d/bindings/bl_style.nim
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type

BLPatternCore* {.bycopy.} = object
d*: BLObjectDetail

BLPatternImpl* {.bycopy.} = object
image*: BLImageCore
## Image used by the pattern.
Expand Down
1 change: 1 addition & 0 deletions src/blend2d/bindings/blend2d_source
Submodule blend2d_source added at d2e936
23 changes: 23 additions & 0 deletions src/blend2d/context.nim
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ proc add*(ctx: Context, r: BLRectI) =
## Add a `BLRectI` to Context
!blContextFillRectI(ctx, r.addr)

proc add*(ctx: Context, r: BLRectI, color: BLRgba) =
## Add a `BLRectI` to Context
!blContextFillRectIExt(ctx, r.addr, color.addr)

proc add*(ctx: Context, circle: Circle) =
## Add a `Circle` pointer to current `Context`
!blContextFillGeometry(ctx, BL_GEOMETRY_TYPE_CIRCLE, circle)
Expand All @@ -171,6 +175,10 @@ proc add*(ctx: Context, c: Circle, color: ColorHex) =
## Add a colored `Circle` pointer to current `Context`
!blContextFillGeometryRgba32(ctx, BL_GEOMETRY_TYPE_CIRCLE, c, color)

proc add*(ctx: Context, c: Circle, color: BLRgba) =
## Add a colored `Circle` pointer to current `Context`
!blContextFillGeometryExt(ctx, BL_GEOMETRY_TYPE_CIRCLE, c, color.addr)

proc add*(ctx: Context, rr: RoundRect, color: ColorHex) =
## Add a colored `BLRoundRect` to current `Context`
!blContextFillGeometryRgba32(ctx, BL_GEOMETRY_TYPE_ROUND_RECT, rr, color)
Expand Down Expand Up @@ -231,8 +239,23 @@ proc mask*(ctx: Context, origin: PointI,
ctx

proc endContext*(ctx: Context) =
## Ends the `ctx` Context
!blContextEnd(ctx)

#
# Context - Stroke
#

proc stroke*(ctx: Context, c: BLCircle, width: float, color: BLRgba = White): Context {.discardable.} =
## Add a stroke to `BLCircle` using `ctx` Context
!blContextSetStrokeWidth(ctx, width)
!blContextStrokeGeometryExt(ctx, BLGeometryType.BlGeometryTypeCircle, c.addr, color.addr)
result = ctx

template stroke*(c: BLCircle, width: float, color: BLRgba = White) =
## Add a stroke to `BLCircle` while in a `ctx` Context
this.stroke(c, width, color)

#
# Macro Utils
#
Expand Down
2 changes: 1 addition & 1 deletion src/blend2d/geometry.nim
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ proc size*(w, h: int): BLSizeI =
BLSizeI(w: w.int32, h: h.int32)

proc circle*(cx, cy, r: float): BLCircle =
result = BLCircle(cx: cx, cy: cy, r: r)
result = BLCircle(cx: cx, cy: cy, r: r)

0 comments on commit 02535ad

Please sign in to comment.