Gimp.Curve

g GObject.Object GObject.Object Gimp.Curve Gimp.Curve GObject.Object->Gimp.Curve

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

add_point (x, y)

clear_points ()

delete_point (point)

get_curve_type ()

get_n_points ()

get_n_samples ()

get_point (point)

get_point_type (point)

get_sample (x)

is_identity ()

set_curve_type (curve_type)

set_n_samples (n_samples)

set_point (point, x, y)

set_point_type (point, type)

set_sample (x, y)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

curve-type

Gimp.CurveType

r/w/c/en

The curve type

n-samples

int

r/w/c/en

The number of samples

Signals

Inherited:

GObject.Object (1)

Name

Short Description

points-changed

Emitted when any points are added, deleted, or edited in curve.

samples-changed

Emitted when any sample is edited, or if the number of samples changed, in curve.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gimp.Curve(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gimp.CurveClass

classmethod new()
Returns:

a new curve.

Return type:

Gimp.Curve

Creates a new Gimp.Curve object, of type [enum`Gimp`.CurveType.SMOOTH], with 0 points initially.

New in version 3.2.

add_point(x, y)
Parameters:
  • x (float) – the point abscissa on a [0.0, 1.0] range.

  • y (float) – the point ordinate on a [0.0, 1.0] range.

Returns:

a point identifier to be used in other functions.

Return type:

int

Add a new point in a [enum`Gimp`.CurveType.SMOOTH] self, with coordinates (x, y). Any value outside the [0.0, 1.0] range will be silently clamped.

The returned identifier can later be used e.g. in [method`Gimp`.Curve.get_point] or other functions taking a point number as argument.

Calling this may change identifiers for other points and the total number of points in this self. Any such information you currently hold should be considered invalid once the curve is changed.

New in version 3.2.

clear_points()

Deletes all points from a [enum`Gimp`.CurveType.SMOOTH] self.

A subsequent call to [method`Gimp`.Curve.get_n_points] will return 0.

New in version 3.2.

delete_point(point)
Parameters:

point (int) – a point identifier.

Deletes a specific point from a [enum`Gimp`.CurveType.SMOOTH] self.

The point identifier must be between 0 and the value returned by [method`Gimp`.Curve.get_n_points].

You may also use a point identifier as returned by [method`Gimp`.Curve.add_point], which will correspond to the same point, unless you modified the self since (e.g. by calling gimp_curve_add_point again, or by deleting or modifying a point).

New in version 3.2.

get_curve_type()
Returns:

the self type.

Return type:

Gimp.CurveType

New in version 3.2.

get_n_points()
Returns:

the number of points in a smooth curve.

Return type:

int

Gets the number of points in a [enum`Gimp`.CurveType.SMOOTH] curve. Note that it will always be 0 for a [enum`Gimp`.CurveType.FREE] curve.

This can later be used e.g. in [method`Gimp`.Curve.get_point] as points are numbered from 0 (included) to the returned number (excluded).

Note that the Gimp.Curve API is not thread-safe. So be careful that the information on the number of points is still valid when you use it (you may have added or removed points in particular).

New in version 3.2.

get_n_samples()
Returns:

the number of samples in a freehand curve.

Return type:

int

Gets the number of samples in a [enum`Gimp`.CurveType.FREE] curve.

New in version 3.2.

get_point(point)
Parameters:

point (int) – a point identifier.

Returns:

x:

the point abscissa on a [0.0, 1.0] range.

y:

the point ordinate on a [0.0, 1.0] range.

Return type:

(x: float, y: float)

Gets the point coordinates for a [enum`Gimp`.CurveType.SMOOTH] self.

The point identifier must be between 0 and the value returned by [method`Gimp`.Curve.get_n_points].

You may also use a point identifier as returned by [method`Gimp`.Curve.add_point], which will correspond to the same point, unless you modified the self since (e.g. by calling gimp_curve_add_point again, or by deleting or modifying a point).

New in version 3.2.

get_point_type(point)
Parameters:

point (int) – a point identifier.

Returns:

the point type of a [enum`Gimp`.CurveType.SMOOTH] self.

Return type:

Gimp.CurvePointType

New in version 3.2.

get_sample(x)
Parameters:

x (float) – an abscissa on a [0.0, 1.0] range.

Return type:

float

Gets the ordinate y value corresponding to the passed x abscissa value, in a [enum`Gimp`.CurveType.FREE] self.

Note that while the y coordinate will be stored exactly, the x coordinate will be rounded to the closest curve sample on the abscissa. The more sample was set with [method`Gimp`.Curve.set_n_samples], the more precise the rounding will be.

New in version 3.2.

is_identity()
Returns:

True if the curve is an identity mapping, False otherwise.

Return type:

bool

If this function returns True, then the curve maps each value to itself. If it returns False, then this assumption can not be made.

New in version 3.2.

set_curve_type(curve_type)
Parameters:

curve_type (Gimp.CurveType) – the new curve type.

Sets the curve type of self, as follows:

  • Nothing happens if the curve type is unchanged.

  • If you change to [enum`Gimp`.CurveType.SMOOTH], it will create a non-specified number of points and will approximate their position along the freehand curve. All default points will be [enum`Gimp`.CurvePointType.SMOOTH].

  • If you change to [enum`Gimp`.CurveType.FREE], all existing points will be cleared.

New in version 3.2.

set_n_samples(n_samples)
Parameters:

n_samples (int) – the number of samples.

Sets the number of sample in a [enum`Gimp`.CurveType.FREE] self.

Samples will be positioned on the curve abscissa at regular interval. The more samples, the more your curve will have details. Currently, the value of n_samples is limited and must be between 2^8 and 2^12.

Note that changing the number of samples will reset the curve to an identity curve.

New in version 3.2.

set_point(point, x, y)
Parameters:
  • point (int) – a point identifier.

  • x (float) – the point abscissa on a [0.0, 1.0] range.

  • y (float) – the point ordinate on a [0.0, 1.0] range.

Sets the point coordinates in a [enum`Gimp`.CurveType.SMOOTH] self. Any value outside the [0.0, 1.0] range will be silently clamped.

New in version 3.2.

set_point_type(point, type)
Parameters:

Sets the point type in a [enum`Gimp`.CurveType.SMOOTH] self.

New in version 3.2.

set_sample(x, y)
Parameters:
  • x (float) – the point abscissa on a [0.0, 1.0] range.

  • y (float) – the point ordinate on a [0.0, 1.0] range.

Sets a sample in a [enum`Gimp`.CurveType.FREE] self, with coordinates (x, y).

Note that while the y coordinate will be stored exactly, the x coordinate will be rounded to the closest curve sample on the abscissa. The more sample was set with [method`Gimp`.Curve.set_n_samples], the more precise the rounding will be.

New in version 3.2.

Signal Details

Gimp.Curve.signals.points_changed(curve)
Signal Name:

points-changed

Flags:

RUN_FIRST

Parameters:

curve (Gimp.Curve) – The object which received the signal

Emitted when any points are added, deleted, or edited in curve.

New in version 3.2.

Gimp.Curve.signals.samples_changed(curve)
Signal Name:

samples-changed

Flags:

RUN_FIRST

Parameters:

curve (Gimp.Curve) – The object which received the signal

Emitted when any sample is edited, or if the number of samples changed, in curve.

New in version 3.2.

Property Details

Gimp.Curve.props.curve_type
Name:

curve-type

Type:

Gimp.CurveType

Default Value:

Gimp.CurveType.SMOOTH

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

The curve type.

New in version 3.2.

Gimp.Curve.props.n_samples
Name:

n-samples

Type:

int

Default Value:

256

Flags:

READABLE, WRITABLE, CONSTRUCT, EXPLICIT_NOTIFY

The number of samples this [enum`Gimp`.CurveType.FREE] curve is split into.

New in version 3.2.