Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #37 from Ethosa/nightly
Browse files Browse the repository at this point in the history
Nightly v0.4.1
  • Loading branch information
Ethosa authored Nov 3, 2021
2 parents 3a47afa + 2f0e198 commit 4ef5a91
Show file tree
Hide file tree
Showing 56 changed files with 481 additions and 333 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/icon.svg" width="240">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/icon.svg" width="240">

The Nim GUI/2D framework based on OpenGL and SDL2.

Expand All @@ -13,16 +13,16 @@ The Nim GUI/2D framework based on OpenGL and SDL2.
[![channel icon](https://patrolavia.github.io/telegram-badge/follow.png)](https://t.me/nim1love)
[![channel icon](https://patrolavia.github.io/telegram-badge/chat.png)](https://t.me/nodesnim)

<h4>Stable version - 0.4.0</h4>
<h4>Stable version - 0.4.1</h4>
</div>

## Install
1. Install Nodesnim
- Stable:
- [Stable](https://github.com/Ethosa/nodesnim/tree/master):
```bash
nimble install nodesnim
nimble install nodesnim@#master
```
- Nightly:
- [Nightly](https://github.com/Ethosa/nodesnim/tree/nightly):
```bash
nimble install nodesnim@#nightly
```
Expand Down Expand Up @@ -103,25 +103,28 @@ Also use [`niminst`](https://github.com/nim-lang/niminst) tool for generate an i
## Screenshots
<div align="center">
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/hello_world">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/1.png" width="380" height="220" alt="Hello world example">
<img src="https://user-images.githubusercontent.com/49402667/138453889-ea538f86-2fc4-4947-843f-ca100561b05d.png" width="380" height="220" alt="Hello world example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/calculator">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/2.png" width="380" height="220" alt="Calculator example">
<img src="https://user-images.githubusercontent.com/49402667/138453360-6b701b6a-8695-4ace-bf9f-25d5ae8c68c2.png" width="380" height="220" alt="Calculator example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/snake">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/3.png" width="380" height="220" alt="Snake game example">
<img src="https://user-images.githubusercontent.com/49402667/138456143-292a5b73-7a52-4d29-9769-1c8101db9f85.png" width="380" height="220" alt="Snake game example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/screensaver">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/4.png" width="380" height="220" alt="Screensaver example">
<img src="https://user-images.githubusercontent.com/49402667/138455275-3df817ae-275d-4164-afc1-92fbdbbb4a6c.png" width="380" height="220" alt="Screensaver example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/novel">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/5.png" width="380" height="220" alt="Novel game example">
<img src="https://user-images.githubusercontent.com/49402667/138454518-376b40ba-44d0-458a-9b2b-48a5ea53ff64.png" width="380" height="220" alt="Novel game example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/roguelike">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/6.png" width="380" height="220" alt="Roguelike game example">
<img src="https://user-images.githubusercontent.com/49402667/138454722-e2b2766d-29cd-412a-92d2-29393d442775.png" width="380" height="220" alt="Roguelike game example">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/sample_messenger">
<img src="https://github.com/Ethosa/nodesnim/blob/nightly/screenshots/7.png" width="240" height="480" alt="sample messenger">
<img src="https://user-images.githubusercontent.com/49402667/138455176-d38ea0b3-274d-41c6-b877-2a9be39a7b90.png" width="240" height="480" alt="sample messenger">
</a>
<a href="https://github.com/Ethosa/nodesnim/tree/nightly/examples/calculator">
<img src="https://user-images.githubusercontent.com/49402667/138453719-0b4d50a9-b4a3-40c5-b017-1e0e0dd4892b.png" width="360" height="480" alt="Material Calculator example">
</a>
</div>

Expand Down
4 changes: 0 additions & 4 deletions engine/README.md

This file was deleted.

Binary file removed engine/assets/node.png
Binary file not shown.
20 changes: 0 additions & 20 deletions engine/main.nim

This file was deleted.

1 change: 0 additions & 1 deletion engine/nim.cfg

This file was deleted.

23 changes: 0 additions & 23 deletions engine/scenes/editor.nim

This file was deleted.

5 changes: 0 additions & 5 deletions engine/scenes/projects.nim

This file was deleted.

35 changes: 0 additions & 35 deletions engine/scenes/projects/main.nim

This file was deleted.

32 changes: 0 additions & 32 deletions engine/scenes/projects/project_template.nim

This file was deleted.

36 changes: 0 additions & 36 deletions engine/scenes/projects/projects_files.nim

This file was deleted.

2 changes: 1 addition & 1 deletion examples/roguelike/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import
random

Window("Roguelike", 480, 240)
env.setBackgroundColor(Color("#e0f8cf"))
env.background_color = "#e0f8cf"

var
tileset = TileSet("assets/colored_tilemap.png", Vector2(16, 16), GL_RGBA)
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion nodesnim.nimble
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Package]
name = "nodesnim"
author = "Ethosa"
version = "0.4.0"
version = "0.4.1"
description = "The Nim GUI/2D framework based on OpenGL and SDL2."
license = "MIT"
srcDir = "src"
Expand Down
Binary file removed screenshots/1.png
Binary file not shown.
Binary file removed screenshots/2.png
Binary file not shown.
Binary file removed screenshots/3.png
Binary file not shown.
Binary file removed screenshots/4.png
Binary file not shown.
Binary file removed screenshots/5.png
Binary file not shown.
Binary file removed screenshots/6.png
Binary file not shown.
Binary file removed screenshots/7.png
Binary file not shown.
1 change: 0 additions & 1 deletion src/nodesnim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ when defined(debug):

info("Compiled in debug mode.")


import nodesnim/thirdparty/sdl2 except Color
import
nodesnim/thirdparty/opengl,
Expand Down
5 changes: 3 additions & 2 deletions src/nodesnim/core/audio_stream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import
../thirdparty/sdl2/mixer


discard mixer.init(MIX_INIT_OGG)
discard mixer.openAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)
once:
discard mixer.init(MIX_INIT_OGG)
discard mixer.openAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)

type
AudioStreamRef* = ref object of RootObj
Expand Down
5 changes: 5 additions & 0 deletions src/nodesnim/core/color.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# author: Ethosa
import
../thirdparty/opengl,
strutils,
re

Expand Down Expand Up @@ -201,6 +202,10 @@ proc lerp*(self, other: ColorRef, lerpv: float): uint32 =
lerp(r1, g1, b1, a1, r2, g2, b2, a2, lerpv)


proc glColor*(clr: ColorRef) =
glColor4f(clr.r, clr.g, clr.b, clr.a)


# --- Operators --- #
proc `$`*(color: ColorRef): string =
"Color(" & $color.r & ", " & $color.g & ", " & $color.b & ", " & $color.a & ")"
Expand Down
16 changes: 8 additions & 8 deletions src/nodesnim/core/font.nim
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ styleFunc(setItalic, TTF_STYLE_ITALIC)
styleFunc(setUnderline, TTF_STYLE_UNDERLINE)
styleFunc(setStrikethrough, TTF_STYLE_STRIKETHROUGH)

proc setURL*(text: StyleText, s, e: int, url: string) =
proc setURL*(text: StyleText, s, e: int,
url: string, color: ColorRef = URL_COLOR) =
for i in s..e:
text.chars[i].is_url = true
text.chars[i].url = url
Expand Down Expand Up @@ -260,9 +261,9 @@ proc getCharUnderPoint*(text: StyleText, global_pos, text_pos: Vector2Obj,
text_align: AnchorObj = Anchor(0, 0, 0, 0)): tuple[c: StyleUnicode, pos: uint32] =
let pos = text.getPosUnderPoint(global_pos, text_pos, text_align)
if pos > 0:
(c: text.chars[pos-1], pos: pos-1)
else:
(c: text.chars[pos], pos: pos)
return (c: text.chars[pos-1], pos: pos-1)
elif text.chars.len > 0:
return (c: text.chars[pos], pos: pos)


# ------ Render ------ #
Expand All @@ -272,9 +273,8 @@ proc renderSurface*(text: StyleText, align: AnchorObj): SurfacePtr =
##
## Arguments:
## - `align` -- text align.
when defined(debug):
if text.font.isNil():
throwError(ResourceError, "Font isn't loaded!")
if text.font.isNil():
throwError(ResourceError, "Font isn't loaded!")

if not text.font.isNil() and $text != "":
let
Expand All @@ -300,7 +300,7 @@ proc renderSurface*(text: StyleText, align: AnchorObj): SurfacePtr =
color(uint8(c.color.r * 255), uint8(c.color.g * 255), uint8(c.color.b * 255), uint8(c.color.a * 255)))
r = rect(x, y, w, h)
rendered.blitSurface(nil, surface, addr r)
freeSurface(rendered)
rendered = nil
x += w
y += h + text.spacing.cint
return surface
Expand Down
Loading

0 comments on commit 4ef5a91

Please sign in to comment.