Friday, June 18, 2010

Project Poker Part 4

The progress do fare with my poker software is that it now exists a set of cards. Time to make a table to have somewhere to place the cards.

Lets seek some inspiration from the giant of on line poker - PokerStars. One of the layouts available on PokerStars looks like this.


Now knowing kind of what I want its time to go to work. Lets start by coding the frame around the table. This would on a real poker table consist of padded oval where the players can rest their arms. So what is needed is some kind of an ellipse. It should also have some effect applied to it to make it look cuddly and filled with padding.

Probably many ways to code the frame but one solution is to do it in four steps like this:

1. Start out with a rectangle with very rounded corners.

def outerTableFrame = Rectangle {
            x: 10, y: 10
            width: 500, height: 250
            arcWidth: 250, arcHeight: 250
            fill: Color.GREEN
        };


2. Then take another smaller rectangle and place it on the first rectangle

def innerTableFrame = Rectangle {
            x: 25, y: 25
            width: 470, height: 220
            arcWidth: 220, arcHeight: 220
            fill: Color.PINK
        };


3. Make a new shape by using ShapeSubtract. The pink parts will be "subtracted" from the green parts which will result in a new shape consisting of the green rectangle not covered by the pink rectangle. (Note that the color also changes, probably because black i set to default color in the ShapeSubtract class)

var tableFrame: Shape = ShapeSubtract {
            a: outerTableFrame
            b: innerTableFrame
        };


4. Make the frame look padded by applying a Ligthning effect. Finally choose a color, in this case blue since it seems to be the color of JavaFX

var tableFrame: Shape = ShapeSubtract {
            a: outerTableFrame
            b: innerTableFrame
            effect: Lighting {
                diffuseConstant: 1.0
                specularConstant: 1.0
                specularExponent: 20
                surfaceScale: 1.5
            }
            fill: Color.DARKBLUE
        };


See the complete source code here.

No comments:

Post a Comment