diff --git a/plugins/paintops/hatching/CMakeLists.txt b/plugins/paintops/hatching/CMakeLists.txt --- a/plugins/paintops/hatching/CMakeLists.txt +++ b/plugins/paintops/hatching/CMakeLists.txt @@ -5,6 +5,7 @@ kis_hatching_preferences.cpp kis_hatching_paintop_settings.cpp kis_hatching_paintop_settings_widget.cpp + kis_hatching_pressure_angle_option.cpp kis_hatching_pressure_crosshatching_option.cpp kis_hatching_pressure_separation_option.cpp kis_hatching_pressure_thickness_option.cpp diff --git a/plugins/paintops/hatching/kis_hatching_paintop.h b/plugins/paintops/hatching/kis_hatching_paintop.h --- a/plugins/paintops/hatching/kis_hatching_paintop.h +++ b/plugins/paintops/hatching/kis_hatching_paintop.h @@ -28,6 +28,7 @@ #include "hatching_brush.h" #include "kis_hatching_paintop_settings.h" +#include #include #include #include @@ -73,6 +74,12 @@ */ KisPaintDeviceSP m_hatchedDab; + /** + * Curve to control the hatching angle + * according to user preferences set in the GUI + */ + KisHatchingPressureAngleOption m_angleOption; + /** * Curve to control the intensity of crosshatching * according to user preferences set in the GUI diff --git a/plugins/paintops/hatching/kis_hatching_paintop.cpp b/plugins/paintops/hatching/kis_hatching_paintop.cpp --- a/plugins/paintops/hatching/kis_hatching_paintop.cpp +++ b/plugins/paintops/hatching/kis_hatching_paintop.cpp @@ -56,11 +56,13 @@ m_hatchingBrush = new HatchingBrush(m_settings); + m_angleOption.readOptionSetting(settings); m_crosshatchingOption.readOptionSetting(settings); m_separationOption.readOptionSetting(settings); m_thicknessOption.readOptionSetting(settings); m_opacityOption.readOptionSetting(settings); m_sizeOption.readOptionSetting(settings); + m_angleOption.resetAllSensors(); m_crosshatchingOption.resetAllSensors(); m_separationOption.resetAllSensors(); m_thicknessOption.resetAllSensors(); @@ -95,6 +97,7 @@ if (!brush->canPaintFor(info)) return KisSpacingInformation(1.0); //SENSOR-depending settings + m_settings->anglesensorvalue = m_angleOption.apply(info); m_settings->crosshatchingsensorvalue = m_crosshatchingOption.apply(info); m_settings->separationsensorvalue = m_separationOption.apply(info); m_settings->thicknesssensorvalue = m_thicknessOption.apply(info); @@ -130,9 +133,6 @@ m_hatchedDab->fill(0, 0, (sw - 1), (sh - 1), aersh.data()); //this plus yellow background = french fry brush } - // Trick for moire pattern to look better - bool donotbasehatch = false; - /* If block describing how to stack hatching passes to generate crosshatching according to user specifications */ if (m_settings->enabledcurvecrosshatching) { @@ -153,8 +153,7 @@ m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle(-45), painter()->paintColor(), additionalScale); } else if (m_settings->moirepattern) { - m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle((m_settings->crosshatchingsensorvalue) * 180), painter()->paintColor(), additionalScale); - donotbasehatch = true; + m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle((m_settings->crosshatchingsensorvalue) * 360), painter()->paintColor(), additionalScale); } } else { if (m_settings->perpendicular) { @@ -173,9 +172,14 @@ } } - if (!donotbasehatch) + if (m_settings->enabledcurveangle) + m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, spinAngle((m_settings->anglesensorvalue)*360+m_settings->angle), painter()->paintColor(), additionalScale); + + // The base hatch... unless moiré or angle + if (!m_settings->moirepattern && !m_settings->enabledcurveangle) m_hatchingBrush->hatch(m_hatchedDab, x, y, sw, sh, m_settings->angle, painter()->paintColor(), additionalScale); + // The most important line, the one that paints to the screen. painter()->bitBltWithFixedSelection(x, y, m_hatchedDab, maskDab, sw, sh); painter()->renderMirrorMaskSafe(QRect(QPoint(x, y), QSize(sw, sh)), m_hatchedDab, 0, 0, maskDab, diff --git a/plugins/paintops/hatching/kis_hatching_paintop_settings.h b/plugins/paintops/hatching/kis_hatching_paintop_settings.h --- a/plugins/paintops/hatching/kis_hatching_paintop_settings.h +++ b/plugins/paintops/hatching/kis_hatching_paintop_settings.h @@ -36,6 +36,7 @@ ~KisHatchingPaintOpSettings() override; //Dialogs enabled + bool enabledcurveangle; bool enabledcurvecrosshatching; bool enabledcurveopacity; bool enabledcurveseparation; @@ -63,7 +64,8 @@ bool subpixelprecision; bool opaquebackground; - //Crosshatching, Separation and Thickness curves + //Angle, Crosshatching, Separation and Thickness curves + double anglesensorvalue; double crosshatchingsensorvalue; double separationsensorvalue; double thicknesssensorvalue; diff --git a/plugins/paintops/hatching/kis_hatching_paintop_settings.cpp b/plugins/paintops/hatching/kis_hatching_paintop_settings.cpp --- a/plugins/paintops/hatching/kis_hatching_paintop_settings.cpp +++ b/plugins/paintops/hatching/kis_hatching_paintop_settings.cpp @@ -56,6 +56,7 @@ KisHatchingPaintOpSettings *convenienttwin = static_cast(settings.data()); + convenienttwin->enabledcurveangle = getBool("PressureAngle"); convenienttwin->enabledcurvecrosshatching = getBool("PressureCrosshatching"); convenienttwin->enabledcurveopacity = getBool("PressureOpacity"); convenienttwin->enabledcurveseparation = getBool("PressureSeparation"); diff --git a/plugins/paintops/hatching/kis_hatching_paintop_settings_widget.cpp b/plugins/paintops/hatching/kis_hatching_paintop_settings_widget.cpp --- a/plugins/paintops/hatching/kis_hatching_paintop_settings_widget.cpp +++ b/plugins/paintops/hatching/kis_hatching_paintop_settings_widget.cpp @@ -23,6 +23,7 @@ #include "kis_hatching_preferences.h" #include "kis_hatching_paintop_settings.h" +#include "kis_hatching_pressure_angle_option.h" #include "kis_hatching_pressure_crosshatching_option.h" #include "kis_hatching_pressure_separation_option.h" #include "kis_hatching_pressure_thickness_option.h" @@ -54,6 +55,7 @@ addPaintOpOption(new KisCompositeOpOption(true), i18n("Blending Mode")); addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureSeparationOption(), i18n("0.0"), i18n("1.0")), i18n("Separation")); addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureThicknessOption(), i18n("0.0"), i18n("1.0")), i18n("Thickness")); + addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureAngleOption(), i18n("0.0"), i18n("1.0")), i18n("Angle")); addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureCrosshatchingOption(), i18n("0.0"), i18n("1.0")), i18n("Crosshatching")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption(), i18n("Transparent"), i18n("Opaque")), i18n("Opacity")); addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption(), i18n("0%"), i18n("100%")), i18n("Size")); diff --git a/plugins/paintops/hatching/kis_hatching_pressure_angle_option.h b/plugins/paintops/hatching/kis_hatching_pressure_angle_option.h new file mode 100644 --- /dev/null +++ b/plugins/paintops/hatching/kis_hatching_pressure_angle_option.h @@ -0,0 +1,37 @@ +/* By Idiomdrottning 2018, after a file that + * was Copyright (c) 2010 José Luis Vergara +* +* 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; either version 2 of the License, or +* (at your option) any later version. +* +* 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, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef KIS_HATCHING_PRESSURE_ANGLE_OPTION_H +#define KIS_HATCHING_PRESSURE_ANGLE_OPTION_H + +#include "kis_curve_option.h" +#include + +/** + * The pressure angle option defines a curve that is used to + * calculate the effect of pressure (or other parameters) on + * angle in the hatching brush + */ +class KisHatchingPressureAngleOption : public KisCurveOption +{ +public: + KisHatchingPressureAngleOption(); + double apply(const KisPaintInformation & info) const; +}; + +#endif diff --git a/plugins/paintops/hatching/kis_hatching_pressure_angle_option.cpp b/plugins/paintops/hatching/kis_hatching_pressure_angle_option.cpp new file mode 100644 --- /dev/null +++ b/plugins/paintops/hatching/kis_hatching_pressure_angle_option.cpp @@ -0,0 +1,36 @@ +/* By Idiomdrottning 2018, after a file that + * was Copyright (c) 2010 José Luis Vergara + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kis_hatching_pressure_angle_option.h" +#include + +#include +#include +#include + + +KisHatchingPressureAngleOption::KisHatchingPressureAngleOption() + : KisCurveOption("Angle", KisPaintOpOption::GENERAL, false) +{ +} + +double KisHatchingPressureAngleOption::apply(const KisPaintInformation & info) const +{ + if (!isChecked()) return 0.5; + return computeSizeLikeValue(info); +}