Class: Processing::Context
- Inherits:
-
Object
- Object
- Processing::Context
- Includes:
- GraphicsContext
- Defined in:
- lib/processing/context.rb
Overview
Processing context
Constant Summary collapse
- Vector =
Processing::Vector
- Capture =
Processing::Capture
- Graphics =
Processing::Graphics
- Shader =
Processing::Shader
Constants included from GraphicsContext
GraphicsContext::ADD, GraphicsContext::ALT, GraphicsContext::BACKSPACE, GraphicsContext::BASELINE, GraphicsContext::BLEND, GraphicsContext::BLUR, GraphicsContext::BOTTOM, GraphicsContext::CAPSLOCK, GraphicsContext::CENTER, GraphicsContext::CLEAR, GraphicsContext::COMMAND, GraphicsContext::CONTROL, GraphicsContext::CORNER, GraphicsContext::CORNERS, GraphicsContext::DARKEST, GraphicsContext::DEGREES, GraphicsContext::DELETE, GraphicsContext::DOWN, GraphicsContext::ENTER, GraphicsContext::ESC, GraphicsContext::EXCLUSION, GraphicsContext::F1, GraphicsContext::F10, GraphicsContext::F11, GraphicsContext::F12, GraphicsContext::F13, GraphicsContext::F14, GraphicsContext::F15, GraphicsContext::F16, GraphicsContext::F17, GraphicsContext::F18, GraphicsContext::F19, GraphicsContext::F2, GraphicsContext::F20, GraphicsContext::F21, GraphicsContext::F22, GraphicsContext::F23, GraphicsContext::F24, GraphicsContext::F3, GraphicsContext::F4, GraphicsContext::F5, GraphicsContext::F6, GraphicsContext::F7, GraphicsContext::F8, GraphicsContext::F9, GraphicsContext::FUNCTION, GraphicsContext::GRAY, GraphicsContext::HALF_PI, GraphicsContext::HELP, GraphicsContext::HOME, GraphicsContext::HSB, GraphicsContext::INVERT, GraphicsContext::LEFT, GraphicsContext::LIGHTEST, GraphicsContext::MITER, GraphicsContext::MULTIPLY, GraphicsContext::OPTION, GraphicsContext::PAGEDOWN, GraphicsContext::PAGEUP, GraphicsContext::PI, GraphicsContext::PROJECT, GraphicsContext::QUARTER_PI, GraphicsContext::RADIANS, GraphicsContext::RADIUS, GraphicsContext::REPLACE, GraphicsContext::RGB, GraphicsContext::RGBA, GraphicsContext::RIGHT, GraphicsContext::ROUND, GraphicsContext::SCREEN, GraphicsContext::SECTION, GraphicsContext::SHIFT, GraphicsContext::SPACE, GraphicsContext::SQUARE, GraphicsContext::SUBTRACT, GraphicsContext::TAB, GraphicsContext::TAU, GraphicsContext::THRESHOLD, GraphicsContext::TOP, GraphicsContext::TWO_PI, GraphicsContext::UP, GraphicsContext::WIN
Class Method Summary collapse
Instance Method Summary collapse
-
#createCanvas(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
-
#displayDensity ⇒ Numeric
Returns pixel density of display.
-
#draw(&block) ⇒ nil
Defines draw block.
-
#frameCount ⇒ Integer
Returns number of frames since program started.
-
#frameRate ⇒ Float
Returns number of frames per second.
-
#key ⇒ String
Returns the last key that was pressed or released.
-
#keyCode ⇒ Symbol
Returns the last key code that was pressed or released.
-
#keyPressed(&block) ⇒ Boolean
Defines keyPressed block.
-
#keyReleased(&block) ⇒ nil
Defines keyReleased block.
-
#keyTyped(&block) ⇒ nil
Defines keyTyped block.
-
#loop ⇒ nil
Enables calling draw block on every frame.
-
#motion(&block) ⇒ nil
Defines motion block.
-
#motionGravity ⇒ Vector
Returns vector for real world gravity.
-
#mouseButton ⇒ Numeric
Returns which mouse button was pressed.
-
#mouseClicked(&block) ⇒ nil
Defines mouseClicked block.
-
#mouseDragged(&block) ⇒ nil
Defines mouseDragged block.
-
#mouseMoved(&block) ⇒ nil
Defines mouseMoved block.
-
#mousePressed(&block) ⇒ Boolean
Defines mousePressed block.
-
#mouseReleased(&block) ⇒ nil
Defines mouseReleased block.
-
#mouseX ⇒ Numeric
Returns mouse x position.
-
#mouseY ⇒ Numeric
Returns mouse y position.
-
#noLoop ⇒ nil
Disables calling draw block on every frame.
-
#pixelDensity(density = nil) ⇒ Numeric
Changes and returns canvas pixel density.
-
#pmouseX ⇒ Numeric
Returns mouse x position in previous frame.
-
#pmouseY ⇒ Numeric
Returns mouse y position in previous frame.
-
#redraw ⇒ nil
Calls draw block to redraw frame.
-
#setTitle(title) ⇒ nil
Changes title of window.
-
#setup(&block) ⇒ nil
Defines setup block.
-
#size(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
-
#touchEnded(&block) ⇒ nil
Defines touchEnded block.
-
#touches ⇒ Array
Returns array of touches.
-
#touchMoved(&block) ⇒ nil
Defines touchMoved block.
-
#touchStarted(&block) ⇒ nil
Defines touchStarted block.
-
#windowHeight ⇒ Numeric
Returns window height.
-
#windowWidth ⇒ Numeric
Returns window width.
Methods included from GraphicsContext
#abs, #acos, #angleMode, #arc, #asin, #atan, #atan2, #background, #bezier, #blend, #blendMode, #ceil, #circle, #clip, #colorMode, #constrain, #copy, #cos, #createCapture, #createGraphics, #createImage, #createShader, #createVector, #curve, #degrees, #dist, #ellipse, #ellipseMode, #exp, #fill, #filter, #floor, #height, #image, #imageMode, #lerp, #line, #loadImage, #loadShader, #log, #mag, #map, #max, #min, #noClip, #noFill, #noStroke, #noTint, #noise, #norm, #point, #pop, #popMatrix, #popStyle, #pow, #push, #pushMatrix, #pushStyle, #quad, #radians, #random, #rect, #rectMode, #resetMatrix, #resetShader, #rotate, #round, #save, #scale, #shader, #sin, #sq, #sqrt, #square, #stroke, #strokeCap, #strokeJoin, #strokeWeight, #tan, #text, #textAlign, #textAscent, #textDescent, #textFont, #textSize, #textWidth, #tint, #translate, #triangle, #width
Class Method Details
.draw_screen(painter) ⇒ Object
51 52 53 |
# File 'lib/processing/context.rb', line 51 def @window__.draw_screen(painter) @context.drawImage__ painter end |
Instance Method Details
#createCanvas(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
294 295 296 297 |
# File 'lib/processing/context.rb', line 294 def createCanvas(width, height, pixelDensity: self.pixelDensity) resizeCanvas__ :createCanvas, width, height, pixelDensity nil end |
#displayDensity ⇒ Numeric
Returns pixel density of display.
336 337 338 |
# File 'lib/processing/context.rb', line 336 def displayDensity() @window__.painter.pixel_density end |
#draw(&block) ⇒ nil
Defines draw block.
155 156 157 158 |
# File 'lib/processing/context.rb', line 155 def draw(&block) @drawBlock__ = block if block nil end |
#frameCount ⇒ Integer
Returns number of frames since program started.
360 361 362 |
# File 'lib/processing/context.rb', line 360 def frameCount() @frameCount__ end |
#frameRate ⇒ Float
Returns number of frames per second.
368 369 370 |
# File 'lib/processing/context.rb', line 368 def frameRate() @window__.event.fps end |
#key ⇒ String
Returns the last key that was pressed or released.
376 377 378 |
# File 'lib/processing/context.rb', line 376 def key() @key__ end |
#keyCode ⇒ Symbol
Returns the last key code that was pressed or released.
384 385 386 |
# File 'lib/processing/context.rb', line 384 def keyCode() @keyCode__ end |
#keyPressed(&block) ⇒ Boolean
Defines keyPressed block.
169 170 171 172 |
# File 'lib/processing/context.rb', line 169 def keyPressed(&block) @keyPressedBlock__ = block if block not @keysPressed__.empty? end |
#keyReleased(&block) ⇒ nil
Defines keyReleased block.
178 179 180 181 |
# File 'lib/processing/context.rb', line 178 def keyReleased(&block) @keyReleasedBlock__ = block if block nil end |
#keyTyped(&block) ⇒ nil
Defines keyTyped block.
187 188 189 190 |
# File 'lib/processing/context.rb', line 187 def keyTyped(&block) @keyTypedBlock__ = block if block nil end |
#loop ⇒ nil
Enables calling draw block on every frame.
448 449 450 |
# File 'lib/processing/context.rb', line 448 def loop() @loop__ = true end |
#motion(&block) ⇒ nil
Defines motion block.
268 269 270 271 |
# File 'lib/processing/context.rb', line 268 def motion(&block) @motionBlock__ = block if block nil end |
#motionGravity ⇒ Vector
Returns vector for real world gravity
440 441 442 |
# File 'lib/processing/context.rb', line 440 def motionGravity() @motionGravity__ end |
#mouseButton ⇒ Numeric
Returns which mouse button was pressed
424 425 426 |
# File 'lib/processing/context.rb', line 424 def mouseButton() (@pointersPressed__ & [LEFT, RIGHT, CENTER]).last || 0 end |
#mouseClicked(&block) ⇒ nil
Defines mouseClicked block.
232 233 234 235 |
# File 'lib/processing/context.rb', line 232 def mouseClicked(&block) @mouseClickedBlock__ = block if block nil end |
#mouseDragged(&block) ⇒ nil
Defines mouseDragged block.
223 224 225 226 |
# File 'lib/processing/context.rb', line 223 def mouseDragged(&block) @mouseDraggedBlock__ = block if block nil end |
#mouseMoved(&block) ⇒ nil
Defines mouseMoved block.
214 215 216 217 |
# File 'lib/processing/context.rb', line 214 def mouseMoved(&block) @mouseMovedBlock__ = block if block nil end |
#mousePressed(&block) ⇒ Boolean
Defines mousePressed block.
196 197 198 199 |
# File 'lib/processing/context.rb', line 196 def mousePressed(&block) @mousePressedBlock__ = block if block not @pointersPressed__.empty? end |
#mouseReleased(&block) ⇒ nil
Defines mouseReleased block.
205 206 207 208 |
# File 'lib/processing/context.rb', line 205 def mouseReleased(&block) @mouseReleasedBlock__ = block if block nil end |
#mouseX ⇒ Numeric
Returns mouse x position
392 393 394 |
# File 'lib/processing/context.rb', line 392 def mouseX() @pointerPos__.x end |
#mouseY ⇒ Numeric
Returns mouse y position
400 401 402 |
# File 'lib/processing/context.rb', line 400 def mouseY() @pointerPos__.y end |
#noLoop ⇒ nil
Disables calling draw block on every frame.
456 457 458 |
# File 'lib/processing/context.rb', line 456 def noLoop() @loop__ = false end |
#pixelDensity(density = nil) ⇒ Numeric
Changes and returns canvas pixel density.
316 317 318 319 |
# File 'lib/processing/context.rb', line 316 def pixelDensity(density = nil) resizeCanvas__ :pixelDensity, width, height, density if density @painter__.pixel_density end |
#pmouseX ⇒ Numeric
Returns mouse x position in previous frame
408 409 410 |
# File 'lib/processing/context.rb', line 408 def pmouseX() @pointerPrevPos__.x end |
#pmouseY ⇒ Numeric
Returns mouse y position in previous frame
416 417 418 |
# File 'lib/processing/context.rb', line 416 def pmouseY() @pointerPrevPos__.y end |
#redraw ⇒ nil
Calls draw block to redraw frame.
464 465 466 |
# File 'lib/processing/context.rb', line 464 def redraw() @redraw__ = true end |
#setTitle(title) ⇒ nil
Changes title of window.
305 306 307 308 |
# File 'lib/processing/context.rb', line 305 def setTitle(title) @window__.title = title nil end |
#setup(&block) ⇒ nil
Defines setup block.
146 147 148 149 |
# File 'lib/processing/context.rb', line 146 def setup(&block) @window__.setup = block nil end |
#size(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
281 282 283 284 |
# File 'lib/processing/context.rb', line 281 def size(width, height, pixelDensity: self.pixelDensity) resizeCanvas__ :size, width, height, pixelDensity nil end |
#touchEnded(&block) ⇒ nil
Defines touchEnded block.
250 251 252 253 |
# File 'lib/processing/context.rb', line 250 def touchEnded(&block) @touchEndedBlock__ = block if block nil end |
#touches ⇒ Array
Returns array of touches
432 433 434 |
# File 'lib/processing/context.rb', line 432 def touches() @touches__ end |
#touchMoved(&block) ⇒ nil
Defines touchMoved block.
259 260 261 262 |
# File 'lib/processing/context.rb', line 259 def touchMoved(&block) @touchMovedBlock__ = block if block nil end |
#touchStarted(&block) ⇒ nil
Defines touchStarted block.
241 242 243 244 |
# File 'lib/processing/context.rb', line 241 def touchStarted(&block) @touchStartedBlock__ = block if block nil end |
#windowHeight ⇒ Numeric
Returns window height.
352 353 354 |
# File 'lib/processing/context.rb', line 352 def windowHeight() @window__.height end |
#windowWidth ⇒ Numeric
Returns window width.
344 345 346 |
# File 'lib/processing/context.rb', line 344 def windowWidth() @window__.width end |