Loading...
Searching...
No Matches
mypaint-symmetry.h
Go to the documentation of this file.
#ifndef MYPAINTSYMMETRY_H
#define MYPAINTSYMMETRY_H
/* libmypaint - The MyPaint Brush Library
* Copyright (C) 2017-2019 The MyPaint Team
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "mypaint-matrix.h"
#include "mypaint-glib-compat.h"
typedef enum {
MYPAINT_SYMMETRY_TYPE_VERTICAL,
MYPAINT_SYMMETRY_TYPE_HORIZONTAL,
MYPAINT_SYMMETRY_TYPE_VERTHORZ,
MYPAINT_SYMMETRY_TYPE_ROTATIONAL,
MYPAINT_SYMMETRY_TYPE_SNOWFLAKE,
MYPAINT_SYMMETRY_TYPES_COUNT
} MyPaintSymmetryType;
typedef struct {
MyPaintSymmetryType type;
float center_x;
float center_y;
float angle;
float num_lines;
} MyPaintSymmetryState;
typedef struct {
MyPaintSymmetryState state_current;
MyPaintSymmetryState state_pending;
gboolean pending_changes;
gboolean active;
int num_symmetry_matrices;
MyPaintTransform *symmetry_matrices;
} MyPaintSymmetryData;
void mypaint_update_symmetry_state(MyPaintSymmetryData * const symmetry_data);
MyPaintSymmetryData mypaint_default_symmetry_data();
void mypaint_symmetry_data_destroy(MyPaintSymmetryData *);
void mypaint_symmetry_set_pending(
MyPaintSymmetryData* data, gboolean active, float center_x, float center_y,
float symmetry_angle, MyPaintSymmetryType symmetry_type, int rot_symmetry_lines);
#endif
mypaint-glib-compat.h
gboolean
gint gboolean
Definition mypaint-glib-compat.h:25
mypaint-matrix.h
MyPaintSymmetryType
MyPaintSymmetryType
Enumeration of different kinds of symmetry.
Definition mypaint-symmetry.h:27
MYPAINT_SYMMETRY_TYPE_SNOWFLAKE
@ MYPAINT_SYMMETRY_TYPE_SNOWFLAKE
rotational symmetry and its reflection
Definition mypaint-symmetry.h:47
MYPAINT_SYMMETRY_TYPES_COUNT
@ MYPAINT_SYMMETRY_TYPES_COUNT
number of available symmetry types (only use to enumerate)
Definition mypaint-symmetry.h:51
MYPAINT_SYMMETRY_TYPE_ROTATIONAL
@ MYPAINT_SYMMETRY_TYPE_ROTATIONAL
rotational symmetry
Definition mypaint-symmetry.h:43
MYPAINT_SYMMETRY_TYPE_VERTICAL
@ MYPAINT_SYMMETRY_TYPE_VERTICAL
reflection across the (vertical) y-axis
Definition mypaint-symmetry.h:31
MYPAINT_SYMMETRY_TYPE_HORIZONTAL
@ MYPAINT_SYMMETRY_TYPE_HORIZONTAL
reflection across the (horizontal) x-axis
Definition mypaint-symmetry.h:35
MYPAINT_SYMMETRY_TYPE_VERTHORZ
@ MYPAINT_SYMMETRY_TYPE_VERTHORZ
reflection across both the x-axis and the y-axis
Definition mypaint-symmetry.h:39
MyPaintSymmetryData
Contains data used for symmetry calculations.
Definition mypaint-symmetry.h:99
MyPaintSymmetryData::mypaint_update_symmetry_state
void mypaint_update_symmetry_state(MyPaintSymmetryData *const symmetry_data)
If necessary, recalculate symmetry_matrices.
MyPaintSymmetryData::state_pending
MyPaintSymmetryState state_pending
The pending symmetry state.
Definition mypaint-symmetry.h:110
MyPaintSymmetryData::mypaint_symmetry_data_destroy
void mypaint_symmetry_data_destroy(MyPaintSymmetryData *)
Destroy resources used by the data struct, and the struct itself.
MyPaintSymmetryData::mypaint_symmetry_set_pending
void mypaint_symmetry_set_pending(MyPaintSymmetryData *data, gboolean active, float center_x, float center_y, float symmetry_angle, MyPaintSymmetryType symmetry_type, int rot_symmetry_lines)
Update state_pending and active and set pending_changes to TRUE.
MyPaintSymmetryData::num_symmetry_matrices
int num_symmetry_matrices
The size of symmetry_matrices, depends on type and num_lines of state_current.
Definition mypaint-symmetry.h:124
MyPaintSymmetryData::symmetry_matrices
MyPaintTransform * symmetry_matrices
The matrices used for the actual symmetry calculations.
Definition mypaint-symmetry.h:128
MyPaintSymmetryData::active
gboolean active
Whether symmetry is used or not.
Definition mypaint-symmetry.h:120
MyPaintSymmetryData::state_current
MyPaintSymmetryState state_current
The current symmetry state.
Definition mypaint-symmetry.h:104
MyPaintSymmetryData::pending_changes
gboolean pending_changes
Flag used to check if state_pending needs to be compared against state_current (does not necessarily ...
Definition mypaint-symmetry.h:116
MyPaintSymmetryData::mypaint_default_symmetry_data
MyPaintSymmetryData mypaint_default_symmetry_data()
Create a default symmetry data instance.
MyPaintSymmetryState
Contains the basis for symmetry calculations.
Definition mypaint-symmetry.h:65
MyPaintSymmetryState::type
MyPaintSymmetryType type
The type of symmetry to use.
Definition mypaint-symmetry.h:69
MyPaintSymmetryState::center_x
float center_x
The x coordinate of the symmetry center.
Definition mypaint-symmetry.h:73
MyPaintSymmetryState::angle
float angle
The angle of the symmetry, in radians.
Definition mypaint-symmetry.h:81
MyPaintSymmetryState::num_lines
float num_lines
The number of symmetry lines to use, only relevant when type is one of MYPAINT_SYMMETRY_TYPE_ROTATION...
Definition mypaint-symmetry.h:86
MyPaintSymmetryState::center_y
float center_y
The y coordinate of the symmetry center.
Definition mypaint-symmetry.h:77
MyPaintTransform
3x3 matrix of floats, row-major order.
Definition mypaint-matrix.h:29