khan academy js
Quick Jump: Shapes, Complex Shapes, Colors, Text, Transforms, Environment, Mouse, Keyboard, Math, Trig, Date/Time, Debugging, JavaScript
ProcessingJS
Shapes
See also: ellipseMode
, rectMode
, imageMode
, strokeCap
, bezierPoint
, bezierTangent
, curve
, curvePoint
, curveTangent
, curveTightness
Complex Shapes
See also: strokeJoin
, curveTightness
Colors
background(r, g, b)
Set the background colorfill(r, g, b)
Set the fill color for shapesnoFill()
Turn off fill for shapes
stroke(r, g, b)
Set the outline color for shapesstrokeWeight(thickness)
Change the thickness of lines and outlinesnoStroke()
Turn off outlines for shapes
color(r, g, b)
Store a color in a variableblendColor(c1, c2, MODE)
Blend two colors togetherlerpColor(c1, c2, amount)
Find color between 2 colors
See also: colorMode
, red
, green
, blue
, alpha
, hue
, saturation
, brightness
Text
text(text, x, y)
Draw some text
textFont(font, size*)
Changes the font of text
textSize(size)
Change the size of text
See also: textWidth
, textAscent
, textDescent
, textLeading
, textAlign
Transforms
rotate(angle)
Rotate shapes by an angle
scale(amount)
Scale shapes in both dimensions
translate(x, y)
Translate shapes by an offset
See also: pushMatrix
/popMatrix
, resetMatrix
, printMatrix
Environment
draw = function() { };
Called repeatedly during program execution.
playSound(sound)
Plays one of the allowed sounds.
See also: Program.assertEqual
, Program.restart
, frameRate(fps)
frameCount
, loop
/ noLoop
Mouse
mouseX, mouseY
Current coordinates of the mousepmouseX, pmouseY
Past coordinates of the mousemouseButton
Which button is pressedmouseIsPressed
Whether mouse is being pressed
mouseClicked = function() { };
Called when mouse is clickedmousePressed = function() { };
Called when mouse is pressedmouseReleased = function() { };
Called when mouse is released
mouseMoved = function() { };
Called when mouse is movedmouseDragged = function() { };
Called when mouse is draggedmouseOver = function() { };
Called when mouse moves over canvasmouseOut = function() { };
Called when mouse moves out of canvas
Keyboard
key
Number representing which key is pressedkeyCode
Represents when a special key is pressedkeyIsPressed
True if a key is being pressed, false otherwise
keyPressed = function() { };
Called when a key is pressedkeyReleased = function() { };
Called when a key is releasedkeyTyped = function() { };
Called when a key is typed
Math
random(low, high)
Generate a random numberdist(x1, y1, x2, y2)
Calculates the distance between two pointsconstrain(value, min, max)
Constrain value between min and maxmin(num1, num2)
Return the minimum of two numbersmax(num1, num2)
Return the maximum of two numbers
abs(num)
Take the absolute value of a numberlog(num)
Take the logarithm of a numberpow(num, exponent)
Raise a number to an exponentsq(num)
Square a numbersqrt(num)
Take the square root of a number
round(num)
Return nearest integerceil(num)
Return nearest integer of greater/equal valuefloor(num)
Return nearest integer of lesser/equal valuePVector(x, y)
An object that describes a 2-dimensional vector
See also: mag
, exp
, map
, norm
, lerp
, noise
, noiseDetail
, Random.nextGaussian
Trigonometry
cos(degrees)
Take the cosine of an angle
sin(degrees)
Take the sine of an angle
tan(degrees)
Take the tangent of an angle
See also: acos
, asin
, atan
, atan2
, radians
, degrees
, angleMode
Date & Time
millis()
Milliseconds elapsed since program start
Debugging
debug(arg1, arg2, ...)
Print to your browser's developer console
println(data)
Print to the canvas console
print(data)
Print to the canvas console
JavaScript
var drawWinston = function() { };
Define a new functionif (x < 20) { ... }
Only run code if a certain condition is true
while (x < 250) { ... }
Only run code while a certain condition is truefor (var i = 0; i < 8; i++) { }
Repeat code a fixed number of times
var array = [0, 1, 2, 3, 4];
Make an array of 5 numbers
Our documentation does not cover the many ways to use JavaScript. Learn more at:
This reference is based on ProcessingJS reference and is licensed under the CC BY-NC-SA 2.0 license.
khan academy js的更多相关文章
- Khan Academy
Khan Academy是一个免费的学院. 致力于教育改革. 百度百科:ohn Resig 百度百科有记者采访,采访内容比较有意思.
- 【转】React.js 概览
原文转自:http://segmentfault.com/blog/jiyinyiyong/1190000000693651 这里关于 React 的收集的消息的一个提纲, 具体内容看下边的链接,微博 ...
- [译] 所有你需要知道的关于完全理解 Node.js 事件循环及其度量
原文地址:All you need to know to really understand the Node.js Event Loop and its Metrics 原文作者:Daniel Kh ...
- swift开源项目精选
Swift 开源项目精选-v1.0 2016-03-07 22:11 542人阅读 评论(0) 收藏 举报 分类: iOS(55) Swift(4) 目录(?)[+] 转自 http: ...
- [No000026]365种创业、办公、和生活成长的精华资源
只需要具备以下技能,人人都可以成为企业家:经得起失败的考验,思维活跃,新点子不断,能够脚踏实地把新点子转化为产品,并在这个过程中坚持不懈,百折不挠,即使跌倒了,也要及时从失败中学习,迅速投入到下一次冒 ...
- 必须关注的25位知名JavaScript开发者
必须关注的25位知名JavaScript开发者 发表于2012-08-07 17:30| 16215次阅读| 来源Crossrider Blog| 46 条评论| 作者Crossrider Blog ...
- Awesome Algorithms
Awesome Algorithms A curated list of awesome places to learn and/or practice algorithms. Inspired by ...
- [转]Angular, Backbone, or Ember: Which is Best for your Build?
In order to choose which framework is right for your build, we've asked four important questions of ...
- JavaScript 资源装备
书籍 随着JS的普及,大家能获取到的JS书籍实在太多了,但是在我看来只有很少一部分JS书籍可以提供够新够有意思的内容.以下是我看过之后,觉得很值得推荐给大家的: JavaScript高级程序设计 作者 ...
随机推荐
- Spring总结以及在面试中的一些问题
Spring总结以及在面试中的一些问题. 1.谈谈你对spring IOC和DI的理解,它们有什么区别? IoC Inverse of Control 反转控制的概念,就是将原本在程序中手动创建Use ...
- Thinkphp5 对接百度云对象存储 BOS (上传、删除)
首先下载SDK包可以在 官网下载,或者在项目根目录使用composer . composer require baidubce/bce-sdk-php 压缩包里面有五个文件,实际运用到只有两个,然后放 ...
- while 循环,格式化输出和运算编码
今日内容 1.while循环 while Ture: content = input ("请输入你要喷的内容",输入Q退出) if ...
- Invoice Helper
using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using Microsoft.Crm.Sdk.Messag ...
- 大数据学习--day03(运算符、流程控制语句)
运算符.流程控制语句 自增自减容易出错的地方: 扩展的赋值运算符 a+=b 等同于 a = a+b; 扩展的赋值运算符 隐含了一个类型的强制转换 & && 有何区别 & ...
- 树莓派编译程序时报错:virtual memory exhausted: Cannot allocate memory
一.原因分析: 树莓派内存太小,编译程序会出现virtual memory exhausted: Cannot allocate memory的问题,可以用swap扩展内存的方法. 二.解决方法: 安 ...
- HI-2110的657sp3版本应用笔记之TUP
1. TUP是什么? TUP是华为的搞的一套封装了标准Coap的函数,底层是Coap,上层是华为封装的一层收发函数,用来简化Coap的收发流程,最终只用6个函数搞定,不用懂Coap就可以的. 2. T ...
- MySQL不能连接本地数据库10061
可能的原因是本地服务器没有启动,在安装配置MySQL时,我去掉了开机自动开启,所以开机之后出现了错误10061 解决办法: 一.计算机右击选择管理 二.选择服务,找到MySQL,右击手动,选择启动服务
- hdu5305 Friends(dfs,多校题)
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Sub ...
- 怎么设计好移动APP测试用例
软件测试工作中我们需要不断的储备和总结自己的知识和经验,怎么设计好移动APP测试用例?如:手机.平板.智能设备,并在特定网络环境下. 我们需要关注的功能点,容易出错的位置,这将对我们整个测试过程起着至 ...