PDA

View Full Version : Circles: Studio and Studio Pro



AndyRage
07-14-2011, 12:11 PM
This is a silly script to paint some circles using the current tool. It was one of my early test scripts to make sure my math functions were working. It also has an simple example of using an input box to get data, and a function call.



//================================================== =========================
//================================================== =========================
// ArtRage Script File.
//================================================== =========================
//================================================== =========================

//================================================== =========================
// Version Block - Script version and ArtRage version:
//================================================== =========================
<Version>
ArtRage Version: ArtRage 3 Studio Pro
ArtRage Build: 3.0.8
Professional Edition: Yes
Script Version: 1
</Version>

//================================================== =========================
// Header block - Information about the painting which generated this script:
//================================================== =========================
<Header>
Painting Name: "Untitled"
Painting Width: 1280
Painting Height: 1024
Painting DPI: 72
</Header>

//================================================== =========================
// Script data follows:
//================================================== =========================
real VectorLength(real x, real y)
{
return sqrt(x * x + y * y)
}

void Circle(real rRad) {
<StrokeEvent>
// Prepare for the stroke.
real rCX = 640
real rCY = 512
real x = rCX
real y = rCY + rRad
real pi = 3.14159265
// Do the stroke header - sets up head angle and anticipated stroke direction.
<StrokeHeader>
<EventPt> Wait: 0.000s Loc: (x, y) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO </EventPt>
<Recorded> No </Recorded>
<Smooth> Count: 3
Loc: (x - 3, y - 3) Pr: 1 Ti: 1 Ro: 0
Loc: (x - 2, y - 2) Pr: 1 Ti: 1 Ro: 0
Loc: (x - 1, y - 1) Pr: 1 Ti: 1 Ro: 0
</Smooth>
<PrevA> Loc: (x - 3, y - 3) Pr: 1 Ti: 1 Ro: 0 </PrevA>
<PrevB> Loc: (x - 2, y - 2) Pr: 1 Ti: 1 Ro: 0 </PrevB>
<OldHd> Loc: (x - 2, y - 2) Pr: 1 Ti: 1 Ro: 0 Dr: (1, 0) Hd: (0, 1) </OldHd>
<NewHd> Loc: (x - 1, y - 1) Pr: 1 Ti: 1 Ro: 0 Dr: (1, 0) Hd: (0, 1) </NewHd>
</StrokeHeader>
// Do the circle

// MouseDown point
Loc: (x, y) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO

// Body of circle.
for (real s = 0; s <= pi * 2.05; s += pi / 100) { // Slightly more than a circle, so paint end overlaps start
x = rCX + sin(s) * rRad
y = rCY + cos(s) * rRad

Loc: (x, y) Pr: (cos(s * 2) / 2 + 0.5) Ti: 1 Ro: 0 Rv: NO Iv: NO
}
// MouseUp point.
Loc: (x, y) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO
</StrokeEvent>
return
}
<Events>
int nCircleCount = 5
real rMaxRad = 500
string sYourName = "Fred"

InputBox("How many circles: $$nCircleCount\n\r And how big should the largest be: $$rMaxRad\n\rThanks $$sYourName.")
// Tidy up the input data
if (nCircleCount > 10) nCircleCount = 10
if (nCircleCount < 1) nCircleCount = 1
if (rMaxRad < 20) rMaxRad = 20
if (rMaxRad > 500) rMaxRad = 500
real rRadStep = rMaxRad / nCircleCount
Wait: 0.000s EvType: Command CommandID: SetToolProperty ParamType: ToolProp Value: { 0x0B2D05E64 (Size), 0.56 }
for (int n = 1; n <= nCircleCount; n++) {
real rRad = rRadStep * n
MessageTip("Circle number %%n at radius %%rRad")
Circle(rRad)
}


You can download the script file here (http://www2.ambientdesign.com/files/circles.arscript)