Skip to content

Commit

Permalink
coala: Add coala support
Browse files Browse the repository at this point in the history
Ref coala/coala-bears#1750

Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege committed May 19, 2017
1 parent f153f00 commit c8de176
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 149 deletions.
13 changes: 13 additions & 0 deletions .coafile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Default]
files = src/**/*.java, examples/**/*.rpde

max_line_length = 80

[Java]
# https://github.com/coala/coala-bears/issues/1750
bears = CheckstyleBear
indent_size = 4

[R]
bears = FormatRBear
files = examples/**/*.rpde
23 changes: 9 additions & 14 deletions examples/Basics/BasicOperations/BasicOperations.rpde
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,18 @@ processing$bezierDetail(as.integer(12))

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

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

# bezierPoint
for (i in 1:10) {
t = i / 10
x = processing$bezierPoint(85, 10, 90, 15, t)
y = processing$bezierPoint(20, 10, 90, 80, t)
processing$ellipse(x, y, 5, 5)
t = i/10
x = processing$bezierPoint(85, 10, 90, 15, t)
y = processing$bezierPoint(20, 10, 90, 80, t)
processing$ellipse(x, y, 5, 5)
}

processing$curve(5, 26, 73, 24, 73, 61, 15, 65)
Expand Down
16 changes: 8 additions & 8 deletions examples/Basics/Draw/Draw.rpde
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
yPos <- 0.0;
yPos <- 0

draw <- function() {
processing$background(as.integer(204))
yPos <- yPos - 1.0;
if (yPos < 0) {
yPos <- height;
}
processing$line(0, yPos, width, yPos)
processing$background(as.integer(204))
yPos <- yPos - 1
if (yPos < 0) {
yPos <- height
}
processing$line(0, yPos, width, yPos)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,52 @@
cols <- 10
rows <- 10

Cell <- function(x, y, w, h, angle)
{
me <- list(
x = x,
y = y,
w = w,
h = h,
angle = angle
)
class(me) <- append(class(me),"Cell")
Cell <- function(x, y, w, h, angle) {
me <- list(x = x, y = y, w = w, h = h, angle = angle)
class(me) <- append(class(me), "Cell")
return(me)
}

oscillate <- function(cell)
{
UseMethod("oscillate",cell)
oscillate <- function(cell) {
UseMethod("oscillate", cell)
}

oscillate.Cell <- function(cell)
{
# stdout$print("Calling the base oscillate function")
oscillate.Cell <- function(cell) {
# stdout$print('Calling the base oscillate function')
cell$angle <- cell$angle + 0.2
return(cell)
}

display <- function(cell)
{
UseMethod("display",cell)
display <- function(cell) {
UseMethod("display", cell)
}

display.Cell <- function(cell)
{
display.Cell <- function(cell) {
processing$stroke(255)
processing$fill(127 + 127 * sin(cell$angle))
processing$rect(cell$x,cell$y,cell$w,cell$h)
processing$rect(cell$x, cell$y, cell$w, cell$h)
}

grid <- list()

settings <- function() {
stdout$print("Set width and height.")
processing$size(200,200)
stdout$print("Set width and height.")
processing$size(200, 200)
}

setup <- function()
{
for (i in 1:cols-1)
{
for (j in 1:rows-1)
{
setup <- function() {
for (i in 1:cols - 1) {
for (j in 1:rows - 1) {
# There is no 0 in a list.
grid[[1 + i * cols + j]] = Cell(i*20, j*20, 20, 20, i + j)
grid[[1 + i * cols + j]] = Cell(i * 20, j * 20, 20, 20, i + j)
}
}
}

draw <- function()
{
draw <- function() {
processing$background(0)
for (i in 1:cols-1)
{
for (j in 1:rows-1)
{
for (i in 1:cols - 1) {
for (j in 1:rows - 1) {
oscillate(grid[[1 + i * cols + j]])
display(grid[[1 + i * cols + j]])
}
Expand Down
18 changes: 9 additions & 9 deletions examples/Basics/Settings/Settings.rpde
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
yPos <- 0.0;
yPos <- 0

settings <- function() {
stdout$print("Set width and height.")
processing$size(500, 500)
stdout$print("Set width and height.")
processing$size(500, 500)
}

draw <- function() {
processing$background(as.integer(204))
yPos <- yPos - 1.0;
if (yPos < 0) {
yPos <- height;
}
processing$line(0, yPos, width, yPos)
processing$background(as.integer(204))
yPos <- yPos - 1
if (yPos < 0) {
yPos <- height
}
processing$line(0, yPos, width, yPos)
}
4 changes: 2 additions & 2 deletions examples/Basics/Setup/Setup.rpde
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
setup <- function() {
processing$line(11, 22, 33, 22)
stdout$print("Hello, Processing.R")
processing$line(11, 22, 33, 22)
stdout$print("Hello, Processing.R")
}
82 changes: 36 additions & 46 deletions examples/Basics/ThreeDimensionalCube/ThreeDimensionalCube.rpde
Original file line number Diff line number Diff line change
@@ -1,53 +1,43 @@
PI <- 3.1415

settings <- function()
{
processing$size(500, 500, "processing.opengl.PGraphics3D")
settings <- function() {
processing$size(500, 500, "processing.opengl.PGraphics3D")
}

setup <- function()
{
processing$colorMode(as.integer(1), 1)
processing$frameRate(24)
setup <- function() {
processing$colorMode(as.integer(1), 1)
processing$frameRate(24)
}

draw <- function()
{
frames <- 24 * 3
t <- processing$frameCount() / frames

processing$background(1)

processing$perspective(0.5, 1, 0.01, 100)

processing$camera(
0, 0, 25 + sin(PI * 2 * t) * 3,
0, 0, 0,
0, 1, 0
)

processing$rotateX(-0.5 - 0.05 * sin(PI * 4 * t))
processing$rotateY(-0.5 - 0.05 * cos(PI * 2 * t))

columns <- 8
for (ix in 1:columns - 1)
{
x <- ix - 0.5 * columns + 0.5
for (iy in 1:columns - 1)
{
y <- iy - 0.5 * columns + 0.5
for (iz in 1:columns - 1)
{
z <- iz - 0.5 * columns + 0.5

d <- sqrt(x * x + y * y + z * z)
s <- abs(sin(d - t * 4 * PI))

processing$pushMatrix()
processing$translate(x, z, y)
processing$box(s)
processing$popMatrix()
}
draw <- function() {
frames <- 24 * 3
t <- processing$frameCount()/frames

processing$background(1)

processing$perspective(0.5, 1, 0.01, 100)

processing$camera(0, 0, 25 + sin(PI * 2 * t) * 3, 0, 0, 0, 0, 1, 0)

processing$rotateX(-0.5 - 0.05 * sin(PI * 4 * t))
processing$rotateY(-0.5 - 0.05 * cos(PI * 2 * t))

columns <- 8
for (ix in 1:columns - 1) {
x <- ix - 0.5 * columns + 0.5
for (iy in 1:columns - 1) {
y <- iy - 0.5 * columns + 0.5
for (iz in 1:columns - 1) {
z <- iz - 0.5 * columns + 0.5

d <- sqrt(x * x + y * y + z * z)
s <- abs(sin(d - t * 4 * PI))

processing$pushMatrix()
processing$translate(x, z, y)
processing$box(s)
processing$popMatrix()
}
}
}
}
}
}
60 changes: 27 additions & 33 deletions examples/Basics/Trigonometry/trigonometry.rpde
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,54 @@ radius <- 50
frequency <- 2
frequency2 <- 2

settings <- function()
{
settings <- function() {
processing$size(600, 200)
}

draw <- function()
{
draw <- function() {
processing$background(127)
processing$noStroke()
processing$fill(255)
processing$ellipse(width/8, 75, radius*2, radius*2)
processing$ellipse(width/8, 75, radius * 2, radius * 2)
# Rotates rectangle around circle
px <- width/8 + cos(processing$radians(angle))*(radius)
py <- 75 + sin(processing$radians(angle))*(radius)
px <- width/8 + cos(processing$radians(angle)) * (radius)
py <- 75 + sin(processing$radians(angle)) * (radius)
processing$fill(0)

processing$rect(px, py, 5, 5)
processing$stroke(100)
processing$line(width/8, 75, px, py)
processing$stroke(200)

# Keep reinitializing to 0, to avoid
# Flashing during redrawing

# Keep reinitializing to 0, to avoid Flashing during redrawing
angle2 <- 0

# Draw static curve - y <- sin(x)
for (i in 1:width - 1)
{
px2 <- width/8 + cos(processing$radians(angle2))*(radius)
py2 <- 75 + sin(processing$radians(angle2))*(radius)
processing$point(width/8+radius+i, py2)
for (i in 1:width - 1) {
px2 <- width/8 + cos(processing$radians(angle2)) * (radius)
py2 <- 75 + sin(processing$radians(angle2)) * (radius)
processing$point(width/8 + radius + i, py2)
angle2 <- angle2 - frequency2
}

# Send small ellipse along sine curve
# to illustrate relationship of circle to wave
# Send small ellipse along sine curve to illustrate relationship of circle to
# wave
processing$noStroke()
processing$ellipse(width/8+radius+x, py, 5, 5)
processing$ellipse(width/8 + radius + x, py, 5, 5)
angle <- angle - frequency
x <- x + 1

# When little ellipse reaches end of window,
# set the variables back to 0
if (x >= width-60) {

# When little ellipse reaches end of window, set the variables back to 0
if (x >= width - 60) {
x <- 0
angle <- 0
}

# Draw dynamic line connecting circular path with wave
processing$stroke(50)
processing$line(px, py, width/8+radius+x, py)

# Output calculations to screen
# processing$text("y <- sin x", 35, 185)
# processing$text("px <- " + px, 105, 185)
# processing$text("py <- " + py, 215, 185)
}
processing$line(px, py, width/8 + radius + x, py)

# Output calculations to screen processing$text('y <- sin x', 35, 185)
# processing$text('px <- ' + px, 105, 185) processing$text('py <- ' + py, 215,
# 185)
}

0 comments on commit c8de176

Please sign in to comment.