Add sample for color switch in colors docs (#274)

One of the things I used for a current project was a switch to change the color schemes quickly. I added the snippet in [Specifying Colors & Gradients](https://squib.readthedocs.io/en/latest/colors.html) and in the wiki: https://github.com/andymeneely/squib/wiki/Switch-card-background-or-invert-theme.


* Add sample for color switch in colors docs

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Update docs/colors.rst

Co-Authored-By: Andy Meneely <andy.meneely@gmail.com>

* Add color switch sample and update docs

* Add color switch sample and update docs
This commit is contained in:
Karneades
2019-05-29 09:47:29 -04:00
committed by Andy Meneely
co-authored by Andy Meneely
parent 74dfd854e8
commit d96cf71457
3 changed files with 58 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
require 'squib'
# Choose between black and white color theme for type snake
# * Allow using white snake cards with black text or
# black snake cards with white text
color = 'white'
cards = Squib.csv file: '_switch_color_data.csv', col_sep: "\t"
Squib::Deck.new cards: cards['Type'].size do
background_color = cards['Type'].map do |t|
if color == 'black' && t == "Snake" then
"black"
else
"white"
end
end
background color: background_color
text_color = cards['Type'].map do |t|
if color == 'black' && t == "Snake" then
"white"
else
"black"
end
end
text str: cards['Text'], color: text_color
save_png prefix: '_switch_color_sample_'
end
+3
View File
@@ -0,0 +1,3 @@
Type Text
Snake This is a snake.
Lion This is a lion.
1 Type Text
2 Snake This is a snake.
3 Lion This is a lion.