Top Level Namespace
Defined Under Namespace
Constant Summary collapse
- P2D =
The default, two-dimensional renderer.
'p2d'- WEBGL =
One of the two render modes in p5.js: P2D (default renderer) and WEBGL Enables 3D render by introducing the third dimension: Z
'webgl'- ARROW =
ENVIRONMENT
'default'- CROSS =
'crosshair'- HAND =
'pointer'- MOVE =
'move'- TEXT =
'text'- WAIT =
'wait'- HALF_PI =
HALF_PI is a mathematical constant with the value 1.57079632679489661923. It is half the ratio of the circumference of a circle to its diameter. It is useful in combination with the trigonometric functions <a href=“#/p5/sin”>sin()</a> and <a href=“#/p5/cos”>cos()</a>.
_PI / 2
- PI =
PI is a mathematical constant with the value 3.14159265358979323846. It is the ratio of the circumference of a circle to its diameter. It is useful in combination with the trigonometric functions <a href=“#/p5/sin”>sin()</a> and <a href=“#/p5/cos”>cos()</a>.
_PI- QUARTER_PI =
QUARTER_PI is a mathematical constant with the value 0.7853982. It is one quarter the ratio of the circumference of a circle to its diameter. It is useful in combination with the trigonometric functions <a href=“#/p5/sin”>sin()</a> and <a href=“#/p5/cos”>cos()</a>.
_PI / 4
- TAU =
TAU is an alias for TWO_PI, a mathematical constant with the value 6.28318530717958647693. It is twice the ratio of the circumference of a circle to its diameter. It is useful in combination with the trigonometric functions <a href=“#/p5/sin”>sin()</a> and <a href=“#/p5/cos”>cos()</a>.
_PI * 2
- TWO_PI =
TWO_PI is a mathematical constant with the value 6.28318530717958647693. It is twice the ratio of the circumference of a circle to its diameter. It is useful in combination with the trigonometric functions <a href=“#/p5/sin”>sin()</a> and <a href=“#/p5/cos”>cos()</a>.
_PI * 2
- DEGREES =
Constant to be used with the <a href=“#/p5/angleMode”>angleMode()</a> function, to set the mode in which p5.js interprets and calculates angles (either DEGREES or RADIANS).
'degrees'- RADIANS =
Constant to be used with the <a href=“#/p5/angleMode”>angleMode()</a> function, to set the mode in which p5.js interprets and calculates angles (either RADIANS or DEGREES).
'radians'- DEG_TO_RAD =
_PI / 180.0
- RAD_TO_DEG =
180.0 / _PI
- CORNER =
'corner'- CORNERS =
'corners'- RADIUS =
'radius'- RIGHT =
'right'- LEFT =
'left'- CENTER =
'center'- TOP =
'top'- BOTTOM =
'bottom'- BASELINE =
'alphabetic'- POINTS =
0x0000- LINES =
0x0001- LINE_STRIP =
0x0003- LINE_LOOP =
0x0002- TRIANGLES =
0x0004- TRIANGLE_FAN =
0x0006- TRIANGLE_STRIP =
0x0005- QUADS =
'quads'- QUAD_STRIP =
'quad_strip'- TESS =
'tess'- CLOSE =
'close'- OPEN =
'open'- CHORD =
'chord'- PIE =
'pie'- PROJECT =
PEND: careful this is counterintuitive
'square'- SQUARE =
'butt'- ROUND =
'round'- BEVEL =
'bevel'- MITER =
'miter'- RGB =
COLOR
'rgb'- HSB =
<a href=“learnui.design/blog/the-hsb-color-system-practicioners-primer.html”>HSB</a>.
'hsb'- HSL =
'hsl'- AUTO =
AUTO allows us to automatically set the width or height of an element (but not both), based on the current height and width of the element. Only one parameter can be passed to the <a href=“/#/p5.Element/size”>size</a> function as AUTO, at a time.
'auto'- ALT =
INPUT
18- BACKSPACE =
8- CONTROL =
17- DELETE =
46- DOWN_ARROW =
40- ENTER =
13- ESCAPE =
27- LEFT_ARROW =
37- OPTION =
18- RETURN =
13- RIGHT_ARROW =
39- SHIFT =
16- TAB =
9- UP_ARROW =
38- BLEND =
RENDERING
'source-over'- REMOVE =
'destination-out'- ADD =
'lighter'- DARKEST =
SUBTRACT: ‘subtract’, #
'darken'- LIGHTEST =
'lighten'- DIFFERENCE =
'difference'- SUBTRACT =
'subtract'- EXCLUSION =
'exclusion'- MULTIPLY =
'multiply'- SCREEN =
'screen'- REPLACE =
'copy'- OVERLAY =
'overlay'- HARD_LIGHT =
'hard-light'- SOFT_LIGHT =
'soft-light'- DODGE =
'color-dodge'- BURN =
'color-burn'- THRESHOLD =
FILTERS
'threshold'- GRAY =
'gray'- OPAQUE =
'opaque'- INVERT =
'invert'- POSTERIZE =
'posterize'- DILATE =
'dilate'- ERODE =
'erode'- BLUR =
'blur'- NORMAL =
TYPOGRAPHY
'normal'- ITALIC =
'italic'- BOLD =
'bold'- BOLDITALIC =
'bold italic'- CHAR =
'CHAR'- WORD =
'WORD'- LINEAR =
VERTICES
'linear'- QUADRATIC =
'quadratic'- BEZIER =
'bezier'- CURVE =
'curve'- STROKE =
WEBGL DRAWMODES
'stroke'- FILL =
'fill'- TEXTURE =
'texture'- IMMEDIATE =
'immediate'- IMAGE =
WEBGL TEXTURE MODE NORMAL already exists for typography
'image'- NEAREST =
WEBGL TEXTURE WRAP AND FILTERING LINEAR already exists above
'nearest'- REPEAT =
'repeat'- CLAMP =
'clamp'- MIRROR =
'mirror'- LANDSCAPE =
DEVICE-ORIENTATION
'landscape'- PORTRAIT =
'portrait'- GRID =
'grid'- AXES =
'axes'- LABEL =
'label'- FALLBACK =
'fallback'- CONTAIN =
'contain'- COVER =
'cover'
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/p5rb_cli/static/p5editor.rb', line 258 def method_missing(sym, *args, &block) return super unless $p5.respond_to?(:[]) ret = $p5[sym] case ret.typeof when "undefined" # str = sym.to_s # if str[-1] == "=" # $p5[str.chop.to_sym] = args.first # return args.first # end super when "function" $p5.call(sym, *args, &block).to_r else ret.to_r end end |
Instance Method Details
#run_web_app(script_file) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/p5rb_cli/web_app.rb', line 3 def run_web_app(script_file) if script_file.nil? || !File.exist?(script_file) puts "Not found script file: #{script_file}" return end root = File.join(File.dirname(script_file)) server = WEBrick::HTTPServer.new( Port: 8000, DocumentRoot: root ) static_root = File.join(File.dirname(__FILE__), "static") server.mount_proc '/' do |req, res| case req.path when "/" || "/index.html" res.body = File.read(File.join(static_root, 'index.html')) res.content_type = 'text/html' when "/p5editor.js" res.body = File.read(File.join(static_root, 'p5editor.js')) res.content_type = 'application/javascript' when "/p5editor.rb" res.body = File.read(File.join(static_root, 'p5editor.rb')) res.content_type = 'application/ruby' when "/style.css" res.body = File.read(File.join(static_root, 'style.css')) res.content_type = 'text/css' when "/main.rb" res.body = File.read(script_file) res.content_type = 'application/ruby' else path = File.join(File.dirname(script_file), req.path) if File.exist?(path) res.body = File.binread(path) res.content_type = case File.extname(path) when ".png" then 'image/png' when ".jpg" then 'image/jpeg' else 'application/octet-stream' end else res.body = "Not Found" res.status = 404 end end end trap('INT') { server.shutdown } puts "Serving at http://localhost:8000/" server.start end |