processing.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. /*
  2. Language: Processing
  3. Description: Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts.
  4. Author: Erik Paluka <erik.paluka@gmail.com>
  5. Website: https://processing.org
  6. Category: graphics
  7. */
  8. function processing(hljs) {
  9. const regex = hljs.regex;
  10. const BUILT_INS = [
  11. "displayHeight",
  12. "displayWidth",
  13. "mouseY",
  14. "mouseX",
  15. "mousePressed",
  16. "pmouseX",
  17. "pmouseY",
  18. "key",
  19. "keyCode",
  20. "pixels",
  21. "focused",
  22. "frameCount",
  23. "frameRate",
  24. "height",
  25. "width",
  26. "size",
  27. "createGraphics",
  28. "beginDraw",
  29. "createShape",
  30. "loadShape",
  31. "PShape",
  32. "arc",
  33. "ellipse",
  34. "line",
  35. "point",
  36. "quad",
  37. "rect",
  38. "triangle",
  39. "bezier",
  40. "bezierDetail",
  41. "bezierPoint",
  42. "bezierTangent",
  43. "curve",
  44. "curveDetail",
  45. "curvePoint",
  46. "curveTangent",
  47. "curveTightness",
  48. "shape",
  49. "shapeMode",
  50. "beginContour",
  51. "beginShape",
  52. "bezierVertex",
  53. "curveVertex",
  54. "endContour",
  55. "endShape",
  56. "quadraticVertex",
  57. "vertex",
  58. "ellipseMode",
  59. "noSmooth",
  60. "rectMode",
  61. "smooth",
  62. "strokeCap",
  63. "strokeJoin",
  64. "strokeWeight",
  65. "mouseClicked",
  66. "mouseDragged",
  67. "mouseMoved",
  68. "mousePressed",
  69. "mouseReleased",
  70. "mouseWheel",
  71. "keyPressed",
  72. "keyPressedkeyReleased",
  73. "keyTyped",
  74. "print",
  75. "println",
  76. "save",
  77. "saveFrame",
  78. "day",
  79. "hour",
  80. "millis",
  81. "minute",
  82. "month",
  83. "second",
  84. "year",
  85. "background",
  86. "clear",
  87. "colorMode",
  88. "fill",
  89. "noFill",
  90. "noStroke",
  91. "stroke",
  92. "alpha",
  93. "blue",
  94. "brightness",
  95. "color",
  96. "green",
  97. "hue",
  98. "lerpColor",
  99. "red",
  100. "saturation",
  101. "modelX",
  102. "modelY",
  103. "modelZ",
  104. "screenX",
  105. "screenY",
  106. "screenZ",
  107. "ambient",
  108. "emissive",
  109. "shininess",
  110. "specular",
  111. "add",
  112. "createImage",
  113. "beginCamera",
  114. "camera",
  115. "endCamera",
  116. "frustum",
  117. "ortho",
  118. "perspective",
  119. "printCamera",
  120. "printProjection",
  121. "cursor",
  122. "frameRate",
  123. "noCursor",
  124. "exit",
  125. "loop",
  126. "noLoop",
  127. "popStyle",
  128. "pushStyle",
  129. "redraw",
  130. "binary",
  131. "boolean",
  132. "byte",
  133. "char",
  134. "float",
  135. "hex",
  136. "int",
  137. "str",
  138. "unbinary",
  139. "unhex",
  140. "join",
  141. "match",
  142. "matchAll",
  143. "nf",
  144. "nfc",
  145. "nfp",
  146. "nfs",
  147. "split",
  148. "splitTokens",
  149. "trim",
  150. "append",
  151. "arrayCopy",
  152. "concat",
  153. "expand",
  154. "reverse",
  155. "shorten",
  156. "sort",
  157. "splice",
  158. "subset",
  159. "box",
  160. "sphere",
  161. "sphereDetail",
  162. "createInput",
  163. "createReader",
  164. "loadBytes",
  165. "loadJSONArray",
  166. "loadJSONObject",
  167. "loadStrings",
  168. "loadTable",
  169. "loadXML",
  170. "open",
  171. "parseXML",
  172. "saveTable",
  173. "selectFolder",
  174. "selectInput",
  175. "beginRaw",
  176. "beginRecord",
  177. "createOutput",
  178. "createWriter",
  179. "endRaw",
  180. "endRecord",
  181. "PrintWritersaveBytes",
  182. "saveJSONArray",
  183. "saveJSONObject",
  184. "saveStream",
  185. "saveStrings",
  186. "saveXML",
  187. "selectOutput",
  188. "popMatrix",
  189. "printMatrix",
  190. "pushMatrix",
  191. "resetMatrix",
  192. "rotate",
  193. "rotateX",
  194. "rotateY",
  195. "rotateZ",
  196. "scale",
  197. "shearX",
  198. "shearY",
  199. "translate",
  200. "ambientLight",
  201. "directionalLight",
  202. "lightFalloff",
  203. "lights",
  204. "lightSpecular",
  205. "noLights",
  206. "normal",
  207. "pointLight",
  208. "spotLight",
  209. "image",
  210. "imageMode",
  211. "loadImage",
  212. "noTint",
  213. "requestImage",
  214. "tint",
  215. "texture",
  216. "textureMode",
  217. "textureWrap",
  218. "blend",
  219. "copy",
  220. "filter",
  221. "get",
  222. "loadPixels",
  223. "set",
  224. "updatePixels",
  225. "blendMode",
  226. "loadShader",
  227. "PShaderresetShader",
  228. "shader",
  229. "createFont",
  230. "loadFont",
  231. "text",
  232. "textFont",
  233. "textAlign",
  234. "textLeading",
  235. "textMode",
  236. "textSize",
  237. "textWidth",
  238. "textAscent",
  239. "textDescent",
  240. "abs",
  241. "ceil",
  242. "constrain",
  243. "dist",
  244. "exp",
  245. "floor",
  246. "lerp",
  247. "log",
  248. "mag",
  249. "map",
  250. "max",
  251. "min",
  252. "norm",
  253. "pow",
  254. "round",
  255. "sq",
  256. "sqrt",
  257. "acos",
  258. "asin",
  259. "atan",
  260. "atan2",
  261. "cos",
  262. "degrees",
  263. "radians",
  264. "sin",
  265. "tan",
  266. "noise",
  267. "noiseDetail",
  268. "noiseSeed",
  269. "random",
  270. "randomGaussian",
  271. "randomSeed"
  272. ];
  273. const IDENT = hljs.IDENT_RE;
  274. const FUNC_NAME = { variants: [
  275. {
  276. match: regex.concat(regex.either(...BUILT_INS), regex.lookahead(/\s*\(/)),
  277. className: "built_in"
  278. },
  279. {
  280. relevance: 0,
  281. match: regex.concat(
  282. /\b(?!for|if|while)/,
  283. IDENT, regex.lookahead(/\s*\(/)),
  284. className: "title.function"
  285. }
  286. ] };
  287. const NEW_CLASS = {
  288. match: [
  289. /new\s+/,
  290. IDENT
  291. ],
  292. className: {
  293. 1: "keyword",
  294. 2: "class.title"
  295. }
  296. };
  297. const PROPERTY = {
  298. relevance: 0,
  299. match: [
  300. /\./,
  301. IDENT
  302. ],
  303. className: { 2: "property" }
  304. };
  305. const CLASS = {
  306. variants: [
  307. { match: [
  308. /class/,
  309. /\s+/,
  310. IDENT,
  311. /\s+/,
  312. /extends/,
  313. /\s+/,
  314. IDENT
  315. ] },
  316. { match: [
  317. /class/,
  318. /\s+/,
  319. IDENT
  320. ] }
  321. ],
  322. className: {
  323. 1: "keyword",
  324. 3: "title.class",
  325. 5: "keyword",
  326. 7: "title.class.inherited"
  327. }
  328. };
  329. const TYPES = [
  330. "boolean",
  331. "byte",
  332. "char",
  333. "color",
  334. "double",
  335. "float",
  336. "int",
  337. "long",
  338. "short",
  339. ];
  340. const CLASSES = [
  341. "BufferedReader",
  342. "PVector",
  343. "PFont",
  344. "PImage",
  345. "PGraphics",
  346. "HashMap",
  347. "String",
  348. "Array",
  349. "FloatDict",
  350. "ArrayList",
  351. "FloatList",
  352. "IntDict",
  353. "IntList",
  354. "JSONArray",
  355. "JSONObject",
  356. "Object",
  357. "StringDict",
  358. "StringList",
  359. "Table",
  360. "TableRow",
  361. "XML"
  362. ];
  363. const JAVA_KEYWORDS = [
  364. "abstract",
  365. "assert",
  366. "break",
  367. "case",
  368. "catch",
  369. "const",
  370. "continue",
  371. "default",
  372. "else",
  373. "enum",
  374. "final",
  375. "finally",
  376. "for",
  377. "if",
  378. "import",
  379. "instanceof",
  380. "long",
  381. "native",
  382. "new",
  383. "package",
  384. "private",
  385. "private",
  386. "protected",
  387. "protected",
  388. "public",
  389. "public",
  390. "return",
  391. "static",
  392. "strictfp",
  393. "switch",
  394. "synchronized",
  395. "throw",
  396. "throws",
  397. "transient",
  398. "try",
  399. "void",
  400. "volatile",
  401. "while"
  402. ];
  403. return {
  404. name: 'Processing',
  405. aliases: [ 'pde' ],
  406. keywords: {
  407. keyword: [ ...JAVA_KEYWORDS ],
  408. literal: 'P2D P3D HALF_PI PI QUARTER_PI TAU TWO_PI null true false',
  409. title: 'setup draw',
  410. variable: "super this",
  411. built_in: [
  412. ...BUILT_INS,
  413. ...CLASSES
  414. ],
  415. type: TYPES
  416. },
  417. contains: [
  418. CLASS,
  419. NEW_CLASS,
  420. FUNC_NAME,
  421. PROPERTY,
  422. hljs.C_LINE_COMMENT_MODE,
  423. hljs.C_BLOCK_COMMENT_MODE,
  424. hljs.APOS_STRING_MODE,
  425. hljs.QUOTE_STRING_MODE,
  426. hljs.C_NUMBER_MODE
  427. ]
  428. };
  429. }
  430. export { processing as default };