Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Darkmode #125

Merged
merged 4 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,15 @@ paths:
minimum: 1
example: 256

- name: color
in: query
schema:
$ref: "#/components/schemas/Color"

- name: background_color
in: query
schema:
type: string
example: "#000000"
$ref: "#/components/schemas/Color"

- name: transparency_mask
in: query
Expand Down Expand Up @@ -944,6 +948,10 @@ components:
SceneId:
type: string
example: Tqcqtc6h69

Color:
type: string
example: "#ff0000"

ViewportWidth:
type: number
Expand Down
8 changes: 4 additions & 4 deletions internal/image/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func AngleToKm(a s1.Angle) float64 {
return a.Radians() * earthRadiusKm
}

func (info *Info) MakeValid() {
if info.Width == 0 || info.Height == 0 {
info.Width = 3
info.Height = 2
func (info *Info) AspectRatio() float64 {
if info.Height == 0 {
return 3 / 2
}
return float64(info.Width) / float64(info.Height)
}

func (info *Info) Size() Size {
Expand Down
14 changes: 2 additions & 12 deletions internal/image/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,8 @@ func (source *Source) ListInfos(dirs []string, options ListOptions) (<-chan Sour
}

func (source *Source) ListInfosEmb(dirs []string, options ListOptions) <-chan InfoEmb {
out := make(chan InfoEmb, 1000)
go func() {
defer metrics.Elapsed("list infos embedded")()

infos := source.database.ListWithEmbeddings(dirs, options)
for info := range infos {
info.SourcedInfo.Info.MakeValid()
out <- info
}
close(out)
}()
return out
defer metrics.Elapsed("list infos embedded")()
return source.database.ListWithEmbeddings(dirs, options)
}

// Prefer using ImageId over this unless you absolutely need the path
Expand Down
3 changes: 1 addition & 2 deletions internal/layout/album.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type AlbumEvent struct {
func LayoutAlbumEvent(layout Layout, rect render.Rect, event *AlbumEvent, scene *render.Scene, source *image.Source) render.Rect {

if event.FirstOnDay {
font := scene.Fonts.Main.Face(70, canvas.Black, canvas.FontRegular, canvas.FontNormal)
dateFormat := "Monday, Jan 2"
if event.First {
dateFormat = "Monday, Jan 2, 2006"
Expand All @@ -39,7 +38,7 @@ func LayoutAlbumEvent(layout Layout, rect render.Rect, event *AlbumEvent, scene
W: rect.W,
H: 40,
},
&font,
&scene.Fonts.Header,
event.StartTime.Format(dateFormat),
)
text.VAlign = canvas.Bottom
Expand Down
224 changes: 0 additions & 224 deletions internal/layout/calendar.go

This file was deleted.

3 changes: 1 addition & 2 deletions internal/layout/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ func addSectionToScene(section *Section, scene *render.Scene, bounds render.Rect
Id: info.Id,
}

aspectRatio := float64(info.Width) / float64(info.Height)
imageWidth := float64(config.ImageHeight) * aspectRatio
imageWidth := float64(config.ImageHeight) * info.AspectRatio()

if x+imageWidth > bounds.W {
scale := layoutFitRow(scene.Photos[rowIdx:], bounds, config.ImageSpacing)
Expand Down
2 changes: 1 addition & 1 deletion internal/layout/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func LayoutFlex(infos <-chan image.SourcedInfo, layout Layout, scene *render.Sce
}
photo := dag.Photo{
Id: info.Id,
AspectRatio: float32(info.Width) / float32(info.Height),
AspectRatio: float32(info.AspectRatio()),
}
photos = append(photos, photo)
layoutCounter.Set(len(photos))
Expand Down
2 changes: 1 addition & 1 deletion internal/layout/highlights.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func LayoutHighlights(infos <-chan image.InfoEmb, layout Layout, scene *render.S
photo := HighlightPhoto{
Photo: dag.Photo{
Id: info.Id,
AspectRatio: float32(info.Width) / float32(info.Height),
AspectRatio: float32(info.AspectRatio()),
},
Height: float32(simHeight),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/layout/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func LayoutSearch(infos <-chan image.SimilarityInfo, layout Layout, scene *rende
mostSimilar = info.Similarity
}

aspectRatio := float64(info.Width) / float64(info.Height)
aspectRatio := info.AspectRatio()
imageWidth := float64(imageHeight) * aspectRatio

if rect.X+imageWidth > rect.W {
Expand Down
17 changes: 16 additions & 1 deletion internal/openapi/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/render/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Render struct {
TileSize int `json:"tile_size"`
MaxSolidPixelArea float64 `json:"max_solid_pixel_area"`
BackgroundColor color.Color `json:"background_color"`
Color color.Color `json:"color"`
TransparencyMask bool `json:"transparency_mask"`
LogDraws bool

Expand Down
Loading
Loading