UNPKG

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