Skip to content

Commit 5892e8c

Browse files
authored
🤖 Merge PR DefinitelyTyped#70315 fix(maxmsp): Color methods by @zsteinkamp
1 parent d261c18 commit 5892e8c

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

types/maxmsp/index.d.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Max globals
3-
* https://docs.cycling74.com/max7/vignettes/jsglobal
3+
* https://docs.cycling74.com/max8/vignettes/jsglobal
44
*/
55
declare var inspector: number;
66
declare var inlets: number;
@@ -125,7 +125,7 @@ type MaxMessage =
125125
/**
126126
* The Buffer object in JavaScript is a companion to the buffer~ object you instantiate in Max patchers,
127127
* and provides the ability to access samples and metadata for the buffer~ object with the associated name.
128-
* https://docs.cycling74.com/max7/vignettes/jsbuffer
128+
* https://docs.cycling74.com/max8/vignettes/jsbuffer
129129
*/
130130
declare class Buffer {
131131
/**
@@ -170,7 +170,7 @@ declare class Buffer {
170170
/**
171171
* The Dict object in JS is a companion to the dict object you create in a Max patcher. It provides the ability to access structured data (a dictionary) associated with a name.
172172
* Example code can be found in the "js" tab of the dict help patcher.
173-
* https://docs.cycling74.com/max7/vignettes/jsdict
173+
* https://docs.cycling74.com/max8/vignettes/jsdict
174174
*/
175175
declare class Dict {
176176
/**
@@ -323,7 +323,7 @@ declare class Dict {
323323

324324
/**
325325
* The File object provides a means of reading and writing files from Javascript.
326-
* https://docs.cycling74.com/max7/vignettes/jsfileobject
326+
* https://docs.cycling74.com/max8/vignettes/jsfileobject
327327
*/
328328
declare class File {
329329
/**
@@ -494,7 +494,7 @@ declare class File {
494494

495495
/**
496496
* The Folder object is a js “external object” defined in the Max object called jsfolder. It is used to iterate through files in a folder.
497-
* https://docs.cycling74.com/max7/vignettes/jsfolderobject
497+
* https://docs.cycling74.com/max8/vignettes/jsfolderobject
498498
*/
499499
declare class Folder {
500500
/**
@@ -572,7 +572,7 @@ declare class Folder {
572572
* messages completely outside of js. Executing methods stored in Global objects from Max is not supported. However, methods are certainly among the kinds of things you can store within a Global
573573
* object. A Global is basically a reference to a Javascript object that you can't access directly. The object is connected to the Max symbol with the name you supplied as an argument (this allows it
574574
* to be accessed from Max). Every time you access a Global, it hands off the access to the secret hidden Javascript object. This means you can create any number of Global objects in your code, in any
575-
* number of js instances, and if they all have the same name, they will all share the same data. In this way, a Global resembles a namespace. https://docs.cycling74.com/max7/vignettes/jsglobalobject
575+
* number of js instances, and if they all have the same name, they will all share the same data. In this way, a Global resembles a namespace. https://docs.cycling74.com/max8/vignettes/jsglobalobject
576576
*/
577577
declare class Global {
578578
/**
@@ -598,7 +598,7 @@ declare class Global {
598598
/**
599599
* The LiveAPI object provides a means of communicating with the Live API functions from JavaScript. For background information on this functionality, please see the Live API Overview and Live Object
600600
* Model documents, as well as the Reference pages for live.path, live.object and live.observer objects, which provide the same basic functionality as the LiveAPI object, but from the Max patcher.
601-
* https://docs.cycling74.com/max7/vignettes/jsliveapi
601+
* https://docs.cycling74.com/max8/vignettes/jsliveapi
602602
*/
603603
declare class LiveAPI {
604604
/**
@@ -831,6 +831,11 @@ declare class Max {
831831
*/
832832
fixwidthratio(ratio: number): void;
833833

834+
/**
835+
* The word getcolor followed by string color name returns a Color type.
836+
*/
837+
getcolor(name: string): Color;
838+
834839
/**
835840
* The word getdefaultpatcherheight followed by a symbol used as the name of a receive object, causes Max to report the current default patcher height in pixels to the named receive object (See
836841
* also the setdefaultpatcherheight message to Max.)
@@ -1158,7 +1163,7 @@ declare class MaxobjConnection {
11581163
/**
11591164
* A Maxobj is a Javascript representation of a Max object in a patcher. It is returned by various methods of a Javascript Patcher object, such as newobject().One important thing to keep in mind about
11601165
* a Maxobj is that it could eventually refer to an object that no longer exists if the underlying Max object is freed. The valid property can be used to test for this condition.
1161-
* https://docs.cycling74.com/max7/vignettes/jsmaxobj
1166+
* https://docs.cycling74.com/max8/vignettes/jsmaxobj
11621167
*/
11631168
declare class Maxobj {
11641169
constructor();
@@ -1362,7 +1367,7 @@ declare class MaxobjListenerData<Tvalue> {
13621367

13631368
/**
13641369
* The Patcher object is a Javascript representation of a Max patcher. You can find, create, modify, and iterate through objects within a patcher, send messages to a patcher that you would use with
1365-
* the thispatcher object, etc. https://docs.cycling74.com/max7/vignettes/jspatcherobject
1370+
* the thispatcher object, etc. https://docs.cycling74.com/max8/vignettes/jspatcherobject
13661371
*/
13671372
declare class Patcher {
13681373
/**
@@ -1528,7 +1533,7 @@ declare class Patcher {
15281533
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15291534
// PolyBuffer //
15301535
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1531-
// https://docs.cycling74.com/max7/vignettes/jspolybuffer
1536+
// https://docs.cycling74.com/max8/vignettes/jspolybuffer
15321537

15331538
/**
15341539
* The PolyBuffer object in JS is a companion to the polybuffer~ object you create in a Max patcher. It provides the ability to access a group of buffer~ objects associated with a name.
@@ -1570,7 +1575,7 @@ declare class PolyBuffer {
15701575

15711576
/**
15721577
* A task is a function that can be scheduled or repeated. You can set the arguments to the function as well as the object that will be this when the function is called.
1573-
* https://docs.cycling74.com/max7/vignettes/jstaskobject
1578+
* https://docs.cycling74.com/max8/vignettes/jstaskobject
15741579
*/
15751580
declare class Task {
15761581
/**
@@ -1637,7 +1642,7 @@ declare class Task {
16371642

16381643
/**
16391644
* The Wind object is a property of a Patcher that represents its window. You cannot create a new Wind or access other types of windows such as that of a Max table object.
1640-
* https://docs.cycling74.com/max7/vignettes/jswindobj
1645+
* https://docs.cycling74.com/max8/vignettes/jswindobj
16411646
*/
16421647
declare class Wind {
16431648
/**
@@ -1729,7 +1734,7 @@ declare class Wind {
17291734

17301735
/**
17311736
* The SQLite object provides access to the SQLite database system (see http://www.sqlite.org for more information). A companion object, SQLResult, is required for most database operations.
1732-
* https://docs.cycling74.com/max7/vignettes/jssqliteobject
1737+
* https://docs.cycling74.com/max8/vignettes/jssqliteobject
17331738
*/
17341739
declare class SQLite {
17351740
/**
@@ -1770,11 +1775,11 @@ declare class SQLite {
17701775
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17711776
// SQLResult //
17721777
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1773-
// https://docs.cycling74.com/max7/vignettes/jssqlresultobject
1778+
// https://docs.cycling74.com/max8/vignettes/jssqlresultobject
17741779

17751780
/**
17761781
* An SQLResult object is a container for results obtained in an SQLite.exec call. Not every exec() call will produce results, but any database query (SELECT in particular) will generate an SQLResult
1777-
* object even if the result is empty. https://docs.cycling74.com/max7/vignettes/jssqlresultobject
1782+
* object even if the result is empty. https://docs.cycling74.com/max8/vignettes/jssqlresultobject
17781783
*/
17791784
declare class SQLResult {
17801785
constructor();
@@ -1802,15 +1807,15 @@ declare class SQLResult {
18021807
}
18031808

18041809
/*
1805-
* JSUI: https://docs.cycling74.com/max7/vignettes/jsuiobject
1810+
* JSUI: https://docs.cycling74.com/max8/vignettes/jsuiobject
18061811
*/
18071812

18081813
declare var mgraphics: MGraphics;
18091814
declare var sketch: Sketch;
18101815
declare function refresh(): void;
18111816

18121817
/**
1813-
* https://docs.cycling74.com/max7/vignettes/jsmgraphics
1818+
* https://docs.cycling74.com/max8/vignettes/jsmgraphics
18141819
*/
18151820
declare class MGraphics {
18161821
constructor();
@@ -2331,7 +2336,7 @@ declare class Pattern {
23312336
/**
23322337
* Sketch Every instance of jsui has an instance of Sketch bound to the variable "sketch". This is often the only instance of Sketch you will need to use. However, if you want to do things like render
23332338
* sprites, have multiple layers of images, or use drawing commands to create alpha channels for images, then you can create additional instances to render in. By default, when any function in your
2334-
* jsui object has been called the context is already set for the instance of Sketch bound to the variable "sketch". https://docs.cycling74.com/max7/vignettes/jssketchobject
2339+
* jsui object has been called the context is already set for the instance of Sketch bound to the variable "sketch". https://docs.cycling74.com/max8/vignettes/jssketchobject
23352340
*/
23362341
declare class Sketch {
23372342
/**
@@ -2663,10 +2668,13 @@ declare class Sketch {
26632668
glbindtexture(image_object: string): void;
26642669
glblendfunc(src_function: string, dst_function: string): void;
26652670
glclear(): void;
2671+
glclearcolor(color: Color): void;
26662672
glclearcolor(red: number, green: number, blue: number, alpha: number): void;
26672673
glcleardepth(depth: number): void;
26682674
glclipplane(plane: number, coeff1: number, coeff2: number, coeff3: number, coeff4: number): void;
2675+
glcolor(color: Color): void;
26692676
glcolor(red: number, green: number, blue: number, alpha: number): void;
2677+
glcolormask(color: Color): void;
26702678
glcolormask(red: number, green: number, blue: number, alpha: number): void;
26712679
glcolormaterial(face: number, mode: any[]): void;
26722680
glcullface(face: number): void;
@@ -2732,14 +2740,14 @@ declare class Sketch {
27322740
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27332741
// Image //
27342742
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2735-
// https://docs.cycling74.com/max7/vignettes/jsimageobject
2743+
// https://docs.cycling74.com/max8/vignettes/jsimageobject
27362744

27372745
/**
27382746
* Image The Image object can be used to draw images in an instance of the Sketch. It is possible to load image files from disk, create images from instances of Sketch, or generate them manually. The
27392747
* Image object has several methods to assist in manipulating images once generated. Note that alphablending is on by default in sketch. Certain file formats which contain alpha channels such as PICT
27402748
* or TIFF may have their alpha channel set all off. File formats which do not contain an alpha channel such as JPEG, by default have an alpha channel of all on. If you are having trouble seeing an
27412749
* image when attempting to draw in an instance of Sketch, you may want to either turn off blending with gldisable("blend"), or set the alpha channel to be all on with clearchannel("alpha",1.).
2742-
* https://docs.cycling74.com/max7/vignettes/jsimageobject
2750+
* https://docs.cycling74.com/max8/vignettes/jsimageobject
27432751
*/
27442752
declare class Image {
27452753
/**

types/maxmsp/maxmsp-tests.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ testmax.enablerefresh(1);
157157
testmax.externs();
158158
testmax.fileformat(".tx", "TEXT");
159159
testmax.fixwidthratio(1.1);
160+
testmax.getcolor("live_lcd_bg");
160161
testmax.getdefaultpatcherheight("my_receiver");
161162
testmax.getdefaultpatcherwidth("my_receiver");
162163
testmax.getenablepathcache("my_receiver");
@@ -572,6 +573,15 @@ sketchInstance.glvertex(20, 20);
572573
sketchInstance.glvertex(100, 100);
573574
sketchInstance.glend();
574575

576+
// Test gl color methods
577+
const COLOR_TEST: Color = [0, 0, 0, 1];
578+
sketchInstance.glclearcolor(0, 0, 0, 1);
579+
sketchInstance.glclearcolor(COLOR_TEST);
580+
sketchInstance.glcolor(0, 0, 0, 1);
581+
sketchInstance.glcolor(COLOR_TEST);
582+
sketchInstance.glcolormask(0, 0, 0, 1);
583+
sketchInstance.glcolormask(COLOR_TEST);
584+
575585
// Create a dummy instance of Image
576586
const imageInstance = new Image();
577587

0 commit comments

Comments
 (0)