<commit_before>// LAF OS Library
// Copyright (c) 2022  <NAME>.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.

#ifndef OS_SKIA_PAINT_H_INCLUDED
#define OS_SKIA_PAINT_H_INCLUDED
#pragma once

#include "gfx/color.h"

#include "include/core/SkPaint.h"

namespace os {

  // SkPaint wrapper, information how to paint a shape/primitive in a
  // canvas (stroke, fill or both; stroke width; color, etc.).
  class Paint : public PaintBase {
  public:
    bool antialias() const { return m_skPaint.isAntiAlias(); }
    void antialias(const bool state) {
      m_skPaint.setAntiAlias(state);
    }

    Style style() const {
      return static_cast<Style>(m_skPaint.getStyle());
    }
    void style(const Style style) {
      m_skPaint.setStyle(static_cast<SkPaint::Style>(style));
    }

    gfx::Color color() const {
      const SkColor c = m_skPaint.getColor();
      return gfx::rgba(SkColorGetR(c),
                       SkColorGetG(c),
                       SkColorGetB(c),
                       SkColorGetA(c));
    }
    void color(const gfx::Color c) {
      m_skPaint.setColor(SkColorSetARGB(gfx::geta(c),
                                        gfx::getr(c),
                                        gfx::getg(c),
                                        gfx::getb(c)));
    }

    float strokeWidth() const { return m_skPaint.getStrokeWidth(); }
    void strokeWidth(const float strokeWidth) {
      return m_skPaint.setStrokeWidth(strokeWidth);
    }

    BlendMode blendMode() const {
      auto bm = m_skPaint.asBlendMode();
      if (bm) { return static_cast<BlendMode>(bm.value()); }
      else return BlendMode::Src;
    }
    void blendMode(const BlendMode blendMode) {
      m_skPaint.setBlendMode(static_cast<SkBlendMode>(blendMode));
    }

    const SkPaint& skPaint() const { return m_skPaint; }<commit_msg>[osx] We cannot use std::optional::value() because it wasn't introduced until macOS 10.13<commit_after>// LAF OS Library
// Copyright (c) 2022  <NAME>.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.

#ifndef OS_SKIA_PAINT_H_INCLUDED
#define OS_SKIA_PAINT_H_INCLUDED
#pragma once

#include "gfx/color.h"

#include "include/core/SkPaint.h"

namespace os {

  // SkPaint wrapper, information how to paint a shape/primitive in a
  // canvas (stroke, fill or both; stroke width; color, etc.).
  class Paint : public PaintBase {
  public:
    bool antialias() const { return m_skPaint.isAntiAlias(); }
    void antialias(const bool state) {
      m_skPaint.setAntiAlias(state);
    }

    Style style() const {
      return static_cast<Style>(m_skPaint.getStyle());
    }
    void style(const Style style) {
      m_skPaint.setStyle(static_cast<SkPaint::Style>(style));
    }

    gfx::Color color() const {
      const SkColor c = m_skPaint.getColor();
      return gfx::rgba(SkColorGetR(c),
                       SkColorGetG(c),
                       SkColorGetB(c),
                       SkColorGetA(c));
    }
    void color(const gfx::Color c) {
      m_skPaint.setColor(SkColorSetARGB(gfx::geta(c),
                                        gfx::getr(c),
                                        gfx::getg(c),
                                        gfx::getb(c)));
    }

    float strokeWidth() const { return m_skPaint.getStrokeWidth(); }
    void strokeWidth(const float strokeWidth) {
      return m_skPaint.setStrokeWidth(strokeWidth);
    }

    BlendMode blendMode() const {
      auto bm = m_skPaint.asBlendMode();
      if (bm.has_value()) { return static_cast<BlendMode>(*bm); }
      else return BlendMode::Src;
    }
    void blendMode(const BlendMode blendMode) {
      m_skPaint.setBlendMode(static_cast<SkBlendMode>(blendMode));
    }

    const SkPaint& skPaint() const { return m_skPaint; }
{'fraction_non_alphanumeric': 0.11237996366467687, 'fraction_numerical': 0.003114456267843239, 'mean_word_length': 2.425777777777778, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '297680', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1197, 'n_words': 282}