<commit_before>/*****************************************************************************
 *
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2014 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

#ifndef MAPNIK_IMAGE_FILTER_TYPES_HPP
#define MAPNIK_IMAGE_FILTER_TYPES_HPP

// mapnik
#include <mapnik/config.hpp>
#include <mapnik/color.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/util/variant.hpp>

// stl
#include <vector>
#include <ostream>
#include <iterator>  // for std::back_insert_iterator
#include <functional> // std::ref

namespace mapnik { namespace filter {

struct image_filter_base
{
    inline bool operator==(image_filter_base const& ) const
    {
        return true;
    }
};

struct blur : image_filter_base {};
struct emboss : image_filter_base {};
struct sharpen : image_filter_base {};
struct edge_detect : image_filter_base {};
struct sobel : image_filter_base {};
struct gray : image_filter_base {};
struct x_gradient : image_filter_base {};
struct y_gradient : image_filter_base {};
struct invert : image_filter_base {};

struct agg_stack_blur : image_filter_base
{
    agg_stack_blur(unsigned rx_, unsigned ry_)
        : rx(rx_),ry(ry_) {}
    inline bool operator==(agg_stack_blur const& rhs) const
    {
        return rx == rhs.rx && ry == rhs.ry;
    }
    unsigned rx;
    unsigned ry;
};

struct color_to_alpha : image_filter_base
{
    color_to_alpha(mapnik::color const& c)
        : color(c) {}
    inline bool operator==(color_to_alpha const& rhs) const
    {
        return color == rhs.color;
    }
    mapnik::color color;
};

struct scale_hsla : image_filter_base
{
    scale_hsla(double _h0, double _h1,
         double _s0, double _s1,
         double _l0, double _l1,
         double _a0, double _a1) :
      h0(_h0),
      h1(_h1),
      s0(_s0),
      s1(_s1),
      l0(_l0),
      l1(_l1),
      a0(_a0),
      a1(_a1) {
          if (h0 < 0 || h0 > 1 ||
              h1 < 0 || h1 > 1 ||
              s0 < 0 || s0 > 1 ||
              s1 < 0 || s1 > 1 ||
              l0 < 0 || l0 > 1 ||
              l1 < 0 || l1 > 1 ||
              a0 < 0 || a0 > 1 ||
              a1 < 0 || a1 > 1)
          {
              throw config_error("scale-hsla values must be between 0 and 1");
          }
      }
    inline bool is_identity() const {
        return (h0 == 0 &&
                h1 == 1 &&
                s0 == 0 &&
                s1 == 1 &&
                l0 == 0 &&
                l1 == 1);
    }
    inline bool is_alpha_identity() const {
        return (a0 == 0 &&
                a1 == 1);<commit_msg>change config_error to std::runtime_error in scale_hsla struct<commit_after>/*****************************************************************************
 *
 * This file is part of Mapnik (c++ mapping toolkit)
 *
 * Copyright (C) 2014 <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *****************************************************************************/

#ifndef MAPNIK_IMAGE_FILTER_TYPES_HPP
#define MAPNIK_IMAGE_FILTER_TYPES_HPP

// mapnik
#include <mapnik/config.hpp>
#include <mapnik/color.hpp>
#include <mapnik/util/variant.hpp>

// stl
#include <vector>
#include <ostream>
#include <iterator>  // for std::back_insert_iterator
#include <functional> // std::ref
#include <exception>

namespace mapnik { namespace filter {

struct image_filter_base
{
    inline bool operator==(image_filter_base const& ) const
    {
        return true;
    }
};

struct blur : image_filter_base {};
struct emboss : image_filter_base {};
struct sharpen : image_filter_base {};
struct edge_detect : image_filter_base {};
struct sobel : image_filter_base {};
struct gray : image_filter_base {};
struct x_gradient : image_filter_base {};
struct y_gradient : image_filter_base {};
struct invert : image_filter_base {};

struct agg_stack_blur : image_filter_base
{
    agg_stack_blur(unsigned rx_, unsigned ry_)
        : rx(rx_),ry(ry_) {}
    inline bool operator==(agg_stack_blur const& rhs) const
    {
        return rx == rhs.rx && ry == rhs.ry;
    }
    unsigned rx;
    unsigned ry;
};

struct color_to_alpha : image_filter_base
{
    color_to_alpha(mapnik::color const& c)
        : color(c) {}
    inline bool operator==(color_to_alpha const& rhs) const
    {
        return color == rhs.color;
    }
    mapnik::color color;
};

struct scale_hsla : image_filter_base
{
    scale_hsla(double _h0, double _h1,
         double _s0, double _s1,
         double _l0, double _l1,
         double _a0, double _a1) :
      h0(_h0),
      h1(_h1),
      s0(_s0),
      s1(_s1),
      l0(_l0),
      l1(_l1),
      a0(_a0),
      a1(_a1) {
          if (h0 < 0 || h0 > 1 ||
              h1 < 0 || h1 > 1 ||
              s0 < 0 || s0 > 1 ||
              s1 < 0 || s1 > 1 ||
              l0 < 0 || l0 > 1 ||
              l1 < 0 || l1 > 1 ||
              a0 < 0 || a0 > 1 ||
              a1 < 0 || a1 > 1)
          {
              throw std::runtime_error("scale-hsla values must be between 0 and 1");
          }
      }
    inline bool is_identity() const {
        return (h0 == 0 &&
                h1 == 1 &&
                s0 == 0 &&
                s1 == 1 &&
                l0 == 0 &&
                l1 == 1);
    }
    inline bool is_alpha_identity() const {
        return (a0 == 0 &&
                a1 == 1);
{'fraction_non_alphanumeric': 0.14657071522984286, 'fraction_numerical': 0.02672932882949038, 'mean_word_length': 2.530326594090202, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '3613800', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2045, 'n_words': 667}