Object
A LinearGradientBrush allows GUI object to be painted with a smooth transition between two or more colours positioned along a line.
The colours, angle and style of shading can all be controlled to allow a massive variety of styles to be created.
LinearGradientBrushes can be used to paint any object which you would normally paint with a single-colour Brush object.
As with all graphical effects, these are rather tricky to describe in words, so refer to the User Guide, beginning at pg.167 for some examples that include screenshots of the effects.
Defines a new LinearGradientBrush. The arguments are defined as follows...
area -> Defines the area which the Gradient will cover. Outside this area, the gradient will be repeated by tiling it. Hence, if you want a gradient to cover the whole of an object without joins, you should define the area to completely include the object that you want to paint.
colour1, colour2 -> Two Color objects. By default these two colours define the start and end of the gradient - points in between will be painted with a blend of the two colours. When the angle parameter is zero, colour1 will be to the left, and colour2 to the right.
angle -> A Float value in degrees. The whole gradient will be rotated by this amount, going clockwise for positive values.
scale_transform -> A true or false value. When true, the rotation of the gradient will be adjusted to conform with any other transformations that are applied to the gradient.
# File GUI_Classes.rb, line 1643 def self.new #DUMMY end
This method allows a gradient to be defined that has more than two colours, each positioned at any point along the gradient.
The Array elements should each be two element Arrays each containing two values, first a Color object, then a Float between 0.0 and 1.0 to define that Color's position.
For example...
col1 = Color.new(255, 0, 0) col2 = Color.new(0, 255, 0) col3 = Color.new(0, 0, 255) @my_gradient.interpolationColors([ [co1, 0.0], [col2, 0.5], [col3, 1.0] ])
# File GUI_Classes.rb, line 1767 def interpolationColors #DUMMY end
Cancels any transformations applied by the rotateTransform, translateTransform and scaleTransform methods, returning the gradient to its original form.
# File GUI_Classes.rb, line 1686 def resetTransform #DUMMY end
Takes a Float giving an angle in degrees, and rotates the whole gradient by this amount (in degrees, going clockwise for positive values.)
# File GUI_Classes.rb, line 1653 def rotateTransform #DUMMY end
Scales the whole gradient relative to the top left corner of the originally given area. Each value is a Float, where a value of 1.0 represents the original scale of the gradient. The gradient can be scaled independently in the X and Y dimensions if two different values are given.
# File GUI_Classes.rb, line 1676 def scaleTransform #DUMMY end
This method allows the two originally set colours to be blended in any proportion at any point along the gradient. The Array elements should be two element arrays, each containing two Float values between 0.0 and 1.0.
Each pair of values gives, first, a mix amount where 0.0 = colour1 and 1.0 = colour2. The second of each pair defines the position along the gradient. For example...
my_gradient.setBlend( [ [0.0, 0.0], [1.0, 0.25], [0.5, 0.75], [1.0, 0.0] ] )
This can generate a wide variety of effects somewhat like ripples on the surface of water.
# File GUI_Classes.rb, line 1747 def setBlend #DUMMY end
This method changes the way that the two originally specified colours are blended. The original colour1 will become the colour at both edges, with colour2 positioned at some point in between, blending towards the two edges in a smooth way - similar to the way a curved surface would catch the light.
The focus argument is a Float between 0.0 and 1.0, and sets the position where the second colour will be most intense - 0.5 being a point mid-way vetween the two edges.
The scale argument is also a Float between 0.0 to 1.0, and sets the intensity of the second colour at the focus point. When zero, the second colour will not appear at all. When 1.0 the second colour appears in its pure form at the focus point.
# File GUI_Classes.rb, line 1729 def setBlendBellShape #DUMMY end
This method changes the way that the two originally specified colours are blended. The original colour1 will become the colour at both edges, with colour2 positioned at some point in between, blending towards the two edges as a linear mix.
The focus argument is a Float between 0.0 and 1.0, and sets the position where the second colour will be most intense - 0.5 being a point mid-way vetween the two edges.
The scale argument is also a Float between 0.0 to 1.0, and sets the intensity of the second colour at the focus point. When zero, the second colour will not appear at all. When 1.0 the second colour appears in its pure form at the focus point.
# File GUI_Classes.rb, line 1707 def setBlendTriangularShape #DUMMY end
By default, a LinearGradientBrush will be repeated by joining tiles that are all copies of the original area defined for the gradient. This can lead to ugly joins if the shape to be painted crosses a boundary between tiles.
To overcome this, wrapping mode can be turned on. This reverses the gradient for alternate tiles.
To turn wrapping on, pass either the Integer 1, or the String "flip" to this method. Pass 0 or "tile" to turn wrapping off.
# File GUI_Classes.rb, line 1785 def setWrapMode #DUMMY end
Shifts the whole gradient without rotation. Both x and y are Float values, and shift the gradient by the given amount. measured in grid units, along the x-axis, and y-axis respectively.
# File GUI_Classes.rb, line 1664 def translateTransform #DUMMY end
Generated with the Darkfish Rdoc Generator 2.