Class: Processing::Context

Inherits:
Object
  • Object
show all
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

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

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.



350
351
352
353
# File 'lib/processing/context.rb', line 350

def createCanvas(width, height, pixelDensity: self.pixelDensity)
  resizeCanvas__ :createCanvas, width, height, pixelDensity
  nil
end

#displayDensityNumeric

Returns the pixel density of the display.



405
406
407
# File 'lib/processing/context.rb', line 405

def displayDensity()
  @window__.painter.pixel_density
end

#displayHeightNumeric

Returns the height of the display.



397
398
399
# File 'lib/processing/context.rb', line 397

def displayHeight()
  @window__.screen.height
end

#displayWidthNumeric

Returns the width of the display.



389
390
391
# File 'lib/processing/context.rb', line 389

def displayWidth()
  @window__.screen.width
end

#draw(&block) ⇒ nil

Defines draw block.



198
199
200
201
# File 'lib/processing/context.rb', line 198

def draw(&block)
  @drawBlock__ = block if block
  nil
end

#focusedBoolean

Returns weather the window is active or not.



480
481
482
# File 'lib/processing/context.rb', line 480

def focused()
  @window__.active?
end

#frameCountInteger

Returns the number of frames since the program started.



488
489
490
# File 'lib/processing/context.rb', line 488

def frameCount()
  @frameCount__
end

#frameRateFloat

Returns the number of frames per second.



496
497
498
# File 'lib/processing/context.rb', line 496

def frameRate()
  @window__.event.fps
end

#keyString

Returns the last key that was pressed or released.



504
505
506
# File 'lib/processing/context.rb', line 504

def key()
  @key__
end

#keyCodeSymbol

Returns the last key code that was pressed or released.



512
513
514
# File 'lib/processing/context.rb', line 512

def keyCode()
  @keyCode__
end

#keyPressed(&block) ⇒ Boolean

Defines keyPressed block.



207
208
209
210
# File 'lib/processing/context.rb', line 207

def keyPressed(&block)
  @keyPressedBlock__ = block if block
  not @keysPressed__.empty?
end

#keyReleased(&block) ⇒ nil

Defines keyReleased block.



216
217
218
219
# File 'lib/processing/context.rb', line 216

def keyReleased(&block)
  @keyReleasedBlock__ = block if block
  nil
end

#keyTyped(&block) ⇒ nil

Defines keyTyped block.



225
226
227
228
# File 'lib/processing/context.rb', line 225

def keyTyped(&block)
  @keyTypedBlock__ = block if block
  nil
end

#loopnil

Enables calling draw block on every frame.



576
577
578
# File 'lib/processing/context.rb', line 576

def loop()
  @loop__ = true
end

#motion(&block) ⇒ nil

Defines motion block.



324
325
326
327
# File 'lib/processing/context.rb', line 324

def motion(&block)
  @motionBlock__ = block if block
  nil
end

#motionGravityVector

Returns vector for real world gravity



568
569
570
# File 'lib/processing/context.rb', line 568

def motionGravity()
  @motionGravity__
end

#mouseButtonNumeric

Returns which mouse button was pressed



552
553
554
# File 'lib/processing/context.rb', line 552

def mouseButton()
  ((@pointersPressed__ + @pointersReleased__) & [LEFT, RIGHT, CENTER]).last
end

#mouseClicked(&block) ⇒ nil

Defines mouseClicked block.



270
271
272
273
# File 'lib/processing/context.rb', line 270

def mouseClicked(&block)
  @mouseClickedBlock__ = block if block
  nil
end

#mouseDragged(&block) ⇒ nil

Defines mouseDragged block.



261
262
263
264
# File 'lib/processing/context.rb', line 261

def mouseDragged(&block)
  @mouseDraggedBlock__ = block if block
  nil
end

#mouseMoved(&block) ⇒ nil

Defines mouseMoved block.



252
253
254
255
# File 'lib/processing/context.rb', line 252

def mouseMoved(&block)
  @mouseMovedBlock__ = block if block
  nil
end

#mousePressed(&block) ⇒ Boolean

Defines mousePressed block.



234
235
236
237
# File 'lib/processing/context.rb', line 234

def mousePressed(&block)
  @mousePressedBlock__ = block if block
  not @pointersPressed__.empty?
end

#mouseReleased(&block) ⇒ nil

Defines mouseReleased block.



243
244
245
246
# File 'lib/processing/context.rb', line 243

def mouseReleased(&block)
  @mouseReleasedBlock__ = block if block
  nil
end

#mouseXNumeric

Returns mouse x position



520
521
522
# File 'lib/processing/context.rb', line 520

def mouseX()
  @pointer__&.x || 0
end

#mouseYNumeric

Returns mouse y position



528
529
530
# File 'lib/processing/context.rb', line 528

def mouseY()
  @pointer__&.y || 0
end

#noLoopnil

Disables calling draw block on every frame.



584
585
586
# File 'lib/processing/context.rb', line 584

def noLoop()
  @loop__ = false
end

#pixelDensity(density = nil) ⇒ Numeric

Changes and returns canvas pixel density.



372
373
374
375
# File 'lib/processing/context.rb', line 372

def pixelDensity(density = nil)
  resizeCanvas__ :pixelDensity, width, height, density if density
  @painter__.pixel_density
end

#pmouseXNumeric

Returns mouse x position in previous frame



536
537
538
# File 'lib/processing/context.rb', line 536

def pmouseX()
  @pointerPrev__&.x || 0
end

#pmouseYNumeric

Returns mouse y position in previous frame



544
545
546
# File 'lib/processing/context.rb', line 544

def pmouseY()
  @pointerPrev__&.y || 0
end

#redrawnil

Calls draw block to redraw frame.



592
593
594
# File 'lib/processing/context.rb', line 592

def redraw()
  @redraw__ = true
end

#setTitle(title) ⇒ nil

Changes title of window.



361
362
363
364
# File 'lib/processing/context.rb', line 361

def setTitle(title)
  @window__.title = title
  nil
end

#setup(&block) ⇒ nil

Defines setup block.



170
171
172
173
# File 'lib/processing/context.rb', line 170

def setup(&block)
  @window__.setup = block
  nil
end

#size(width, height, pixelDensity: self.pixelDensity) ⇒ nil

Changes canvas size.



337
338
339
340
# File 'lib/processing/context.rb', line 337

def size(width, height, pixelDensity: self.pixelDensity)
  resizeCanvas__ :size, width, height, pixelDensity
  nil
end

#touchEnded(&block) ⇒ nil

Defines touchEnded block.



288
289
290
291
# File 'lib/processing/context.rb', line 288

def touchEnded(&block)
  @touchEndedBlock__ = block if block
  nil
end

#touchesArray

Returns array of touches



560
561
562
# File 'lib/processing/context.rb', line 560

def touches()
  @touches__
end

#touchMoved(&block) ⇒ nil

Defines touchMoved block.



297
298
299
300
# File 'lib/processing/context.rb', line 297

def touchMoved(&block)
  @touchMovedBlock__ = block if block
  nil
end

#touchStarted(&block) ⇒ nil

Defines touchStarted block.



279
280
281
282
# File 'lib/processing/context.rb', line 279

def touchStarted(&block)
  @touchStartedBlock__ = block if block
  nil
end

#windowHeightNumeric

Returns the height of the window.



472
473
474
# File 'lib/processing/context.rb', line 472

def windowHeight()
  @window__.height
end

#windowMove(x, y) ⇒ nil

Move the position of the window.



416
417
418
419
# File 'lib/processing/context.rb', line 416

def windowMove(x, y)
  @window__.pos = [x, y]
  nil
end

#windowMoved(&block) ⇒ nil

Defines windowMoved block.



306
307
308
309
# File 'lib/processing/context.rb', line 306

def windowMoved(&block)
  @windowMovedBlock__ = block if block
  nil
end

#windowResizable(resizable) ⇒ nil

Makes the window resizable or not.



439
440
441
442
# File 'lib/processing/context.rb', line 439

def windowResizable(resizable)
  @window__.resizable = resizable
  nil
end

#windowResize(width, height) ⇒ nil

Sets the size of the window.



428
429
430
431
# File 'lib/processing/context.rb', line 428

def windowResize(width, height)
  @window__.size = [width, height]
  nil
end

#windowResized(&block) ⇒ nil

Defines windowResized block.



315
316
317
318
# File 'lib/processing/context.rb', line 315

def windowResized(&block)
  @windowResizedBlock__ = block if block
  nil
end

#windowWidthNumeric

Returns the width of the window.



464
465
466
# File 'lib/processing/context.rb', line 464

def windowWidth()
  @window__.width
end

#windowXNumeric

Returns the x position of the window.



448
449
450
# File 'lib/processing/context.rb', line 448

def windowX()
  @window__.x
end

#windowYNumeric

Returns the y position of the window.



456
457
458
# File 'lib/processing/context.rb', line 456

def windowY()
  @window__.y
end