Skip to content

Commit

Permalink
reference: Fix the integer transfer
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <ce.gao@outlook.com>
  • Loading branch information
gaocegege committed Jun 5, 2017
1 parent c675d71 commit b825b5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/reference/arc/arc2/arc2.rpde
Expand Up @@ -4,4 +4,5 @@ OPEN <- 1
CHORD <- 2
PIE <- 3

processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, OPEN)
# TODO: Fix double to int cast.
processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, as.integer(OPEN))
2 changes: 1 addition & 1 deletion examples/reference/arc/arc3/arc3.rpde
Expand Up @@ -4,4 +4,4 @@ OPEN <- 1
CHORD <- 2
PIE <- 3

processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, CHORD)
processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, as.integer(CHORD))
2 changes: 1 addition & 1 deletion examples/reference/arc/arc4/arc4.rpde
Expand Up @@ -4,4 +4,4 @@ OPEN <- 1
CHORD <- 2
PIE <- 3

processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE)
processing$arc(50, 50, 80, 80, 0, PI + QUARTER_PI, as.integer(PIE))
17 changes: 11 additions & 6 deletions examples/reference/point/point2/point2.rpde
@@ -1,9 +1,14 @@
# point 2 https://processing.org/reference/point_.html

P3D <- "processing.opengl.PGraphics3D"
processing$size(100, 100, P3D)
processing$noSmooth()
processing$point(30, 20, -50)
processing$point(85, 20, -50)
processing$point(85, 75, -50)
processing$point(30, 75, -50)
settings <- function() {
processing$size(100, 100, P3D)
}

draw <- function() {
processing$noSmooth()
processing$point(30, 20, -50)
processing$point(85, 20, -50)
processing$point(85, 75, -50)
processing$point(30, 75, -50)
}

5 comments on commit b825b5c

@jeremydouglass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these as.integer() casts temporary -- will they be removed once CHORD PIE etc. constants #49 and built-in variables #98 are supported?

@jeremydouglass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that you changed point2.rpde from immediate mode by adding a settings() and draw() function.

The original simple reference sketch was written in immediate mode (https://processing.org/reference/point_.html).

Is P3D not currently working in immediate mode?

@gaocegege
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re b825b5c#commitcomment-22418715

Yeah, I think so.

re b825b5c#commitcomment-22418768

P3D works well, but size doesn't works since we don't have preprocessor to re-assemble the code #39

@jeremydouglass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it about size -- thanks.

Re: as.integer() b825b5c#commitcomment-22418715 :

I'd recommend always putting temporary casts, temporary definitions of constants, temporary definitions of graphics modes, and other placeholders in the header in order to leave the body of sketches as clean as possible in demos, tests, and reference sketches.

So, we don't do this:

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

...but instead do this:

P3D <- "processing.opengl.PGraphics3D"
settings <- function() {
  size(100, 100, P3D)
}

And we don't do this:

PIE <- 3
arc(50, 50, 80, 80, 0, PI + QUARTER_PI, as.integer(PIE))

...but instead do this:

PIE <- as.integer(3)
arc(50, 50, 80, 80, 0, PI + QUARTER_PI, PIE)

Later the top lines can be deleted -- once the variable is defined by the mode.

@gaocegege
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes sense!

Please sign in to comment.