Commit 9586b6b9 authored by Vesa-Pekka Palmu's avatar Vesa-Pekka Palmu

Move rendering into a square logical grid

This allows the clock to scale better on non 16:9 displays.
parent b75344e8
......@@ -5,8 +5,8 @@ import (
)
var winTitle = "SDL CLOCK"
var winWidth, winHeight int32 = 1920, 1080
var gridStartX int32 = 569
var winWidth, winHeight int32 = 1080, 1080
var gridStartX int32 = 149
var gridStartY int32 = 149
var gridSize int32 = 20
var gridSpacing = 25
......@@ -28,84 +28,86 @@ var options struct {
EngineOptions *clock.EngineOptions
}
// Radius = 500
// 12 "Hour" static circles
var staticCircles = [12][2]int32{
{1393, 790},
{1210, 973},
{960, 1040},
{710, 973},
{526, 790},
{460, 540},
{526, 290},
{709, 106},
{959, 40},
{1210, 106},
{1393, 289},
{1460, 539},
{540, 40},
{790, 107},
{973, 290},
{1040, 540},
{973, 790},
{790, 973},
{540, 1040},
{290, 973},
{107, 790},
{40, 540},
{107, 290},
{290, 107},
}
// Radius = 450
// Second circles
var secCircles = [60][2]int32{
{959, 90}, // 0
{1007, 92},
{1053, 99},
{1099, 112},
{1143, 128},
{1185, 150}, // 5
{1224, 175},
{1261, 205},
{1294, 238},
{1324, 275},
{1349, 315}, // 10
{1371, 356},
{1387, 400},
{1400, 446},
{1407, 492},
{1410, 539}, // 15
{1407, 587},
{1400, 633},
{1387, 679},
{1371, 723},
{1349, 765}, // 20
{1324, 804},
{1294, 841},
{1261, 874},
{1224, 904},
{1185, 929}, // 25
{1143, 951},
{1099, 967},
{1053, 980},
{1007, 987},
{960, 990}, // 30
{912, 987},
{866, 980},
{820, 967},
{776, 951},
{735, 929}, // 35
{695, 904},
{658, 874},
{625, 841},
{595, 804},
{570, 765}, // 40
{548, 723},
{532, 679},
{519, 633},
{512, 587},
{510, 540}, // 45
{512, 492},
{519, 446},
{532, 400},
{548, 356},
{570, 315}, // 50
{595, 275},
{625, 238},
{658, 205},
{695, 175},
{734, 150}, // 55
{776, 128},
{820, 112},
{866, 99},
{912, 92},
{540, 90},
{587, 92},
{634, 100},
{679, 112},
{723, 129},
{765, 150},
{805, 176},
{841, 206},
{874, 239},
{904, 275},
{930, 315},
{951, 357},
{968, 401},
{980, 446},
{988, 493},
{990, 540},
{988, 587},
{980, 634},
{968, 679},
{951, 723},
{930, 765},
{904, 805},
{874, 841},
{841, 874},
{805, 904},
{765, 930},
{723, 951},
{679, 968},
{634, 980},
{587, 988},
{540, 990},
{493, 988},
{446, 980},
{401, 968},
{357, 951},
{315, 930},
{275, 904},
{239, 874},
{206, 841},
{176, 805},
{150, 765},
{129, 723},
{112, 679},
{100, 634},
{92, 587},
{90, 540},
{92, 493},
{100, 446},
{112, 401},
{129, 357},
{150, 315},
{176, 275},
{206, 239},
{239, 206},
{275, 176},
{315, 150},
{357, 129},
{401, 112},
{446, 100},
{493, 92},
}
// radius 500 * 192 / 1080
......
......@@ -126,14 +126,14 @@ func main() {
staticCircles = smallStaticCircles
} else {
// Scale down if needed
renderer.SetLogicalSize(1920, 1080)
renderer.SetLogicalSize(1080, 1080)
}
staticTexture, _ = renderer.CreateTexture(sdl.PIXELFORMAT_RGBA8888, sdl.TEXTUREACCESS_TARGET, textureSize, textureSize)
renderer.SetRenderTarget(staticTexture)
if !options.Small {
gfx.FilledCircleColor(renderer, textureCoord, textureCoord, textureRadius, staticSDLColor)
gfx.AACircleColor(renderer, textureCoord, textureCoord, textureRadius, staticSDLColor)
// gfx.AACircleColor(renderer, textureCoord, textureCoord, textureRadius, staticSDLColor)
} else {
renderer.SetDrawColor(staticSDLColor.R, staticSDLColor.G, staticSDLColor.B, 255)
renderer.DrawPoint(0, 1)
......@@ -163,7 +163,7 @@ func main() {
renderer.SetRenderTarget(secTexture)
if !options.Small {
gfx.FilledCircleColor(renderer, textureCoord, textureCoord, textureRadius, secSDLColor)
gfx.AACircleColor(renderer, textureCoord, textureCoord, textureRadius, secSDLColor)
// gfx.AACircleColor(renderer, textureCoord, textureCoord, textureRadius, secSDLColor)
} else {
renderer.SetDrawColor(secSDLColor.R, secSDLColor.G, secSDLColor.B, 255)
renderer.DrawPoint(0, 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment