UNPKG

7.21 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 = {
276 variants: [
277 {
278 match: regex.concat(regex.either(...BUILT_INS), regex.lookahead(/\s*\(/)),
279 className: "built_in"
280 },
281 {
282 relevance: 0,
283 match: regex.concat(
284 /\b(?!for|if|while)/,
285 IDENT, regex.lookahead(/\s*\(/)),
286 className: "title.function"
287 }
288 ]
289 };
290 const NEW_CLASS = {
291 match: [
292 /new\s+/,
293 IDENT
294 ],
295 className: {
296 1: "keyword",
297 2: "class.title"
298 }
299 };
300 const PROPERTY = {
301 relevance: 0,
302 match: [
303 /\./,
304 IDENT
305 ],
306 className: {
307 2: "property"
308 }
309 };
310 const CLASS = {
311 variants: [
312 {
313 match: [
314 /class/,
315 /\s+/,
316 IDENT,
317 /\s+/,
318 /extends/,
319 /\s+/,
320 IDENT
321 ]
322 },
323 {
324 match: [
325 /class/,
326 /\s+/,
327 IDENT
328 ]
329 }
330 ],
331 className: {
332 1: "keyword",
333 3: "title.class",
334 5: "keyword",
335 7: "title.class.inherited"
336 }
337 };
338
339 const TYPES = [
340 "boolean",
341 "byte",
342 "char",
343 "color",
344 "double",
345 "float",
346 "int",
347 "long",
348 "short",
349 ];
350 const CLASSES = [
351 "BufferedReader",
352 "PVector",
353 "PFont",
354 "PImage",
355 "PGraphics",
356 "HashMap",
357 "String",
358 "Array",
359 "FloatDict",
360 "ArrayList",
361 "FloatList",
362 "IntDict",
363 "IntList",
364 "JSONArray",
365 "JSONObject",
366 "Object",
367 "StringDict",
368 "StringList",
369 "Table",
370 "TableRow",
371 "XML"
372 ];
373 const JAVA_KEYWORDS = [
374 "abstract",
375 "assert",
376 "break",
377 "case",
378 "catch",
379 "const",
380 "continue",
381 "default",
382 "else",
383 "enum",
384 "final",
385 "finally",
386 "for",
387 "if",
388 "import",
389 "instanceof",
390 "long",
391 "native",
392 "new",
393 "package",
394 "private",
395 "private",
396 "protected",
397 "protected",
398 "public",
399 "public",
400 "return",
401 "static",
402 "strictfp",
403 "switch",
404 "synchronized",
405 "throw",
406 "throws",
407 "transient",
408 "try",
409 "void",
410 "volatile",
411 "while"
412 ];
413
414 return {
415 name: 'Processing',
416 aliases: [ 'pde' ],
417 keywords: {
418 keyword: [
419 ...JAVA_KEYWORDS
420 ],
421 literal: 'P2D P3D HALF_PI PI QUARTER_PI TAU TWO_PI null true false',
422 title: 'setup draw',
423 variable: "super this",
424 built_in: [
425 ...BUILT_INS,
426 ...CLASSES
427 ],
428 type: TYPES
429 },
430 contains: [
431 CLASS,
432 NEW_CLASS,
433 FUNC_NAME,
434 PROPERTY,
435 hljs.C_LINE_COMMENT_MODE,
436 hljs.C_BLOCK_COMMENT_MODE,
437 hljs.APOS_STRING_MODE,
438 hljs.QUOTE_STRING_MODE,
439 hljs.C_NUMBER_MODE
440 ]
441 };
442}
443
444export { processing as default };