Skip to content

Instantly share code, notes, and snippets.

@mhamilt
Created November 23, 2021 14:25
Show Gist options
  • Save mhamilt/223845d7fb250117eea07a50fd07251e to your computer and use it in GitHub Desktop.
Save mhamilt/223845d7fb250117eea07a50fd07251e to your computer and use it in GitHub Desktop.
Get cell index closest to red for each column in a matrix.
{
"boxes" : [ {
"box" : {
"maxclass" : "comment",
"text" : "Map index to 0. - 1., 0. 2. as those are the cell index limits ",
"presentation_linecount" : 3,
"bubble" : 1,
"patching_rect" : [ 390.0, 525.0, 467.0, 30.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-62",
"fontsize" : 17.100642169900123
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print \"Scaled Results\"",
"patching_rect" : [ 300.0, 570.0, 124.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-61"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "scale 0. 2. 1. 0.",
"patching_rect" : [ 300.0, 525.0, 90.0, 22.0 ],
"numinlets" : 6,
"numoutlets" : 1,
"id" : "obj-60",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "get index of smallest disance (w/ min)",
"linecount" : 2,
"presentation_linecount" : 3,
"bubble" : 1,
"patching_rect" : [ 390.0, 390.0, 195.0, 49.0 ],
"numinlets" : 1,
"bubblepoint" : 0.1,
"numoutlets" : 0,
"id" : "obj-59",
"fontsize" : 17.100642169900123
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "find the distance from red",
"linecount" : 2,
"presentation_linecount" : 3,
"bubble" : 1,
"patching_rect" : [ 375.0, 300.0, 165.0, 49.0 ],
"numinlets" : 1,
"bubblepoint" : 0.1,
"numoutlets" : 0,
"id" : "obj-57",
"fontsize" : 17.100642169900123
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "For Each column",
"bubble" : 1,
"bubbleside" : 2,
"patching_rect" : [ 435.0, 225.0, 140.0, 45.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-56",
"fontsize" : 17.100642169900123
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "print Results",
"patching_rect" : [ 135.0, 555.0, 75.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-54"
}
}
, {
"box" : {
"maxclass" : "jit.pwindow",
"patching_rect" : [ 630.0, 300.0, 100.0, 100.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-36",
"outlettype" : [ "jit_matrix", "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "- 1",
"patching_rect" : [ 255.0, 210.0, 29.5, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-51",
"outlettype" : [ "int" ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "setcell 0 0 val 0 1. 0 0, setcell 1 1 val 0 1. 0 0, setcell 2 2 val 0 1. 0 0, bang",
"linecount" : 4,
"presentation_linecount" : 4,
"patching_rect" : [ 450.0, 120.0, 135.0, 62.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-50",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.matrix steve",
"patching_rect" : [ 330.0, 225.0, 85.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-42",
"outlettype" : [ "jit_matrix", "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "coll",
"patching_rect" : [ 225.0, 495.0, 50.5, 22.0 ],
"numinlets" : 1,
"numoutlets" : 4,
"id" : "obj-28",
"outlettype" : [ "", "", "", "" ],
"saved_object_attributes" : {
"embed" : 0,
"precision" : 6
}
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "- 1",
"patching_rect" : [ 255.0, 390.0, 29.5, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-27",
"outlettype" : [ "int" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "t min b i i",
"patching_rect" : [ 270.0, 180.0, 57.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 4,
"id" : "obj-21",
"outlettype" : [ "min", "bang", "int", "int" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.submatrix steve 4 float32 @dim 1 3 @offset 0 0",
"patching_rect" : [ 330.0, 270.0, 273.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-142",
"outlettype" : [ "jit_matrix", "" ]
}
}
, {
"box" : {
"maxclass" : "message",
"text" : "$2 $1",
"patching_rect" : [ 225.0, 450.0, 39.0, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-115",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pack i i",
"patching_rect" : [ 225.0, 420.0, 46.0, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-113",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "coll",
"patching_rect" : [ 330.0, 390.0, 50.5, 22.0 ],
"numinlets" : 1,
"numoutlets" : 4,
"id" : "obj-108",
"outlettype" : [ "", "", "", "" ],
"saved_object_attributes" : {
"embed" : 0,
"precision" : 6
}
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "listfunnel",
"patching_rect" : [ 330.0, 360.0, 56.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-109",
"outlettype" : [ "list" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.spill",
"patching_rect" : [ 330.0, 330.0, 41.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-110",
"outlettype" : [ "", "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.gen",
"patching_rect" : [ 330.0, 300.0, 41.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-107",
"outlettype" : [ "jit_matrix", "" ],
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 3,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "jit.gen",
"rect" : [ 221.0, 169.0, 600.0, 450.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"boxes" : [ {
"box" : {
"maxclass" : "newobj",
"text" : "+",
"patching_rect" : [ 145.0, 216.0, 29.5, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-7",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "+",
"patching_rect" : [ 183.75, 165.0, 29.5, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-5",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "swiz w",
"patching_rect" : [ 224.0, 113.0, 44.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-3",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "swiz z",
"patching_rect" : [ 178.0, 113.0, 41.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-2",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "+",
"patching_rect" : [ 76.0, 169.0, 29.5, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-16",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "swiz x",
"patching_rect" : [ 131.0, 113.0, 41.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-14",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "swiz y",
"patching_rect" : [ 76.0, 113.0, 41.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-15",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "absdiff",
"patching_rect" : [ 76.0, 79.0, 67.0, 22.0 ],
"numinlets" : 2,
"numoutlets" : 1,
"id" : "obj-13",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "vec 0 1. 0 0",
"patching_rect" : [ 124.0, 41.0, 71.0, 22.0 ],
"numinlets" : 4,
"numoutlets" : 1,
"id" : "obj-6",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "in 1",
"patching_rect" : [ 76.0, 41.0, 28.0, 22.0 ],
"numinlets" : 0,
"numoutlets" : 1,
"id" : "obj-1",
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "out 1",
"patching_rect" : [ 145.0, 256.0, 35.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-4"
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-7", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-16", 0 ],
"destination" : [ "obj-7", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-5", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-2", 0 ],
"destination" : [ "obj-5", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-13", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-15", 0 ],
"destination" : [ "obj-16", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-14", 0 ],
"destination" : [ "obj-16", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-15", 0 ],
"order" : 1
}
}
, {
"patchline" : {
"source" : [ "obj-13", 0 ],
"destination" : [ "obj-14", 0 ],
"order" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-1", 0 ],
"destination" : [ "obj-13", 0 ]
}
}
]
}
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pak offset 0 0",
"fontname" : "Arial",
"patching_rect" : [ 225.0, 240.0, 86.0, 23.0 ],
"numinlets" : 3,
"numoutlets" : 1,
"id" : "obj-17",
"fontsize" : 13.0,
"outlettype" : [ "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "uzi 3",
"patching_rect" : [ 255.0, 150.0, 40.0, 22.0 ],
"numinlets" : 2,
"numoutlets" : 3,
"id" : "obj-104",
"outlettype" : [ "bang", "bang", "int" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "t dump b b b clear",
"patching_rect" : [ 285.0, 45.0, 105.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 5,
"id" : "obj-74",
"outlettype" : [ "dump", "bang", "bang", "bang", "clear" ]
}
}
, {
"box" : {
"maxclass" : "button",
"patching_rect" : [ 285.0, 15.0, 24.0, 24.0 ],
"numinlets" : 1,
"numoutlets" : 1,
"id" : "obj-73",
"parameter_enable" : 0,
"outlettype" : [ "bang" ]
}
}
, {
"box" : {
"maxclass" : "comment",
"text" : "- For Each column\n- find the distance from a colour\n- look for the smallest number in new column\n- get the index\n- map the index to dimension",
"linecount" : 6,
"patching_rect" : [ 6.5, 15.0, 208.0, 87.0 ],
"numinlets" : 1,
"numoutlets" : 0,
"id" : "obj-44"
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.noise 4 float32 3 3",
"patching_rect" : [ 630.0, 105.0, 119.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-8",
"outlettype" : [ "jit_matrix", "" ]
}
}
, {
"box" : {
"maxclass" : "newobj",
"text" : "jit.matrix steve 4 float32 3 3",
"patching_rect" : [ 630.0, 255.0, 155.0, 22.0 ],
"numinlets" : 1,
"numoutlets" : 2,
"id" : "obj-7",
"outlettype" : [ "jit_matrix", "" ]
}
}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-28", 0 ],
"destination" : [ "obj-60", 0 ],
"order" : 0
}
}
, {
"patchline" : {
"source" : [ "obj-60", 0 ],
"destination" : [ "obj-61", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-74", 0 ],
"destination" : [ "obj-28", 0 ],
"midpoints" : [ 294.5, 135.0, 210.0, 135.0, 210.0, 489.0, 234.5, 489.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-28", 0 ],
"destination" : [ "obj-54", 0 ],
"order" : 1
}
}
, {
"patchline" : {
"source" : [ "obj-74", 1 ],
"destination" : [ "obj-104", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-74", 2 ],
"destination" : [ "obj-50", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-74", 3 ],
"destination" : [ "obj-8", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-74", 4 ],
"destination" : [ "obj-28", 0 ],
"midpoints" : [ 380.5, 210.0, 312.0, 210.0, 312.0, 481.0, 234.5, 481.0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-73", 0 ],
"destination" : [ "obj-74", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-8", 0 ],
"destination" : [ "obj-7", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-36", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-50", 0 ],
"destination" : [ "obj-7", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-142", 0 ],
"destination" : [ "obj-107", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-17", 0 ],
"destination" : [ "obj-142", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-42", 0 ],
"destination" : [ "obj-142", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-51", 0 ],
"destination" : [ "obj-17", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 2 ],
"destination" : [ "obj-51", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 1 ],
"destination" : [ "obj-42", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 0 ],
"destination" : [ "obj-108", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-104", 2 ],
"destination" : [ "obj-21", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-21", 3 ],
"destination" : [ "obj-27", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-115", 0 ],
"destination" : [ "obj-28", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-27", 0 ],
"destination" : [ "obj-113", 1 ]
}
}
, {
"patchline" : {
"source" : [ "obj-113", 0 ],
"destination" : [ "obj-115", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-110", 0 ],
"destination" : [ "obj-109", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-109", 0 ],
"destination" : [ "obj-108", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-108", 1 ],
"destination" : [ "obj-113", 0 ]
}
}
, {
"patchline" : {
"source" : [ "obj-107", 0 ],
"destination" : [ "obj-110", 0 ]
}
}
],
"appversion" : {
"major" : 8,
"minor" : 1,
"revision" : 3,
"architecture" : "x64",
"modernui" : 1
}
,
"classnamespace" : "box"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment