mirror of
https://github.com/brl/mutter.git
synced 2025-02-13 11:54:09 +00:00
![Peter Hutterer](/assets/img/avatar_default.png)
This keeps the existing ClutterBezier implementation but changes the visible API to match the needs of the tablet tool pressure curve: a bezier defined within a [0.0/0.0, 1.0/1.0] box,(sampled into a set of x->y mappings for each possible pressure input x, and a lookup function to get those values out of the curve. This patch moves the internally-only functions to be statics and changes meta_bezier_init() to take only the second and third control point, as normalized doubles. Because internally we still work with integers, the bezier curve now has an integer "precision" that defines how many points between 0.0 and 1.0 we can sample. The meta_bezier_rasterize() function calculates the x->y mapping for each point on the bezier curve given the initial scale of the curve. That value is then available to the caller via meta_bezier_lookup(). Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3399>
50 lines
1.4 KiB
C
50 lines
1.4 KiB
C
/*
|
|
* Authored By Tomas Frydrych <tf@openedhand.com>
|
|
*
|
|
* Copyright (C) 2006, 2007 OpenedHand
|
|
*
|
|
* 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 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, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <glib.h>
|
|
|
|
#include "core/util-private.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
typedef struct _MetaBezier MetaBezier;
|
|
|
|
META_EXPORT_TEST
|
|
MetaBezier * meta_bezier_new (unsigned int precision);
|
|
|
|
META_EXPORT_TEST
|
|
void meta_bezier_free (MetaBezier *b);
|
|
|
|
META_EXPORT_TEST
|
|
void meta_bezier_init (MetaBezier *b,
|
|
double x_1,
|
|
double y_1,
|
|
double x_2,
|
|
double y_2);
|
|
|
|
META_EXPORT_TEST
|
|
double meta_bezier_lookup (const MetaBezier *b,
|
|
double pos);
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaBezier, meta_bezier_free);
|
|
|
|
G_END_DECLS
|