Work on examples

This commit is contained in:
Joey Yakimowich-Payne 2020-08-28 04:11:48 -06:00
commit 86fa492323
3 changed files with 48 additions and 5 deletions

View file

@ -2,12 +2,52 @@ import os
import nanovg
type
StyleConfig* = ref object
cornerRadiusTopLeft*: float
cornerRadiusTopRight*: float
cornerRadiusBottomLeft*: float
cornerRadiusBottomRight*: float
fontBlur*: float
font*: string
fontSize*: float
fontColor*: Color
fontShadowColor*: Color
fontShadowXOffset*: float
fontShadowYOffset*: float
textAlignments*: seq[Alignment]
hasShadow*: bool
shadowColor*: Color
shadowXOffset*: float
shadowYOffset*: float
highlightColor*: Color
highlightWidth*: float
fillColor*: Color
fillOverlay*: Paint
WindowConfig* = object
cornerRadiusTopLeft*: float
cornerRadiusTopRight*: float
cornerRadiusBottomLeft*: float
cornerRadiusBottomRight*: float
let DEFAULT_BUTTON_STYLE = StyleConfig(
cornerRadiusTopLeft: 3.0,
cornerRadiusTopRight: 3.0,
cornerRadiusBottomLeft: 3.0,
cornerRadiusBottomRight: 3.0,
fontBlur: 0.0,
font: "sans",
fontSize: 20.0,
fontColor: rgba(255, 255, 255, 160),
fontShadowColor: rgba(0, 0, 0, 60)
)
# To see icons in code, use a nerd font
const ICON_TRASH* = ""
const ICON_SEARCH* = "🔍"
@ -42,7 +82,7 @@ proc drawWindow*(vg: Context, title: string, x, y, w, h: float, font="sans") =
vg.setFont(font)
vg.textAlign("center middle")
vg.setFontBlur(2)
vg.setFontBlur(0)
vg.setFillColor(rgba(0,0,0,128))
vg.text(title, x+w/2, y+16+1)
@ -215,4 +255,4 @@ proc drawSearchBox*(vg: Context, text: string, x, y, w, h: float) =
vg.setFont("icons")
vg.setFillColor(rgba(255,255,255,32))
vg.textAlign("center middle")
vg.text(ICON_CIRCLED_CROSS, x+w-h*0.55f, y+h*0.55f)
vg.text(ICON_CIRCLED_CROSS, x+w-h*0.55f, y+h*0.55f)