<commit_before>//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.ui.bgs;

import pythagoras.f.IDimension;

import playn.core.ImmediateLayer;
import playn.core.Surface;
import static playn.core.PlayN.graphics;

import tripleplay.ui.Background;

/**
 * A background that shows a line around a solid color.
 */
public class BorderedBackground extends Background
{
    public BorderedBackground (int bgColor, int borderColor, float thickness) {
        _bgColor = bgColor;
        _borderColor = borderColor;
        _thickness = thickness;
    }

    @Override
    protected Instance instantiate (final IDimension size) {
        return new LayerInstance(graphics().createImmediateLayer(new ImmediateLayer.Renderer() {
            public void render (Surface surf) {
                float width = size.width(), height = size.height();
                float bot = height-1, right = width-1;
                surf.setAlpha(alpha);
                surf.setFillColor(_bgColor).fillRect(0, 0, width, height);
                surf.setFillColor(_borderColor).
                    drawLine(0, 0, right, 0, _thickness).
                    drawLine(right, 0, right, bot, _thickness).
                    drawLine(right, bot, 0, bot, _thickness).
                    drawLine(0, bot, 0, 0, _thickness);
                surf.setAlpha(1);
            }
        }));
    }

    protected final int _bgColor, _borderColor;
    protected final float _thickness;
}<commit_msg>Fix bordered background rendering.<commit_after>//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.ui.bgs;

import pythagoras.f.IDimension;

import playn.core.ImmediateLayer;
import playn.core.Surface;
import static playn.core.PlayN.graphics;

import tripleplay.ui.Background;

/**
 * A background that shows a line around a solid color.
 */
public class BorderedBackground extends Background
{
    public BorderedBackground (int bgColor, int borderColor, float thickness) {
        _bgColor = bgColor;
        _borderColor = borderColor;
        _thickness = thickness;
    }

    @Override
    protected Instance instantiate (final IDimension size) {
        return new LayerInstance(graphics().createImmediateLayer(new ImmediateLayer.Renderer() {
            public void render (Surface surf) {
                float width = size.width(), height = size.height();
                surf.setAlpha(alpha);
                surf.setFillColor(_bgColor).fillRect(0, 0, width, height);
                surf.setFillColor(_borderColor).
                    fillRect(0, 0, width, _thickness).
                    fillRect(0, 0, _thickness, height).
                    fillRect(width-_thickness, 0, _thickness, height).
                    fillRect(0, height-_thickness, width, _thickness);
                surf.setAlpha(1);
            }
        }));
    }

    protected final int _bgColor, _borderColor;
    protected final float _thickness;
}
{'fraction_non_alphanumeric': 0.09729561703450419, 'fraction_numerical': 0.009325458501709667, 'mean_word_length': 2.4527896995708156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3137898', 'n_tokens_mistral': 940, 'n_tokens_neox': 880, 'n_words': 242}