Class: Processing::Context
- Inherits:
-
Object
- Object
- Processing::Context
- Includes:
- GraphicsContext, Xot::Inspectable
- Defined in:
- lib/processing/context.rb
Overview
Processing context
Constant Summary collapse
- Capture =
Processing::Capture
- Font =
Processing::Font
- Graphics =
Processing::Graphics
- Image =
Processing::Image
- Shader =
Processing::Shader
- TextBounds =
Processing::TextBounds
- Touch =
Processing::Touch
- Vector =
Processing::Vector
- PORTRAIT =
Portrait for windowOrientation
:portrait- LANDSCAPE =
Landscape for windowOrientation
:landscape
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
Instance Method Summary collapse
-
#createCanvas(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
-
#displayDensity ⇒ Numeric
Returns the pixel density of the display.
-
#displayHeight ⇒ Numeric
Returns the height of the display.
-
#displayWidth ⇒ Numeric
Returns the width of the display.
-
#draw(&block) ⇒ nil
Defines draw block.
-
#focused ⇒ Boolean
Returns weather the window is active or not.
-
#frameCount ⇒ Integer
Returns the number of frames since the program started.
-
#frameRate ⇒ Float
Returns the 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 the height of the window.
-
#windowMove(x, y) ⇒ nil
Move the position of the window.
-
#windowMoved(&block) ⇒ nil
Defines windowMoved block.
-
#windowOrientation(*orientations) ⇒ nil
Sets window orientation mask.
-
#windowResizable(resizable) ⇒ nil
Makes the window resizable or not.
-
#windowResize(width, height) ⇒ nil
Sets the size of the window.
-
#windowResized(&block) ⇒ nil
Defines windowResized block.
-
#windowWidth ⇒ Numeric
Returns the width of the window.
-
#windowX ⇒ Numeric
Returns the x position of the window.
-
#windowY ⇒ Numeric
Returns the y position of the window.
Methods included from GraphicsContext
#abs, #acos, #alpha, #angleMode, #arc, #asin, #atan, #atan2, #background, #bezier, #blend, #blendMode, #blue, #ceil, #circle, #clip, #color, #colorMode, #constrain, #copy, #cos, #createCapture, #createGraphics, #createImage, #createShader, #createVector, #curve, #degrees, #dist, #ellipse, #ellipseMode, #exp, #fill, #filter, #floor, #green, #height, #image, #imageMode, #lerp, #lerpColor, #line, #loadImage, #loadShader, #log, #mag, #map, #max, #min, #noClip, #noFill, #noStroke, #noTint, #noise, #norm, #pixelHeight, #pixelWidth, #point, #pop, #popMatrix, #popStyle, #pow, #push, #pushMatrix, #pushStyle, #quad, #radians, #random, #rect, #rectMode, #red, #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
Instance Method Details
#createCanvas(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
358 359 360 361 |
# File 'lib/processing/context.rb', line 358 def createCanvas(width, height, pixelDensity: self.pixelDensity) resizeCanvas__ :createCanvas, width, height, pixelDensity nil end |
#displayDensity ⇒ Numeric
Returns the pixel density of the display.
413 414 415 |
# File 'lib/processing/context.rb', line 413 def displayDensity() @window__.painter.pixel_density end |
#displayHeight ⇒ Numeric
Returns the height of the display.
405 406 407 |
# File 'lib/processing/context.rb', line 405 def displayHeight() @window__.screen.height end |
#displayWidth ⇒ Numeric
Returns the width of the display.
397 398 399 |
# File 'lib/processing/context.rb', line 397 def displayWidth() @window__.screen.width end |
#draw(&block) ⇒ nil
Defines draw block.
206 207 208 209 |
# File 'lib/processing/context.rb', line 206 def draw(&block) @drawBlock__ = block if block nil end |
#focused ⇒ Boolean
Returns weather the window is active or not.
498 499 500 |
# File 'lib/processing/context.rb', line 498 def focused() @window__.active? end |
#frameCount ⇒ Integer
Returns the number of frames since the program started.
506 507 508 |
# File 'lib/processing/context.rb', line 506 def frameCount() @frameCount__ end |
#frameRate ⇒ Float
Returns the number of frames per second.
514 515 516 |
# File 'lib/processing/context.rb', line 514 def frameRate() @window__.event.fps end |
#key ⇒ String
Returns the last key that was pressed or released.
522 523 524 |
# File 'lib/processing/context.rb', line 522 def key() @key__ end |
#keyCode ⇒ Symbol
Returns the last key code that was pressed or released.
530 531 532 |
# File 'lib/processing/context.rb', line 530 def keyCode() @keyCode__ end |
#keyPressed(&block) ⇒ Boolean
Defines keyPressed block.
215 216 217 218 |
# File 'lib/processing/context.rb', line 215 def keyPressed(&block) @keyPressedBlock__ = block if block not @keysPressed__.empty? end |
#keyReleased(&block) ⇒ nil
Defines keyReleased block.
224 225 226 227 |
# File 'lib/processing/context.rb', line 224 def keyReleased(&block) @keyReleasedBlock__ = block if block nil end |
#keyTyped(&block) ⇒ nil
Defines keyTyped block.
233 234 235 236 |
# File 'lib/processing/context.rb', line 233 def keyTyped(&block) @keyTypedBlock__ = block if block nil end |
#loop ⇒ nil
Enables calling draw block on every frame.
594 595 596 |
# File 'lib/processing/context.rb', line 594 def loop() @loop__ = true end |
#motion(&block) ⇒ nil
Defines motion block.
332 333 334 335 |
# File 'lib/processing/context.rb', line 332 def motion(&block) @motionBlock__ = block if block nil end |
#motionGravity ⇒ Vector
Returns vector for real world gravity
586 587 588 |
# File 'lib/processing/context.rb', line 586 def motionGravity() @motionGravity__ end |
#mouseButton ⇒ Numeric
Returns which mouse button was pressed
570 571 572 |
# File 'lib/processing/context.rb', line 570 def mouseButton() ((@pointersPressed__ + @pointersReleased__) & [LEFT, RIGHT, CENTER]).last end |
#mouseClicked(&block) ⇒ nil
Defines mouseClicked block.
278 279 280 281 |
# File 'lib/processing/context.rb', line 278 def mouseClicked(&block) @mouseClickedBlock__ = block if block nil end |
#mouseDragged(&block) ⇒ nil
Defines mouseDragged block.
269 270 271 272 |
# File 'lib/processing/context.rb', line 269 def mouseDragged(&block) @mouseDraggedBlock__ = block if block nil end |
#mouseMoved(&block) ⇒ nil
Defines mouseMoved block.
260 261 262 263 |
# File 'lib/processing/context.rb', line 260 def mouseMoved(&block) @mouseMovedBlock__ = block if block nil end |
#mousePressed(&block) ⇒ Boolean
Defines mousePressed block.
242 243 244 245 |
# File 'lib/processing/context.rb', line 242 def mousePressed(&block) @mousePressedBlock__ = block if block not @pointersPressed__.empty? end |
#mouseReleased(&block) ⇒ nil
Defines mouseReleased block.
251 252 253 254 |
# File 'lib/processing/context.rb', line 251 def mouseReleased(&block) @mouseReleasedBlock__ = block if block nil end |
#mouseX ⇒ Numeric
Returns mouse x position
538 539 540 |
# File 'lib/processing/context.rb', line 538 def mouseX() @pointer__&.x || 0 end |
#mouseY ⇒ Numeric
Returns mouse y position
546 547 548 |
# File 'lib/processing/context.rb', line 546 def mouseY() @pointer__&.y || 0 end |
#noLoop ⇒ nil
Disables calling draw block on every frame.
602 603 604 |
# File 'lib/processing/context.rb', line 602 def noLoop() @loop__ = false end |
#pixelDensity(density = nil) ⇒ Numeric
Changes and returns canvas pixel density.
380 381 382 383 |
# File 'lib/processing/context.rb', line 380 def pixelDensity(density = nil) resizeCanvas__ :pixelDensity, width, height, density if density @painter__.pixel_density end |
#pmouseX ⇒ Numeric
Returns mouse x position in previous frame
554 555 556 |
# File 'lib/processing/context.rb', line 554 def pmouseX() @pointerPrev__&.x || 0 end |
#pmouseY ⇒ Numeric
Returns mouse y position in previous frame
562 563 564 |
# File 'lib/processing/context.rb', line 562 def pmouseY() @pointerPrev__&.y || 0 end |
#redraw ⇒ nil
Calls draw block to redraw frame.
610 611 612 |
# File 'lib/processing/context.rb', line 610 def redraw() @redraw__ = true end |
#setTitle(title) ⇒ nil
Changes title of window.
369 370 371 372 |
# File 'lib/processing/context.rb', line 369 def setTitle(title) @window__.title = title nil end |
#setup(&block) ⇒ nil
Defines setup block.
178 179 180 181 |
# File 'lib/processing/context.rb', line 178 def setup(&block) @window__.setup = block if block nil end |
#size(width, height, pixelDensity: self.pixelDensity) ⇒ nil
Changes canvas size.
345 346 347 348 |
# File 'lib/processing/context.rb', line 345 def size(width, height, pixelDensity: self.pixelDensity) resizeCanvas__ :size, width, height, pixelDensity nil end |
#touchEnded(&block) ⇒ nil
Defines touchEnded block.
296 297 298 299 |
# File 'lib/processing/context.rb', line 296 def touchEnded(&block) @touchEndedBlock__ = block if block nil end |
#touches ⇒ Array
Returns array of touches
578 579 580 |
# File 'lib/processing/context.rb', line 578 def touches() @touches__ end |
#touchMoved(&block) ⇒ nil
Defines touchMoved block.
305 306 307 308 |
# File 'lib/processing/context.rb', line 305 def touchMoved(&block) @touchMovedBlock__ = block if block nil end |
#touchStarted(&block) ⇒ nil
Defines touchStarted block.
287 288 289 290 |
# File 'lib/processing/context.rb', line 287 def touchStarted(&block) @touchStartedBlock__ = block if block nil end |
#windowHeight ⇒ Numeric
Returns the height of the window.
490 491 492 |
# File 'lib/processing/context.rb', line 490 def windowHeight() @window__.height end |
#windowMove(x, y) ⇒ nil
Move the position of the window.
424 425 426 427 |
# File 'lib/processing/context.rb', line 424 def windowMove(x, y) @window__.pos = [x, y] nil end |
#windowMoved(&block) ⇒ nil
Defines windowMoved block.
314 315 316 317 |
# File 'lib/processing/context.rb', line 314 def windowMoved(&block) @windowMovedBlock__ = block if block nil end |
#windowOrientation(*orientations) ⇒ nil
Sets window orientation mask
458 459 460 |
# File 'lib/processing/context.rb', line 458 def windowOrientation (*orientations) @window__.orientations = orientations.flatten.uniq end |
#windowResizable(resizable) ⇒ nil
Makes the window resizable or not.
447 448 449 450 |
# File 'lib/processing/context.rb', line 447 def windowResizable(resizable) @window__.resizable = resizable nil end |
#windowResize(width, height) ⇒ nil
Sets the size of the window.
436 437 438 439 |
# File 'lib/processing/context.rb', line 436 def windowResize(width, height) @window__.size = [width, height] nil end |
#windowResized(&block) ⇒ nil
Defines windowResized block.
323 324 325 326 |
# File 'lib/processing/context.rb', line 323 def windowResized(&block) @windowResizedBlock__ = block if block nil end |
#windowWidth ⇒ Numeric
Returns the width of the window.
482 483 484 |
# File 'lib/processing/context.rb', line 482 def windowWidth() @window__.width end |
#windowX ⇒ Numeric
Returns the x position of the window.
466 467 468 |
# File 'lib/processing/context.rb', line 466 def windowX() @window__.x end |
#windowY ⇒ Numeric
Returns the y position of the window.
474 475 476 |
# File 'lib/processing/context.rb', line 474 def windowY() @window__.y end |