Andy Meneely
United States
Rochester
New York
flag msg tools
designer
Squib is my Ruby library for prototyping tabletop games
badge
I spent 100 geek gold on this and I can't think of what to say here.
Avatar
mbmbmbmbmb
I'd like to introduce everyone to a pet project of mine, called Squib.

Squib is a Ruby DSL for prototyping card and board games. Write a little bit of Ruby, define your deck's stats, and you can compile your game into a series of images ready for print-and-play or even print-on-demand. Squib is very data-driven and built on the principle of Don't Repeat Yourself. Think of it like nanDeck done "the Ruby way". Squib supports:

* A concise set of rules for laying out your cards
* Loading PNGs and SVGs using Cairo
* Complex text rendering using Pango
* Reading xlsx and csv files
* Rendering to individual PNGs, PNG sheets, or PDF sheets
* Flexible, data-driven layouts in Yaml
* Basic shape drawing
* Unit conversion
* The full power of Ruby!

Check it out: http://andymeneely.github.io/squib/
Plus, it's open source under the MIT License. Free as in speech AND beer! https://github.com/andymeneely/squib

Today I've released my seventh version since July, so I think it's time to spread the word and get some feedback. About me: I'm a software engineering professor who loves designing games. I've used nanDeck for many years and I kept telling myself "this is great, but I want to do this in Ruby". Squib is still in its early stages, but I've developed a few games in it already and test it obsessively.

Note: you'll definitely need to know Ruby to use Squib, but hey, maybe this is going to be your excuse to go pick it up

Update: v0.13.4 is released on July 17, 2017. Changelog is here: https://github.com/andymeneely/squib/blob/master/CHANGELOG.m...
  • [+] Dice rolls
that Matt
United States
Ann Arbor
Michigan
flag msg tools
I'm a quitter. I come from a long line of quitters. It's amazing I'm here at all.
badge
I can feel bits of my brain falling away like wet cake.
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
I have no use for this right now but I'm pro-Ruby and pro-me-never-having-to-use-nanDeck... so I've thumbed and bookmarked this thread as hard as I can.
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
That last example on the page was astounding. Transforming a plain-looking spreadsheet into well-rendered cards is such a time saver!
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Derek H
South Africa
Pretoria
Gauteng
flag msg tools
badge
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
andygamer wrote:
Note: you'll definitely need to know Ruby to use Squib, but hey, maybe this is going to be your excuse to go pick it up

You had me up to the point where you said "Ruby".

This sounds exactly like the project I have been tinkering with, on-and-off (but mostly off), which is based on Python - and many of the underlying technologies I have been using are exactly the same as yours.

Anyway, congrats on getting this out there - not that I don't think nanDeck is good, but competition drives innovation (even in the ultra-friendly world of game design tools ).
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Chris
United States
Cheektowaga
New York
flag msg tools
badge
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
andygamer wrote:

Check it out: http://andymeneely.github.io/squib/
Plus, it's open source under the MIT License. Free as in speech AND beer! https://github.com/andymeneely/squib


Cool Tool and holy cow they have Free Beer in Rochester!!! Next time I go there for my sons Hockey I will have to look up the free beer stands. Sounds like my rendition of heaven (Well me and Bob and Doug Mckenzie).
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Gadi Oron
Israel
Rehovot
flag msg tools
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Is the output PDF of Squib a vector graphics or raster image?
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Andy Meneely
United States
Rochester
New York
flag msg tools
designer
Squib is my Ruby library for prototyping tabletop games
badge
I spent 100 geek gold on this and I can't think of what to say here.
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Thank you all for your kind words!

gamesbook wrote:

This sounds exactly like the project I have been tinkering with, on-and-off (but mostly off), which is based on Python - and many of the underlying technologies I have been using are exactly the same as yours.


Nice! Yeah Cairo & Pango are great and the bindings for Ruby and Python are pretty seamless. I would definitely encourage you to keep going and get it yours out there. There are plenty of Python folks who would love it.

regex wrote:

Is the output PDF of Squib a vector graphics or raster image?


It's raster, although Cairo handles vector back ends interchangeably, so it's certainly possible (perhaps even trivial) to support a vector-based surface the entire way and then render that out to a pdf. Is that something you want? I can play with it.
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Chris Schumann
United States
Saint Paul
Minnesota
flag msg tools
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
andygamer wrote:
It's raster, although Cairo handles vector back ends interchangeably, so it's certainly possible (perhaps even trivial) to support a vector-based surface the entire way and then render that out to a pdf. Is that something you want? I can play with it.

Vectors in the pdf will make it end up MUCH smaller, plus it can be rendered at different sizes or imported into Inkscape or something if folks want to tweak it to their needs.
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Bruce Gazdecki
United States
Lindsey
Ohio
flag msg tools
badge
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
I would love to do this, but you all are speaking a foreign language to me.

7 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Gadi Oron
Israel
Rehovot
flag msg tools
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Hi

The vector graphics option is what I think is missing in nandeck. I make a deck of cards and the PDF if 500Mb, then I start compressing and optimizing - half of the work is messing with the large files.

Another point is the text rendering which is done much better on the device itself than on the original PDF.

So YES - I would love to have this feature.

Thanks for all your work.

andygamer wrote:


regex wrote:

Is the output PDF of Squib a vector graphics or raster image?


It's raster, although Cairo handles vector back ends interchangeably, so it's certainly possible (perhaps even trivial) to support a vector-based surface the entire way and then render that out to a pdf. Is that something you want? I can play with it.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Well, I spent part of last night playing around with Squib.

It's very fun to play with!

My test project is building all the cards in Potion-Making: Practice.

It took quite a while to ramp up to speed regarding how to use the layout (which I'm still not sure I'm doing properly, since I'm repeating a bit, and that's not DRY!)

I've been considering how to build a web front-end for this, to allow me to build layouts using a graphical tool. Also, so I can access this even on a machine not running Ruby

Issues I've had so far:
1. I don't know what the layout "merge" means. I guess it has to do with how the YML keys are merged together? So far I've been sticking to the "extends" keyword.
2. Color names - I couldn't find a lookup table for the list of built-in colors in Cairo. Didn't look very hard, instead I just defined a custom color in the config.yml
3. I built the whole thing using pixel-coordinates, but I'll have to go back and re-adjust everything since the DPI was too low. I guess I should have used "units" to begin with.

Right now I'm trying to figure out how to draw a Cairo gradient that fills a rect that has been shaped by the layout.

Well done, it's a great tool!
2 
 Thumb up
8.00
 tip
 Hide
  • [+] Dice rolls
Claus Ekstrøm
Denmark
flag msg tools
badge
Oy!
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
scraimer wrote:
Well, I spent part of last night playing around with Squib.

It's very fun to play with!

My test project is building all the cards in Potion-Making: Practice.

It took quite a while to ramp up to speed regarding how to use the layout (which I'm still not sure I'm doing properly, since I'm repeating a bit, and that's not DRY!)

I've been considering how to build a web front-end for this, to allow me to build layouts using a graphical tool. Also, so I can access this even on a machine not running Ruby


Bragging bragging! We don't believe you unless you provide pictures of the end product
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
There's not much to show, I've only generated the 16 Simple Elixir types, but they are really ugly. Here you go:

4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Claus Ekstrøm
Denmark
flag msg tools
badge
Oy!
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
scraimer wrote:
There's not much to show, I've only generated the 16 Simple Elixir types, but they are really ugly. Here you go:



Looks like a fine start! Can't wait to see the end product (and to hear more about your experience as you go along). Do you have any prior experience with ruby/scripting?

Claus
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
I have a lot of experience scripting in Javascript, Perl and PHP. But Ruby? Not so much. I wrote a Ruby on Rails website about 7 years ago, but I'm not familiar with raw Ruby.

I'll keep working on it, though. Thanks for the encouragement!
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Andy Meneely
United States
Rochester
New York
flag msg tools
designer
Squib is my Ruby library for prototyping tabletop games
badge
I spent 100 geek gold on this and I can't think of what to say here.
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Thanks for trying it out! You are officially an early adopter.

By the way, I just released v0.2.0. Added a neat little showcase feature. I've hacked a bit for the vector backend idea, but that will take more time.

scraimer wrote:
It took quite a while to ramp up to speed regarding how to use the layout (which I'm still not sure I'm doing properly, since I'm repeating a bit, and that's not DRY!)


Yeah layouts are a different way of approaching it than nanDeck and others. But once I got used to it I use them all the time now.

scraimer wrote:

I've been considering how to build a web front-end for this, to allow me to build layouts using a graphical tool. Also, so I can access this even on a machine not running Ruby


So, I'm not sure that's the best idea at this point. Security would be very difficult because you'd be asking untrusted users to execute Ruby code and Ruby doesn't really have sandboxing for that. Also, Squib currently is super greedy about memory - I'm working on that, but it would be tough to tame.

My thinking was this: Squib is still Ruby, so if someone is scared off by installing Ruby then perhaps Squib is too much anyway. That said, I have found the toolkit to be pretty easy to install.

I'm also looking into some sort of portable version of Squib. Extensions to RubyGems like "gem compile" are intriguing. Or perhaps Bundler has the features we need.

scraimer wrote:

Issues I've had so far:
1. I don't know what the layout "merge" means. I guess it has to do with how the YML keys are merged together? So far I've been sticking to the "extends" keyword.


Yeah just stick to extends. It does more. Merge keys are a Yaml feature, but you can get it done with extends. I'll reivse docs so that's clearer.

scraimer wrote:

2. Color names - I couldn't find a lookup table for the list of built-in colors in Cairo. Didn't look very hard, instead I just defined a custom color in the config.yml


Here's the list that was linked off the docs:
https://github.com/rcairo/rcairo/blob/master/lib/cairo/color...
http://andymeneely.github.io/squib/doc/file.README.html#Spec...

scraimer wrote:

3. I built the whole thing using pixel-coordinates, but I'll have to go back and re-adjust everything since the DPI was too low. I guess I should have used "units" to begin with.


I personally prefer pixel coordinates. Feel cleaner to me. I tend to target templates from TheGameCrafter.com. (You might notice that the defaults are TGC's poker cards).

scraimer wrote:

Right now I'm trying to figure out how to draw a Cairo gradient that fills a rect that has been shaped by the layout.


Ah, so if you drop down to Cairo for that and get it working, let me know and I'll see if I can generalize it into a feature. Squib doesn't do gradients (yet).

Otherwise, just doing it in an SVG is probably your best bet at getting it done without using Cairo directly.

Thank you for the feedback!
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Mike Adachi
Japan
Tokyo
flag msg tools
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
First, great tool, big creds for the Ruby love, and open sourcing it is the icing on the cake! _Very_ nice!

andygamer wrote:
Thank you all for your kind words!
regex wrote:

Is the output PDF of Squib a vector graphics or raster image?


It's raster, although Cairo handles vector back ends interchangeably, so it's certainly possible (perhaps even trivial) to support a vector-based surface the entire way and then render that out to a pdf. Is that something you want? I can play with it.


Yes, pleaaaaaase implement vector output! Thanks for this great tool!
4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Just a quick update (sorry for the silence, and for pinging everyone's subscription who's not interested)

I'm still working on the project, I even got a couple hours of work in last night. Not knowing Ruby is not making this easy, but the real issue is the fact that nearly all the cards in Potion Making are unique. So it's just taking a while to input all the features on each card into a spreadsheet.

Maybe I should have started with Witch's Brew instead whistle
1 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Whoohoo! I figured out how to draw gradients!

So now, I can use the parametric colors from the "ResultParams" in a table like this:

Points,ResultTitle,Result Type,ResultParams,Ingredient1,Ingredient2,Element
4,Powder of Obeyance,Powder,red: pink:orange,Love Potion,Dragon's Tooth,Fern Flower
4,Powder of Destiny,Powder,silver:blue:gold,Tincture of Soothsaying,Pheonix Feather,Belladonna
4,Powder of the Truth,Powder,orange:green:gold,Elixir of Knowledge,Snake's Eye,Mushrooms
4,Powder of Incorporality,Powder,blue: purple:silver,Potion of Everlasting Sleep,Bat's Wing,Mandrake Root


Into cards like this:
(Note the gradient colors in the bowls and in the contents of the bowls, both from the "ResultParams" value for that card.)



I ended up doing this by adding a method named svg_in_linear_gradient to both Card and Deck, so it'll be much easier to use than writing Cairo code for each type of deck I'm building.

Yay!
8 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Andy Meneely
United States
Rochester
New York
flag msg tools
designer
Squib is my Ruby library for prototyping tabletop games
badge
I spent 100 geek gold on this and I can't think of what to say here.
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Cool! I hadn't thought of using gradients and svg that way, but it makes sense.

Would you be willing to do a pull request? I probably won't do a whole new command like that, but we can work on getting gradients in there and other places. I would obviously put your name in as a contributor.
3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Honestly, I don't really know how to do a pull request on GitHub. Sorry modest

I'll have to figure that out, I guess.

For posterity's sake, and the sake of anyone stumbling on this thread in the future, here's the code I used for the functions:

module Squib
class Card
# Helper function to build linear gradients
def linear_gradient(x1,y1,x2,y2,extend,*stops)
g = Cairo::LinearPattern.new(x1,y1,x2,y2)
g.set_extend(eval("Cairo::EXTEND_#{extend.to_s.upcase}"))
Squib.logger.debug {"linear_gradient(#{x1}, #{y1}, #{x2}, #{y2}, #{stops})"}
stops.each {|s| g.add_color_stop_rgba(*s)}
g
end

# Card-function to draw a linear gradient, clipped by the SVG (as a
# mask), this looks exactly like the SVG is drawn with a fill that is a
# linear gradient instead of a solid black.
def svg_in_linear_gradient(file, id, x, y, width, height, alpha, blend,
angle,
gradient_x1, gradient_y1, gradient_x2, gradient_y2,
gradient_extend, *gradient_stops)
return if file.nil? or file.eql? ''
svg = RSVG::Handle.new_from_file(file)
width = svg.width if width == :native
height = svg.height if height == :native
tmp = Cairo::ImageSurface.new(width, height)
tmp_cc = Cairo::Context.new(tmp)
tmp_cc.scale(width.to_f / svg.width.to_f, height.to_f / svg.height.to_f)
tmp_cc.render_rsvg_handle(svg, id)

# The above built a Cairo surface with the SVG on it
# Now let's build the gradient which will be used as the Cairo "source",
gradient = linear_gradient(
gradient_x1, gradient_y1, gradient_x2, gradient_y2, gradient_extend,
# Gradient stops:
*gradient_stops
)

use_cairo do |cc|
cc.translate(x, y)
cc.rotate(angle)
cc.translate(-1 * x, -1 * y)
# We'll clip into the SVG's shape by using the SVG-surface as a "mask"
cc.set_source(gradient)
cc.mask(tmp, x, y)
cc.operator = blend unless blend == :none
#cc.paint(alpha)
end
end
end

class Deck
# Deck-function for drawing SVG files that instead of black are drawn
# with linear gradiants as a fill
def svg_in_linear_gradient(opts = {})
p = needs(opts,[:range, :files, :svgid, :force_svgid, :x, :y, :width, :height, :layout, :alpha, :blend, :angle, :gradient_x1, :gradient_y1, :gradient_x2, :gradient_y2, :gradient_extend, :gradient_stops])
Dir.chdir(@img_dir) do
@progress_bar.start('Loading SVG(s)', p[:range].size) do |bar|
p[:range].each do |i|
unless p[:force_id][i] && p[:id][i].to_s.empty?
@cards[i].svg_in_linear_gradient(p[:file][i], p[:id][i], p[:x][i], p[:y][i],
p[:width][i], p[:height][i], p[:alpha][i], p[:blend][i], p[:angle][i],
p[:gradient_x1][i], p[:gradient_y1][i], p[:gradient_x2][i], p[:gradient_y2][i],
p[:gradient_extend][i], *p[:gradient_stops][i]
)
end
bar.increment
end
end
end
end
end
end


All I did was put that into "deck-functions.rb" and then added require './deck-functions' at the head of the deck.rb
And here's an example of how I used it to draw the bowl:

result_color3 = deck['ResultParams'].map { |x| x.split(':').at(2) }
svg_in_linear_gradient file: 'Bowl.svg', alpha: 0.5, layout: :Result,
range: :all,
gradient_x1: Array.new(deck.size) { 0 },
gradient_y1: Array.new(deck.size) { 10 },
gradient_x2: Array.new(deck.size) { 150 },
gradient_y2: Array.new(deck.size) { 0 },
gradient_extend: Array.new(deck.size) { :reflect },
gradient_stops: result_color3.map { |c| [ [0.6, c], [1.0, :white] ] }
4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Andy Meneely
United States
Rochester
New York
flag msg tools
designer
Squib is my Ruby library for prototyping tabletop games
badge
I spent 100 geek gold on this and I can't think of what to say here.
Avatar
mbmbmbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Nifty! Ok, I'm going to do two things based on your idea:

(a) Everywhere colors are specified, you can specify gradients too. Maybe a special string syntax like "(x1,y1)(x2,y2)blue[0.1]#abc[1.0]".

(b) A "mask" argument for svg and png commands. It'll takes in a color for the svg and png commands and use the image as a mask instead of a paint.

Here are the two GitHub issues:
https://github.com/andymeneely/squib/issues/29
https://github.com/andymeneely/squib/issues/32



3 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
I really like (a), but couldn't figure out how to implement easily.

And (b) is wonderful, for me. I mean, I love using thenoubproject's monochrome images, and usually I want them in a color that isn't black. But does this seem like a feature that's generally useful?

Then again, I suppose it would make designing multi-suit card decks much easier.

Thank you for taking my ideas
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Oh, and I just remembered that I still haven't implemented a radial gradient - the code I wrote is only for linear gradients! The parameter sets for the radial gradient is a little different than the linear one, I think.

Well, it can wait until I actually need it, and by then I should be able to do pull requests to make it easier for you.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Shalom Craimer
Israel
Givat Zeev
(Near Jerusalem)
flag msg tools
designer
badge
Avatar
mbmbmb
Re: Introducing Squib: a Ruby gem for prototyping games
Ah, finally finished all the cards, and the layout. I guess I can call it "v1" or something.

I tried doing proper reuse of data and settings. So in the the following three cards, the first card shows a brown-and-gray beaker, which is reused as the ingredient in the second card. The third card's ingredient is itself taken from the second card.


Same in the following two cards:



And here's another layout:



It ended up being a lot more work than I had expected, because of the large variety of card layouts. There were 8 sharply different layouts of cards, and two sub-types, bringing it up to 10.

Part of it was my own fault in trying to set all the colors in a spreadsheet. If I knew Ruby better, I could have much more easily done it. I'd have built a subclass of Card and done better code-reuse using conditionals and methods, I guess.

I like it. The next steps are making the layout have a correct bleed area, I suppose. But for now it's enough for me to construct a paper prototype which will allow me to test how much I like the game. I know it's not quite low-ink, but it's pretty good.

(edited, since I pressed "submit" by accident)
4 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
1 , 2 , 3 , 4 , 5  Next »  [9] | 
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.