21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Structure of Drawings<br />

Gradient.Style = com.sun.star.awt.GradientStyle.LINEAR<br />

Gradient.StartColor = RGB(255,0,0)<br />

Gradient.EndColor = RGB(0,255,0)<br />

Gradient.StartIntensity = 150<br />

Gradient.EndIntensity = 150<br />

Gradient.Angle = 450<br />

Gradient.StepCount = 100<br />

RectangleShape.FillStyle = com.sun.star.drawing.FillStyle.GRADIENT<br />

RectangleShape.FillGradient = Gradient<br />

Page.add(RectangleShape)<br />

This example creates a linear color gradient (Style = LINEAR). The gradient starts with red (StartColor) in<br />

the top left corner, and extends at a 45 degree angle (Angle) to green (EndColor) in the bottom right corner. The<br />

color intensity of the start and end colors is 150 percent (StartIntensity and EndIntensity) which results in<br />

the colors seeming brighter than the values specified in the StartColor and EndColor properties. The color<br />

gradient is depicted using a hundred graduated individual colors (StepCount).<br />

Hatches<br />

To create a hatch fill, the FillStyle property must be set to HATCH. The program code for defining the hatch is<br />

very similar to the code for color gradients. Again an auxiliary structure, in this case com.sun.star.drawing.Hatch,<br />

is used to define the appearance of hatches. The structure for hatches has the following properties:<br />

Style (Enum)<br />

type of hatch: simple, squared, or squared with diagonals (default values in accordance with<br />

com.sun.star.awt.HatchStyle)<br />

Color (Long)<br />

color of lines<br />

Distance (Long)<br />

distance between lines in hundredths of a millimeter<br />

Angle (Short)<br />

angle of hatch in tenths of a degree<br />

The following example demonstrates the use of a hatch structure:<br />

Dim Doc As Object<br />

Dim Page As Object<br />

Dim RectangleShape As Object<br />

Dim Point As New com.sun.star.awt.Point<br />

Dim Size As New com.sun.star.awt.Size<br />

Dim Hatch As New com.sun.star.drawing.Hatch<br />

Point.x = 1000<br />

Point.y = 1000<br />

Size.Width = 10000<br />

Size.Height = 10000<br />

Doc = ThisComponent<br />

Page = Doc.DrawPages(0)<br />

RectangleShape = Doc.createInstance("com.sun.star.drawing.RectangleShape")<br />

RectangleShape.Size = Size<br />

RectangleShape.Position = Point<br />

RectangleShape.FillStyle = com.sun.star.drawing.FillStyle.HATCH<br />

Hatch.Style = com.sun.star.drawing.HatchStyle.SINGLE<br />

Hatch.Color = RGB(64,64,64)<br />

Hatch.Distance = 20<br />

Hatch.Angle = 450<br />

RectangleShape.FillHatch = Hatch<br />

Page.add(RectangleShape)<br />

This code creates a simple hatch structure (HatchStyle = SINGLE) whose lines are rotated 45 degrees (Angle).<br />

116 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!