1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpTextLayer
* Copyright (C) 2002-2003 Sven Neumann <sven@gimp.org>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "text-types.h"
#include "core/gimpimage-undo.h"
#include "gimptext.h"
#include "gimptextlayer.h"
#include "gimptextlayer-transform.h"
static void gimp_text_layer_get_trafo (GimpTextLayer *layer,
GimpMatrix2 *trafo);
void
gimp_text_layer_scale (GimpItem *item,
gint new_width,
gint new_height,
gint new_offset_x,
gint new_offset_y,
GimpInterpolationType interpolation_type,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
}
void
gimp_text_layer_flip (GimpItem *item,
GimpContext *context,
GimpOrientationType flip_type,
gdouble axis,
gboolean clip_result)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpMatrix2 text_trafo;
GimpMatrix2 trafo = { { { 1.0, 0.0 }, { 0.0, 1.0 } } };
switch (flip_type)
{
case GIMP_ORIENTATION_HORIZONTAL:
trafo.coeff[0][0] = - 1.0;
break;
case GIMP_ORIENTATION_VERTICAL:
trafo.coeff[1][1] = - 1.0;
break;
case GIMP_ORIENTATION_UNKNOWN:
break;
}
gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
gimp_matrix2_mult (&trafo, &text_trafo);
gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
"transformation", &text_trafo,
NULL);
if (layer->mask)
gimp_item_flip (GIMP_ITEM (layer->mask), context,
flip_type, axis, clip_result);
}
void
gimp_text_layer_rotate (GimpItem *item,
GimpContext *context,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result)
{
GimpLayer *layer = GIMP_LAYER (item);
GimpMatrix2 text_trafo;
GimpMatrix2 trafo;
gdouble cos = 1.0;
gdouble sin = 0.0;
switch (rotate_type)
{
case GIMP_ROTATE_90:
cos = 0.0;
sin = - 1.0;
break;
case GIMP_ROTATE_180:
cos = - 1.0;
sin = 0.0;
break;
case GIMP_ROTATE_270:
cos = 0.0;
sin = 1.0;
break;
}
trafo.coeff[0][0] = cos;
trafo.coeff[0][1] = -sin;
trafo.coeff[1][0] = sin;
trafo.coeff[1][1] = cos;
gimp_text_layer_get_trafo (GIMP_TEXT_LAYER (layer), &text_trafo);
gimp_matrix2_mult (&trafo, &text_trafo);
gimp_text_layer_set (GIMP_TEXT_LAYER (layer), NULL,
"transformation", &text_trafo,
NULL);
if (layer->mask)
gimp_item_rotate (GIMP_ITEM (layer->mask), context,
rotate_type, center_x, center_y, clip_result);
}
void
gimp_text_layer_transform (GimpItem *item,
GimpContext *context,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean supersample,
gint recursion_level,
gboolean clip_result,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
}
static void
gimp_text_layer_get_trafo (GimpTextLayer *layer,
GimpMatrix2 *trafo)
{
*trafo = layer->text->transformation;
}
|