Skip to content

Commit 3de3197

Browse files
authored
Add background color support
Allow for background color changes
1 parent c9b0679 commit 3de3197

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
end
2525
end
2626

27+
2728
get '/:base/:username' do
29+
# Custom color scheme, with default background
2830
headers 'Cache-Control' => "max-age=#{60*60*24}"
2931
headers 'Content-Type' => "image/svg+xml"
3032

@@ -44,3 +46,27 @@
4446
out << svg
4547
end
4648
end
49+
50+
51+
get '/:base/:background/:username' do
52+
# Custom color scheme, with custom background
53+
headers 'Cache-Control' => "max-age=#{60*60*24}"
54+
headers 'Content-Type' => "image/svg+xml"
55+
56+
username = params[:username].chomp('.svg')
57+
58+
#Makes API backwards compatible
59+
if(params[:base] == "teal" || params[:base] == "halloween" || params[:base] == "default")
60+
scheme = COLOR_SCHEMES[params[:base].to_sym]
61+
else
62+
#this case will be executed a majority of the time
63+
base_color = '#'+params[:base]
64+
background_color = '#'+params[:background]
65+
scheme = [background_color, lighten_color(base_color, 0.3), lighten_color(base_color, 0.2), base_color, darken_color(base_color, 0.8)]
66+
end
67+
68+
svg = GithubChart.new(user: username, colors: scheme).render('svg')
69+
stream do |out|
70+
out << svg
71+
end
72+
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy