1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 varying float fade_factor; // 0->1 fade factor used for AA
13 uniform float line_width;
14 uniform float feather;
25 if (type == TYPE_LINE)
27 float start = (line_width / 2.0) - feather; // where we start to apply alpha
28 float end = (line_width / 2.0) + feather; // where we end to apply alpha
30 // Calculate the multiplier so we can transform the 0->1 fade factor
31 // to take feather and line width into account.
32 float multiplied = 1.0 / (1.0 - (start / end));
34 float dist = (1.0 - abs(fade_factor)) * multiplied;
36 alpha = clamp(dist, 0.0, 1.0);
39 vec4 result_color = color;
40 result_color.a = result_color.a * alpha;
42 gl_FragColor = result_color;
45 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */