samples: gistify colors
parent
8cd651d5f1
commit
43ab4b0ae8
|
|
@ -31,3 +31,6 @@
|
||||||
[submodule "samples/data"]
|
[submodule "samples/data"]
|
||||||
path = samples/data
|
path = samples/data
|
||||||
url = https://gist.github.com/6f89115805e205c647a779b7b4866151.git
|
url = https://gist.github.com/6f89115805e205c647a779b7b4866151.git
|
||||||
|
[submodule "samples/colors"]
|
||||||
|
path = samples/colors
|
||||||
|
url = https://gist.github.com/fac2f4a16a23c2bada126e93d6523971.git
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit bdfebb34afcf710fdd9fa3127e6bbf9ad541905a
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
require 'squib'
|
|
||||||
|
|
||||||
Squib::Deck.new(width: 825, height: 1125, cards: 1) do
|
|
||||||
background color: :white
|
|
||||||
|
|
||||||
y = 0
|
|
||||||
text color: '#f00', str: '3-hex', x: 50, y: y += 50
|
|
||||||
text color: '#f00', str: '3-hex (alpha)', x: 50, y: y += 50
|
|
||||||
text color: '#ff0000', str: '6-hex', x: 50, y: y += 50
|
|
||||||
text color: '#ff000099', str: '8-hex(alpha)', x: 50, y: y += 50
|
|
||||||
text color: '#ffff00000000', str: '12-hex', x: 50, y: y += 50
|
|
||||||
text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y += 50
|
|
||||||
text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y += 50
|
|
||||||
text color: '(0,0)(400,0) blue@0.0 red@1.0', str: 'Linear gradients!', x: 50, y: y += 50
|
|
||||||
text color: '(200,500,10)(200,500,100) blue@0.0 red@1.0', str: 'Radial gradients!', x: 50, y: y += 50
|
|
||||||
# see gradients.rb sample for more on gradients
|
|
||||||
|
|
||||||
save_png prefix: 'colors_'
|
|
||||||
end
|
|
||||||
|
|
||||||
# This script generates a table of the built-in constants
|
|
||||||
Squib::Deck.new(width: 3000, height: 1500) do
|
|
||||||
colors = (Cairo::Color.constants - %i(HEX_RE Base RGB CMYK HSV X11))
|
|
||||||
colors.sort_by! {|c| Cairo::Color.parse(c).to_s}
|
|
||||||
x, y, w, h = 0, 0, 300, 50
|
|
||||||
colors.each_with_index do |color, i|
|
|
||||||
rect x: x, y: y, width: w, height: h, fill_color: color
|
|
||||||
text str: color.to_s, x: x + 5, y: y + 13, font: 'Sans Bold 16',
|
|
||||||
color: (Cairo::Color.parse(color).to_hsv.v > 0.9) ? '#000' : '#fff'
|
|
||||||
y += h
|
|
||||||
if y > @height
|
|
||||||
x += w
|
|
||||||
y = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
save_png prefix: 'color_constants_'
|
|
||||||
end
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
require 'squib'
|
|
||||||
|
|
||||||
Squib::Deck.new do
|
|
||||||
# Just about anywhere Squib takes in a color it can also take in a gradient too
|
|
||||||
# The x-y coordinates on the card itself,
|
|
||||||
# and then color stops are defined between 0 and 1
|
|
||||||
background color: '(0,0)(0,1125) #ccc@0.0 #111@1.0'
|
|
||||||
line stroke_color: '(0,0)(825,0) #111@1.0 #ccc@0.0',
|
|
||||||
x1: 0, y1: 600, x2: 825, y2: 600,
|
|
||||||
stroke_width: 15
|
|
||||||
|
|
||||||
# Radial gradients look like this
|
|
||||||
circle fill_color: '(425,400,2)(425,400,120) #ccc@0.0 #111@1.0',
|
|
||||||
x: 415, y: 415, radius: 100, stroke_color: '#0000'
|
|
||||||
triangle fill_color: '(650,400,2)(650,400,120) #ccc@0.0 #111@1.0',
|
|
||||||
stroke_color: '#0000',
|
|
||||||
x1: 650, y1: 360,
|
|
||||||
x2: 550, y2: 500,
|
|
||||||
x3: 750, y3: 500
|
|
||||||
|
|
||||||
# Gradients are also good for beveling effects:
|
|
||||||
rect fill_color: '(0,200)(0,600) #111@0.0 #ccc@1.0',
|
|
||||||
x: 30, y: 350, width: 150, height: 150,
|
|
||||||
radius: 15, stroke_color: '#0000'
|
|
||||||
rect fill_color: '(0,200)(0,600) #111@1.0 #ccc@0.0',
|
|
||||||
x: 40, y: 360, width: 130, height: 130,
|
|
||||||
radius: 15, stroke_color: '#0000'
|
|
||||||
|
|
||||||
# Alpha transparency can be used too
|
|
||||||
text str: 'Hello, world!', x: 75, y: 700, font: 'Sans Bold 72',
|
|
||||||
color: '(0,0)(825,0) #000f@0.0 #0000@1.0'
|
|
||||||
|
|
||||||
save_png prefix: 'gradient_'
|
|
||||||
end
|
|
||||||
|
|
@ -36,20 +36,20 @@ describe 'Squib samples' do
|
||||||
autoscale_font/_autoscale_font.rb
|
autoscale_font/_autoscale_font.rb
|
||||||
basic.rb
|
basic.rb
|
||||||
cairo_access.rb
|
cairo_access.rb
|
||||||
data/_csv.rb
|
colors/_gradients.rb
|
||||||
config_text_markup.rb
|
config_text_markup.rb
|
||||||
custom_config.rb
|
custom_config.rb
|
||||||
shapes/_draw_shapes.rb
|
data/_csv.rb
|
||||||
embed_text.rb
|
|
||||||
data/_excel.rb
|
data/_excel.rb
|
||||||
gradients.rb
|
embed_text.rb
|
||||||
saves/_hand.rb
|
|
||||||
hello_world.rb
|
hello_world.rb
|
||||||
images/_more_load_images.rb
|
images/_more_load_images.rb
|
||||||
portrait-landscape.rb
|
portrait-landscape.rb
|
||||||
ranges.rb
|
ranges.rb
|
||||||
|
saves/_hand.rb
|
||||||
saves/_saves.rb
|
saves/_saves.rb
|
||||||
saves/_showcase.rb
|
saves/_showcase.rb
|
||||||
|
shapes/_draw_shapes.rb
|
||||||
text_options.rb
|
text_options.rb
|
||||||
tgc_proofs.rb
|
tgc_proofs.rb
|
||||||
units.rb
|
units.rb
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue