Skip to content

Commit c8de176

Browse files
committed
coala: Add coala support
Ref coala/coala-bears#1750 Signed-off-by: Ce Gao <[email protected]>
1 parent f153f00 commit c8de176

File tree

8 files changed

+124
-149
lines changed

8 files changed

+124
-149
lines changed

.coafile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Default]
2+
files = src/**/*.java, examples/**/*.rpde
3+
4+
max_line_length = 80
5+
6+
[Java]
7+
# https://github.com/coala/coala-bears/issues/1750
8+
bears = CheckstyleBear
9+
indent_size = 4
10+
11+
[R]
12+
bears = FormatRBear
13+
files = examples/**/*.rpde

examples/Basics/BasicOperations/BasicOperations.rpde

+9-14
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,18 @@ processing$bezierDetail(as.integer(12))
1414

1515
processing$bezier(85, 20, 10, 10, 90, 90, 15, 80)
1616

17-
# for (i in 1:16) {
18-
# t = i / float(steps);
19-
# x = processing$bezierPoint(85, 10, 90, 15, t);
20-
# y = processing$bezierPoint(20, 10, 90, 80, t);
21-
# tx = processing$bezierTangent(85, 10, 90, 15, t);
22-
# ty = processing$bezierTangent(20, 10, 90, 80, t);
23-
# a = atan2(ty, tx);
24-
# a -= HALF_PI;
25-
# line(x, y, cos(a)*8 + x, sin(a)*8 + y);
26-
# }
17+
# for (i in 1:16) { t = i / float(steps); x = processing$bezierPoint(85, 10, 90,
18+
# 15, t); y = processing$bezierPoint(20, 10, 90, 80, t); tx =
19+
# processing$bezierTangent(85, 10, 90, 15, t); ty = processing$bezierTangent(20,
20+
# 10, 90, 80, t); a = atan2(ty, tx); a -= HALF_PI; line(x, y, cos(a)*8 + x,
21+
# sin(a)*8 + y); }
2722

2823
# bezierPoint
2924
for (i in 1:10) {
30-
t = i / 10
31-
x = processing$bezierPoint(85, 10, 90, 15, t)
32-
y = processing$bezierPoint(20, 10, 90, 80, t)
33-
processing$ellipse(x, y, 5, 5)
25+
t = i/10
26+
x = processing$bezierPoint(85, 10, 90, 15, t)
27+
y = processing$bezierPoint(20, 10, 90, 80, t)
28+
processing$ellipse(x, y, 5, 5)
3429
}
3530

3631
processing$curve(5, 26, 73, 24, 73, 61, 15, 65)

examples/Basics/Draw/Draw.rpde

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
yPos <- 0.0;
2-
1+
yPos <- 0
2+
33
draw <- function() {
4-
processing$background(as.integer(204))
5-
yPos <- yPos - 1.0;
6-
if (yPos < 0) {
7-
yPos <- height;
8-
}
9-
processing$line(0, yPos, width, yPos)
4+
processing$background(as.integer(204))
5+
yPos <- yPos - 1
6+
if (yPos < 0) {
7+
yPos <- height
8+
}
9+
processing$line(0, yPos, width, yPos)
1010
}

examples/Basics/ObjectOrientedProgramming/ObjectOrientedProgramming.rpde

+20-37
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,52 @@
33
cols <- 10
44
rows <- 10
55

6-
Cell <- function(x, y, w, h, angle)
7-
{
8-
me <- list(
9-
x = x,
10-
y = y,
11-
w = w,
12-
h = h,
13-
angle = angle
14-
)
15-
class(me) <- append(class(me),"Cell")
6+
Cell <- function(x, y, w, h, angle) {
7+
me <- list(x = x, y = y, w = w, h = h, angle = angle)
8+
class(me) <- append(class(me), "Cell")
169
return(me)
1710
}
1811

19-
oscillate <- function(cell)
20-
{
21-
UseMethod("oscillate",cell)
12+
oscillate <- function(cell) {
13+
UseMethod("oscillate", cell)
2214
}
2315

24-
oscillate.Cell <- function(cell)
25-
{
26-
# stdout$print("Calling the base oscillate function")
16+
oscillate.Cell <- function(cell) {
17+
# stdout$print('Calling the base oscillate function')
2718
cell$angle <- cell$angle + 0.2
2819
return(cell)
2920
}
3021

31-
display <- function(cell)
32-
{
33-
UseMethod("display",cell)
22+
display <- function(cell) {
23+
UseMethod("display", cell)
3424
}
3525

36-
display.Cell <- function(cell)
37-
{
26+
display.Cell <- function(cell) {
3827
processing$stroke(255)
3928
processing$fill(127 + 127 * sin(cell$angle))
40-
processing$rect(cell$x,cell$y,cell$w,cell$h)
29+
processing$rect(cell$x, cell$y, cell$w, cell$h)
4130
}
4231

4332
grid <- list()
4433

4534
settings <- function() {
46-
stdout$print("Set width and height.")
47-
processing$size(200,200)
35+
stdout$print("Set width and height.")
36+
processing$size(200, 200)
4837
}
4938

50-
setup <- function()
51-
{
52-
for (i in 1:cols-1)
53-
{
54-
for (j in 1:rows-1)
55-
{
39+
setup <- function() {
40+
for (i in 1:cols - 1) {
41+
for (j in 1:rows - 1) {
5642
# There is no 0 in a list.
57-
grid[[1 + i * cols + j]] = Cell(i*20, j*20, 20, 20, i + j)
43+
grid[[1 + i * cols + j]] = Cell(i * 20, j * 20, 20, 20, i + j)
5844
}
5945
}
6046
}
6147

62-
draw <- function()
63-
{
48+
draw <- function() {
6449
processing$background(0)
65-
for (i in 1:cols-1)
66-
{
67-
for (j in 1:rows-1)
68-
{
50+
for (i in 1:cols - 1) {
51+
for (j in 1:rows - 1) {
6952
oscillate(grid[[1 + i * cols + j]])
7053
display(grid[[1 + i * cols + j]])
7154
}
+9-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
yPos <- 0.0;
1+
yPos <- 0
22

33
settings <- function() {
4-
stdout$print("Set width and height.")
5-
processing$size(500, 500)
4+
stdout$print("Set width and height.")
5+
processing$size(500, 500)
66
}
77

88
draw <- function() {
9-
processing$background(as.integer(204))
10-
yPos <- yPos - 1.0;
11-
if (yPos < 0) {
12-
yPos <- height;
13-
}
14-
processing$line(0, yPos, width, yPos)
9+
processing$background(as.integer(204))
10+
yPos <- yPos - 1
11+
if (yPos < 0) {
12+
yPos <- height
13+
}
14+
processing$line(0, yPos, width, yPos)
1515
}

examples/Basics/Setup/Setup.rpde

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
setup <- function() {
2-
processing$line(11, 22, 33, 22)
3-
stdout$print("Hello, Processing.R")
2+
processing$line(11, 22, 33, 22)
3+
stdout$print("Hello, Processing.R")
44
}
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,43 @@
11
PI <- 3.1415
22

3-
settings <- function()
4-
{
5-
processing$size(500, 500, "processing.opengl.PGraphics3D")
3+
settings <- function() {
4+
processing$size(500, 500, "processing.opengl.PGraphics3D")
65
}
76

8-
setup <- function()
9-
{
10-
processing$colorMode(as.integer(1), 1)
11-
processing$frameRate(24)
7+
setup <- function() {
8+
processing$colorMode(as.integer(1), 1)
9+
processing$frameRate(24)
1210
}
1311

14-
draw <- function()
15-
{
16-
frames <- 24 * 3
17-
t <- processing$frameCount() / frames
18-
19-
processing$background(1)
20-
21-
processing$perspective(0.5, 1, 0.01, 100)
22-
23-
processing$camera(
24-
0, 0, 25 + sin(PI * 2 * t) * 3,
25-
0, 0, 0,
26-
0, 1, 0
27-
)
28-
29-
processing$rotateX(-0.5 - 0.05 * sin(PI * 4 * t))
30-
processing$rotateY(-0.5 - 0.05 * cos(PI * 2 * t))
31-
32-
columns <- 8
33-
for (ix in 1:columns - 1)
34-
{
35-
x <- ix - 0.5 * columns + 0.5
36-
for (iy in 1:columns - 1)
37-
{
38-
y <- iy - 0.5 * columns + 0.5
39-
for (iz in 1:columns - 1)
40-
{
41-
z <- iz - 0.5 * columns + 0.5
42-
43-
d <- sqrt(x * x + y * y + z * z)
44-
s <- abs(sin(d - t * 4 * PI))
45-
46-
processing$pushMatrix()
47-
processing$translate(x, z, y)
48-
processing$box(s)
49-
processing$popMatrix()
50-
}
12+
draw <- function() {
13+
frames <- 24 * 3
14+
t <- processing$frameCount()/frames
15+
16+
processing$background(1)
17+
18+
processing$perspective(0.5, 1, 0.01, 100)
19+
20+
processing$camera(0, 0, 25 + sin(PI * 2 * t) * 3, 0, 0, 0, 0, 1, 0)
21+
22+
processing$rotateX(-0.5 - 0.05 * sin(PI * 4 * t))
23+
processing$rotateY(-0.5 - 0.05 * cos(PI * 2 * t))
24+
25+
columns <- 8
26+
for (ix in 1:columns - 1) {
27+
x <- ix - 0.5 * columns + 0.5
28+
for (iy in 1:columns - 1) {
29+
y <- iy - 0.5 * columns + 0.5
30+
for (iz in 1:columns - 1) {
31+
z <- iz - 0.5 * columns + 0.5
32+
33+
d <- sqrt(x * x + y * y + z * z)
34+
s <- abs(sin(d - t * 4 * PI))
35+
36+
processing$pushMatrix()
37+
processing$translate(x, z, y)
38+
processing$box(s)
39+
processing$popMatrix()
40+
}
41+
}
5142
}
52-
}
53-
}
43+
}

examples/Basics/Trigonometry/trigonometry.rpde

+27-33
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,54 @@ radius <- 50
1212
frequency <- 2
1313
frequency2 <- 2
1414

15-
settings <- function()
16-
{
15+
settings <- function() {
1716
processing$size(600, 200)
1817
}
1918

20-
draw <- function()
21-
{
19+
draw <- function() {
2220
processing$background(127)
2321
processing$noStroke()
2422
processing$fill(255)
25-
processing$ellipse(width/8, 75, radius*2, radius*2)
23+
processing$ellipse(width/8, 75, radius * 2, radius * 2)
2624
# Rotates rectangle around circle
27-
px <- width/8 + cos(processing$radians(angle))*(radius)
28-
py <- 75 + sin(processing$radians(angle))*(radius)
25+
px <- width/8 + cos(processing$radians(angle)) * (radius)
26+
py <- 75 + sin(processing$radians(angle)) * (radius)
2927
processing$fill(0)
30-
28+
3129
processing$rect(px, py, 5, 5)
3230
processing$stroke(100)
3331
processing$line(width/8, 75, px, py)
3432
processing$stroke(200)
35-
36-
# Keep reinitializing to 0, to avoid
37-
# Flashing during redrawing
33+
34+
# Keep reinitializing to 0, to avoid Flashing during redrawing
3835
angle2 <- 0
39-
36+
4037
# Draw static curve - y <- sin(x)
41-
for (i in 1:width - 1)
42-
{
43-
px2 <- width/8 + cos(processing$radians(angle2))*(radius)
44-
py2 <- 75 + sin(processing$radians(angle2))*(radius)
45-
processing$point(width/8+radius+i, py2)
38+
for (i in 1:width - 1) {
39+
px2 <- width/8 + cos(processing$radians(angle2)) * (radius)
40+
py2 <- 75 + sin(processing$radians(angle2)) * (radius)
41+
processing$point(width/8 + radius + i, py2)
4642
angle2 <- angle2 - frequency2
4743
}
48-
49-
# Send small ellipse along sine curve
50-
# to illustrate relationship of circle to wave
44+
45+
# Send small ellipse along sine curve to illustrate relationship of circle to
46+
# wave
5147
processing$noStroke()
52-
processing$ellipse(width/8+radius+x, py, 5, 5)
48+
processing$ellipse(width/8 + radius + x, py, 5, 5)
5349
angle <- angle - frequency
5450
x <- x + 1
55-
56-
# When little ellipse reaches end of window,
57-
# set the variables back to 0
58-
if (x >= width-60) {
51+
52+
# When little ellipse reaches end of window, set the variables back to 0
53+
if (x >= width - 60) {
5954
x <- 0
6055
angle <- 0
6156
}
62-
57+
6358
# Draw dynamic line connecting circular path with wave
6459
processing$stroke(50)
65-
processing$line(px, py, width/8+radius+x, py)
66-
67-
# Output calculations to screen
68-
# processing$text("y <- sin x", 35, 185)
69-
# processing$text("px <- " + px, 105, 185)
70-
# processing$text("py <- " + py, 215, 185)
71-
}
60+
processing$line(px, py, width/8 + radius + x, py)
61+
62+
# Output calculations to screen processing$text('y <- sin x', 35, 185)
63+
# processing$text('px <- ' + px, 105, 185) processing$text('py <- ' + py, 215,
64+
# 185)
65+
}

0 commit comments

Comments
 (0)