/* * This file is part of the BuildIt software distribution (https://gitea.federationhq.de/byterazor/repobadge) * Copyright (c) 2020 Dominik Meyer . * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** @file */ #include #include repoBadge::Badge::Badge(const std::string &left, const std::string &right, BadgeColor color) : left_(left), right_(right) { switch(color) { case BadgeColor::BLUE: color_="#007ec6"; break; case BadgeColor::BRIGHTGREEN: color_="#4c1"; break; case BadgeColor::GREEN: color_="#97CA00"; break; case BadgeColor::YELLOWGREEN: color_="#a4a61d"; break; case BadgeColor::LIGHTGREY: color_="#9f9f9f"; break; case BadgeColor::ORANGE: color_="#fe7d37"; break; case BadgeColor::RED: color_="#e05d44"; break; case BadgeColor::YELLOW: color_="#dfb317"; break; }; } std::string repoBadge::Badge::create() { std::stringstream stream; // we use 82.5 pixes as the maxim character with for the used font-family // hopefully this will be enough int widthL = (82.5 * (float)left_.length())/ 11.0; int widthR = (82.5 * (float)right_.length())/ 11.0; int width = widthL + widthR + 20; /* * simple generation of the image */ stream << "\n"; stream << "\n"; stream << "\n"; stream << " \n"; stream << " \n"; stream << "\n"; stream << "\n"; stream << " \n"; stream << "\n"; stream << "\n"; stream << "\n"; stream << "\n"; stream << "\n"; stream << " "<\n"; stream << " "<\n"; stream << " "<\n"; stream << " "<\n"; stream << "\n"; stream << "\n"; return stream.str(); }