diff --git a/research/SpiderAndBalanceSources.json b/research/SpiderAndBalanceSources.json
new file mode 100644
index 0000000..03e495e
--- /dev/null
+++ b/research/SpiderAndBalanceSources.json
@@ -0,0 +1,41 @@
+[
+ {
+ "repository": "https://dayu.media/git/dayu/dayu-colorplate.git",
+ "commit": "f8950384e514685c8809fe8e8ee2dd5f16ad0bd7",
+ "source": "Core/DYColorMath.h",
+ "destination": "大鱼调色/Plugin/SpiderCore/DYColorMath.h",
+ "sha256": "bdd6278e17ff4208ad94a8b0e834c817c0a3475f205dd79898e8fd88e84a19c9"
+ },
+ {
+ "repository": "https://dayu.media/git/dayu/dayu-colorplate.git",
+ "commit": "f8950384e514685c8809fe8e8ee2dd5f16ad0bd7",
+ "source": "Core/DYSpiderMesh.hpp",
+ "destination": "大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp",
+ "sha256": "81ecf1f0bae4030615144c7cd7ca492f93f2d718ff9e45da8242f97848e3d754"
+ },
+ {
+ "repository": "https://dayu.media/git/dayu/dayu-cst.git",
+ "commit": "973766b51dbcab3ab5092f1955d753575cd32d89",
+ "source": "大鱼CST/Plugin/Resources/Basis_balanceWheel.png",
+ "destination": "大鱼调色/Plugin/Resources/Basis_balanceWheel.png",
+ "sha256": "56d6cc32611f90b53dfa2ae221d5d1c9633ae494b32bc3050ec85b8ad1220989"
+ },
+ {
+ "repository": "https://dayu.media/git/dayu/dayu-colorplate.git",
+ "commit": "f8950384e514685c8809fe8e8ee2dd5f16ad0bd7",
+ "source": "Sources/DYPanel.mm",
+ "sourceSHA256": "80c6d07abab2d9a78a6c7070e2edf395289a952c731d05423681727aed97035e",
+ "section": "DYSpider class and point-count controls",
+ "adaptedDestination": "DYSpiderDisc.inc.h / DYNewPanels.inc.h",
+ "adaptations": "Host parameter adapter, manual ownership and this product theme; original geometry and control math retained."
+ },
+ {
+ "repository": "https://dayu.media/git/dayu/dayu-cst.git",
+ "commit": "973766b51dbcab3ab5092f1955d753575cd32d89",
+ "source": "大鱼CST/Plugin/DayuCustomViews.mm",
+ "sourceSHA256": "18e3bece1f627a24b875e9d02cbe938c183f6ed2ae9081e668ba460e5bf5d051",
+ "section": "DayuBalanceWheelView: +104 degree orientation, /5 drag scale and radial clamp",
+ "adaptedDestination": "DYNewPanels.inc.h",
+ "adaptations": "Host parameter adapter, manual ownership and this product theme; original geometry and control math retained."
+ }
+]
diff --git a/template/sources/RegisteredParameters.json b/template/sources/RegisteredParameters.json
index 1550a35..b17f9ae 100644
--- a/template/sources/RegisteredParameters.json
+++ b/template/sources/RegisteredParameters.json
@@ -1,7 +1,7 @@
{
"archivesBase64": {
"9000": "AAAAAAAAAisqYnBsaXN0MDDUAQIDBAUGBwxYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctIICQoLXERhdGFJc0xlZ2FjeV8QD0JsaW5kRGF0YU9iamVjdIACgAGjDQ4PVSRudWxsTxEBa2JwbGlzdDAw1AECAwQFBgcKWCR2ZXJzaW9uWSRhcmNoaXZlclQkdG9wWCRvYmplY3RzEgABhqBfEA9OU0tleWVkQXJjaGl2ZXLRCAlbQ3VzdG9tIERhdGGAAaULDBMZH1UkbnVsbNMNDg8QERJVZm9sZHNWc2NoZW1hViRjbGFzc4ACEAKABNMUFQ8WFxhXTlMua2V5c1pOUy5vYmplY3RzoKCAA9IaGxwdWiRjbGFzc25hbWVYJGNsYXNzZXNcTlNEaWN0aW9uYXJ5ohweWE5TT2JqZWN00hobICFfEBBEWUluc3BlY3RvclRva2VuoiIeXxAQRFlJbnNwZWN0b3JUb2tlbgAIABEAGgAkACkAMgA3AEkATABYAFoAYABmAG0AcwB6AIEAgwCFAIcAjgCWAKEAogCjAKUAqgC1AL4AywDOANcA3ADvAPIAAAAAAAACAQAAAAAAAAAjAAAAAAAAAAAAAAAAAAABBQgACAARABoAJAApADIANwBJAE4AWwBtAG8AcQB1AHsB6gAAAAAAAAIBAAAAAAAAABAAAAAAAAAAAAAAAAAAAAHrAA==",
- "9001": "AAAAAAAAAe8qYnBsaXN0MDDUAQIDBAUGBwxYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctIICQoLXERhdGFJc0xlZ2FjeV8QD0JsaW5kRGF0YU9iamVjdIACgAGjDQ4PVSRudWxsTxEBL2JwbGlzdDAw1AECAwQFBgcKWCR2ZXJzaW9uWSRhcmNoaXZlclQkdG9wWCRvYmplY3RzEgABhqBfEA9OU0tleWVkQXJjaGl2ZXLRCAlbQ3VzdG9tIERhdGGAAaULDBEXHVUkbnVsbNINDg8QVXBhdGhzViRjbGFzc4ACgATTEhMOFBUWV05TLmtleXNaTlMub2JqZWN0c6CggAPSGBkaG1okY2xhc3NuYW1lWCRjbGFzc2VzXE5TRGljdGlvbmFyeaIaHFhOU09iamVjdNIYGR4fXERZQXNzZXRTdGF0ZaIgHFxEWUFzc2V0U3RhdGUIERokKTI3SUxYWmBma3F4enyDi5aXmJqfqrPAw8zR3uEAAAAAAAABAQAAAAAAAAAhAAAAAAAAAAAAAAAAAAAA7ggACAARABoAJAApADIANwBJAE4AWwBtAG8AcQB1AHsBrgAAAAAAAAIBAAAAAAAAABAAAAAAAAAAAAAAAAAAAAGvAA=="
+ "9001": "AAAAAAAAAjcqYnBsaXN0MDDUAQIDBAUGBwxYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctIICQoLXERhdGFJc0xlZ2FjeV8QD0JsaW5kRGF0YU9iamVjdIACgAGjDQ4PVSRudWxsTxEBd2JwbGlzdDAw1AECAwQFBgcKWCR2ZXJzaW9uWSRhcmNoaXZlclQkdG9wWCRvYmplY3RzEgABhqBfEA9OU0tleWVkQXJjaGl2ZXLRCAlbQ3VzdG9tIERhdGGAAaULDBUbIVUkbnVsbNQNDg8QERITFFVwYXRoc1YkY2xhc3Ncc3BpZGVyTGlua2VkWnNwaWRlck1lc2iAAoAECYAA0xYXDhgZGldOUy5rZXlzWk5TLm9iamVjdHOgoIAD0hwdHh9aJGNsYXNzbmFtZVgkY2xhc3Nlc1xOU0RpY3Rpb25hcnmiHiBYTlNPYmplY3TSHB0iI1xEWUFzc2V0U3RhdGWiJCBcRFlBc3NldFN0YXRlAAgAEQAaACQAKQAyADcASQBMAFgAWgBgAGYAbwB1AHwAiQCUAJYAmACZAJsAogCqALUAtgC3ALkAvgDJANIA3wDiAOsA8AD9AQAAAAAAAAACAQAAAAAAAAAlAAAAAAAAAAAAAAAAAAABDQgACAARABoAJAApADIANwBJAE4AWwBtAG8AcQB1AHsB9gAAAAAAAAIBAAAAAAAAABAAAAAAAAAAAAAAAAAAAAH3AA=="
},
"parameters": [
{
@@ -430,11 +430,11 @@
"default": 0,
"key": "cmbalanceAngle",
"kind": "float",
- "max": 1,
+ "max": 360,
"min": 0,
"offset": 992,
"pid": 2248,
- "step": 0.01,
+ "step": 1,
"title": "色彩平衡方向"
},
{
@@ -1192,6 +1192,39 @@
"step": 1,
"title": "复制时自动调色"
},
+ {
+ "default": 1,
+ "key": "primaryMasterEnabled",
+ "kind": "bool",
+ "max": 1,
+ "min": 0,
+ "offset": 1084,
+ "pid": 2271,
+ "step": 0.01,
+ "title": "一级调色总开关"
+ },
+ {
+ "default": 1,
+ "key": "spiderMix",
+ "kind": "float",
+ "max": 1,
+ "min": 0,
+ "offset": 1092,
+ "pid": 2273,
+ "step": 0.01,
+ "title": "蜘蛛盘混合"
+ },
+ {
+ "default": 1,
+ "key": "spiderEnabled",
+ "kind": "bool",
+ "max": 1,
+ "min": 0,
+ "offset": 1088,
+ "pid": 2272,
+ "step": 0.01,
+ "title": "蜘蛛盘校色仪"
+ },
{
"default": 1,
"key": "baseEnabled",
@@ -3034,8 +3067,11 @@
"template/tools/dump_model.mm": "2ef22e010e0cae15b73107d39fb2c125f6049b1e5405e88078f936cf29e79350",
"大鱼调色/Plugin/DYCSTTypes.h": "3372e3cd77248eeb374e54675d2902befceea8e00a2afc4f9543116ef3027696",
"大鱼调色/Plugin/DYColorManagement.h": "b0a4cd1b8c45dbce90a7b4f30f72ebf95ecd382895e74e3bfeda0f7cdb185157",
- "大鱼调色/Plugin/DYModel.h": "2a1b3064d2c1179347412ad44981aad384165c2238aac06d936a496976d52e63",
- "大鱼调色/Plugin/DYModel.mm": "9478a6ec39a3d61946cd1687db7043df29c9f7185fd04ec7b1c4c57fe52ebc5d",
- "大鱼调色/Plugin/DYUniforms.h": "d56fd7de758afaca1478fd0ecbb7347cf9986730d7becc998a6ea6233a98f381"
+ "大鱼调色/Plugin/DYModel.h": "ff10bd26d4abab1e610e392841b3bf8551f7be1a245a6dca3a13e8f2a2d27adf",
+ "大鱼调色/Plugin/DYModel.mm": "f485aba06c9b4de871e95761d69b3df1001843bcf7226aba2ed278d596358364",
+ "大鱼调色/Plugin/DYSpiderState.h": "0c80747e41e8fc97762e301b011bd08c18865a825eaafde086ed79ace37b22f9",
+ "大鱼调色/Plugin/DYUniforms.h": "8ef480025c739b29f55884ba0c7218e9d6fd8d80c46cfc72d6ee3da90215abe4",
+ "大鱼调色/Plugin/SpiderCore/DYColorMath.h": "bdd6278e17ff4208ad94a8b0e834c817c0a3475f205dd79898e8fd88e84a19c9",
+ "大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp": "81ecf1f0bae4030615144c7cd7ca492f93f2d718ff9e45da8242f97848e3d754"
}
}
diff --git a/template/verification/StaticContract.json b/template/verification/StaticContract.json
index f462dcb..4d3cc9b 100644
--- a/template/verification/StaticContract.json
+++ b/template/verification/StaticContract.json
@@ -1,10 +1,10 @@
{
"passed": true,
- "sha256": "f245f1543b6ae4b8ce9dbdf899ee436b73aec44e3d9f2fbae8a1eb524aac97e5",
+ "sha256": "f027524f35c827baf746d2d7e52869644e7d601d556d8e6bf060ab27fcb49806",
"version": "5.13",
"displayversion": "5.6.7",
"filterCount": 1,
- "nativeFloatParameters": 231,
+ "nativeFloatParameters": 234,
"customParameters": 2,
"publications": [
{
diff --git a/template/大鱼调色.moef b/template/大鱼调色.moef
index 552fcc0..70fbe88 100644
--- a/template/大鱼调色.moef
+++ b/template/大鱼调色.moef
@@ -298,8 +298,8 @@
0
- *********SweMb-gOLBoA11I*E61-*I4-klM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh660Ec9L2FVR437QolZNq3XSJwE1o7gOKtYF43oMIxWOaJXR6*0U*4X1EsDJGFiRKlgHl2-9q7kP4ZnR1*kp*20*kE3-UQ8K0FqNL7nOKxiKGFVQaBcOLNZQZEYR4xkK0FjMadZMrFn2U*-Ve-T2*xCIohZSKJYEL7XO4ZqNL9F0*ZPErJnR4xh62FVR44**OI91-2L5JIYPbJgPB6B1UwEJL-VR4VnJWFXP43nQs*0U*HH2VAC3-IKJotH9ahZSLBOHZAiPq7eNKBoQu0UU*DG4-YO4pcYMqlVQrBiMKpZK0FXP43nQqJnL2tHF4ZXR4ZjPa3mSO6O53VCIoxWOaJXRB6M4FsTL2FNELBnNLFHR43oNO6U53l2KI3nQqJoIrFVR4I62FcY8H6rGIlMKa-aOr3sSbm1WtOLa7eTefD*kwnFri2********-*E*********V********************vUU*0**F*-c*7**d*16*Bk-7*2s*Kk-h*4w*QE-p*5g-fU********6-*********-********************4j**
- *********SweMb-gOLBoA11I*E61-*I4-klM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh660Ec9L2FVR437QolZNq3XSJwE1o7gOKtYF43oMIxWOaJXR6*0U*4X1EsDJGFiRKlgHl2-9q7kP4ZnR1*kp*20*kE3-UQ8K0FqNL7nOKxiKGFVQaBcOLNZQZEYR4xkK0FjMadZMrFn2U*-Ve-T2*xCIohZSKJYEL7XO4ZqNL9F0*ZPErJnR4xh62FVR44**OI91-2L5JIYPbJgPB6B1UwEJL-VR4VnJWFXP43nQs*0U*HH2VAC3-IKJotH9ahZSLBOHZAiPq7eNKBoQu0UU*DG4-YO4pcYMqlVQrBiMKpZK0FXP43nQqJnL2tHF4ZXR4ZjPa3mSO6O53VCIoxWOaJXRB6M4FsTL2FNELBnNLFHR43oNO6U53l2KI3nQqJoIrFVR4I62FcY8H6rGIlMKa-aOr3sSbm1WtOLa7eTefD*kwnFri2********-*E*********V********************vUU*0**F*-c*7**d*16*Bk-7*2s*Kk-h*4w*QE-p*5g-fU********6-*********-********************4j**
+ *********XQeMb-gOLBoA11I*E61-*I4-klM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh660Ec9L2FVR437QolZNq3XSJwE1o7gOKtYF43oMIxWOaJXR6*0U*4X1EsDJGFiRKlgHl2-Rq7kP4ZnR1*kp*20*kE3-UQ8K0FqNL7nOKxiKGFVQaBcOLNZQZEYR4xkK0FjMadZMrFn2U*-Ve-T2*xCIohZSKJYEL7XO4ZqNL9F0*ZPErJnR4xh62FVR44**OI91-IP6JIYPbJgPBEB1UwE2F6H33JkMLFcQpMYMqlVQrBQQr-dN4JmH4ZiOqJYKbBkOKFZQYpZQqW**c*20M**olML1VUN4ZRCImtfNLZnKYtH9axWOaJXR5CUc6*1oVkR5VxO74BgMLBnPa3hNJUYMqlVQrBZQplCIoFdMrFdPqtVQbaW5W-MHZBDMadZMrHG5-oW6pl2KI3nQqJoIrFVR4KW70-QF3Z-QrBZR3BoMLFZ**U*2E*O*0E*8E*m*1Q*GE-A*3U*KU-U*4M*Pk-p*5k*WE0I*7M*a*0N*7g*cU0e*9I*hU0r*9Y*jU17*B6*rk1W*Cg*w*1x*E*********0*E*********Z*******************-1EU*0**F*-c*7**d*16*Bk-7*2s*Kk-h*4w*QE-p*5g-xU********6-*********-********************5r**
+ *********XQeMb-gOLBoA11I*E61-*I4-klM75NZQbBdPqtN743mMqVdRaJmJ0FoPr-M74xWOaJXR5AG**44c3wE1otHGqJtNKF-QaBcOLNZQh660Ec9L2FVR437QolZNq3XSJwE1o7gOKtYF43oMIxWOaJXR6*0U*4X1EsDJGFiRKlgHl2-Rq7kP4ZnR1*kp*20*kE3-UQ8K0FqNL7nOKxiKGFVQaBcOLNZQZEYR4xkK0FjMadZMrFn2U*-Ve-T2*xCIohZSKJYEL7XO4ZqNL9F0*ZPErJnR4xh62FVR44**OI91-IP6JIYPbJgPBEB1UwE2F6H33JkMLFcQpMYMqlVQrBQQr-dN4JmH4ZiOqJYKbBkOKFZQYpZQqW**c*20M**olML1VUN4ZRCImtfNLZnKYtH9axWOaJXR5CUc6*1oVkR5VxO74BgMLBnPa3hNJUYMqlVQrBZQplCIoFdMrFdPqtVQbaW5W-MHZBDMadZMrHG5-oW6pl2KI3nQqJoIrFVR4KW70-QF3Z-QrBZR3BoMLFZ**U*2E*O*0E*8E*m*1Q*GE-A*3U*KU-U*4M*Pk-p*5k*WE0I*7M*a*0N*7g*cU0e*9I*hU0r*9Y*jU17*B6*rk1W*Cg*w*1x*E*********0*E*********Z*******************-1EU*0**F*-c*7**d*16*Bk-7*2s*Kk-h*4w*QE-p*5g-xU********6-*********-********************5r**
@@ -365,6 +365,9 @@
+
+
+
diff --git a/tools/build_template.py b/tools/build_template.py
index 18ec918..54d6dbd 100644
--- a/tools/build_template.py
+++ b/tools/build_template.py
@@ -20,7 +20,7 @@ CONTENT_TAGS={'scenenode','layer','group','filter','behavior','mask'}
def sha(data):return hashlib.sha256(data).hexdigest()
def model_identity():
- files=['大鱼调色/Plugin/DYModel.h','大鱼调色/Plugin/DYModel.mm','大鱼调色/Plugin/DYUniforms.h','大鱼调色/Plugin/DYColorManagement.h','大鱼调色/Plugin/DYCSTTypes.h','template/tools/dump_model.mm']
+ files=['大鱼调色/Plugin/DYModel.h','大鱼调色/Plugin/DYModel.mm','大鱼调色/Plugin/DYUniforms.h','大鱼调色/Plugin/DYColorManagement.h','大鱼调色/Plugin/DYCSTTypes.h','大鱼调色/Plugin/DYSpiderState.h','大鱼调色/Plugin/SpiderCore/DYColorMath.h','大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp','template/tools/dump_model.mm']
return {name:sha((ROOT/name).read_bytes()) for name in files}
def refresh_metadata():
diff --git a/tools/verify_gpu.mm b/tools/verify_gpu.mm
index abee2fb..0095b09 100644
--- a/tools/verify_gpu.mm
+++ b/tools/verify_gpu.mm
@@ -93,7 +93,7 @@ static Pixels render(id pipeline, bool dayu, id
+#import
+#include "../大鱼调色/Plugin/SpiderCore/DYSpiderMesh.hpp"
+#include
+#include
+#include
+static int checks=0;
+static void require(bool value,const char*why){checks++;if(!value){fprintf(stderr,"FAIL %s\n",why);exit(1);}}
+int main(){@autoreleasepool{
+ static_assert(sizeof(dy::SpiderMesh)==4988,"archive ABI");
+ NSString*source=[NSString stringWithContentsOfFile:@"大鱼调色/Plugin/SpiderCore/DYColorMath.h" encoding:NSUTF8StringEncoding error:nil];
+ source=[source stringByAppendingString:@"\nkernel void meshProbe(device const float4*input[[buffer(0)]],device float4*out[[buffer(1)]],constant int2&size[[buffer(2)]],device const float*samples[[buffer(3)]],uint i[[thread_position_in_grid]]){out[i]=float4(dyVariableSpider(input[i].xyz,size.x,size.y,samples),1);}\n"];
+ NSError*error=nil;iddevice=MTLCreateSystemDefaultDevice();require(device,"Metal device");MTLCompileOptions*options=[MTLCompileOptions new];options.fastMathEnabled=NO;idlib=[device newLibraryWithSource:source options:options error:&error];if(!lib)fprintf(stderr,"%s\n",error.localizedDescription.UTF8String);require(lib,"shared polar implementation compiles for Metal");idpipeline=[device newComputePipelineStateWithFunction:[lib newFunctionWithName:@"meshProbe"] error:&error];require(pipeline,"Metal pipeline");idqueue=[device newCommandQueue];
+ std::vectorcorpus;std::mt19937 rng(571030);std::uniform_real_distributionvalues(-.2,4);
+ for(int i=0;i<1000;i++){auto rgb=dyHSVRGB(float3{float(i)/1000,float(i%71)/70,1});corpus.push_back(simd_float4{rgb.x,rgb.y,rgb.z,1});corpus.push_back(simd_float4{values(rng),values(rng),values(rng),1});}
+ for(float gray:{0.f,.001f,.5f,1.f,4.f})corpus.push_back(simd_float4{gray,gray,gray,1});
+ idinput=[device newBufferWithBytes:corpus.data() length:corpus.size()*sizeof(simd_float4) options:MTLResourceStorageModeShared],output=[device newBufferWithLength:corpus.size()*sizeof(simd_float4) options:MTLResourceStorageModeShared];float maxError=0;int grids=0;
+ for(int hues:{6,8,12,16,24})for(int saturation:{6,8,12,16,24}){
+ auto neutral=dy::neutralMesh(hues,saturation);require(dy::validMesh(neutral),"all 25 supported topologies validate");auto samples=dy::meshSamples(neutral);
+ for(auto c:corpus){auto n=dyVariableSpider(float3{c.x,c.y,c.z},hues,saturation-1,samples.data());require(n.x==c.x&&n.y==c.y&&n.z==c.z,"every neutral grid is exact identity including HDR and gray");}
+ std::bitsetselection;selection[2]=1;auto moved=dy::moveMesh(neutral,selection,-.035,.04);require(moved.pins[2]&&moved.x[0]buffer=[device newBufferWithBytes:samples.data() length:samples.size()*sizeof(float) options:MTLResourceStorageModeShared];simd_int2 size={hues,saturation-1};idcmd=[queue commandBuffer];idenc=[cmd computeCommandEncoder];[enc setComputePipelineState:pipeline];[enc setBuffer:input offset:0 atIndex:0];[enc setBuffer:output offset:0 atIndex:1];[enc setBytes:&size length:sizeof(size) atIndex:2];[enc setBuffer:buffer offset:0 atIndex:3];[enc dispatchThreads:MTLSizeMake(corpus.size(),1,1) threadsPerThreadgroup:MTLSizeMake(64,1,1)];[enc endEncoding];[cmd commit];[cmd waitUntilCompleted];require(cmd.status==MTLCommandBufferStatusCompleted,"Metal dispatch completed");const auto*gpu=(const simd_float4*)output.contents;int changed=0;
+ for(size_t i=0;i.001;}
+ require(changed>0,"grid edit changes visible colors");grids++;
+ // Uniform translation survives resampling between every pair of resolutions.
+ auto translated=neutral;for(int i=0;i
#include "DYUniforms.h"
+#include "SpiderCore/DYColorMath.h"
using namespace metal;
// The linked, versioned AIR helper owns color arithmetic only. Its source is in
@@ -39,7 +40,9 @@ fragment half4 dyFragment(DYRaster in [[stage_in]],
constant DYUniforms& uniforms [[buffer(0)]],
constant float& sceneLevel [[buffer(1)]],
constant DYRenderOptions& options [[buffer(2)]],
- constant DYUniforms& colorUniforms [[buffer(3)]]) {
+ constant DYUniforms& colorUniforms [[buffer(3)]],
+ device const float* spiderSamples [[buffer(4)]],
+ constant int2& spiderSize [[buffer(5)]]) {
constexpr sampler sampleFilter(coord::normalized, address::clamp_to_edge, filter::linear);
half4 sample = source.sample(sampleFilter, in.uv);
if (!(sample.a > half(0.0))) return half4(0.0h);
@@ -49,6 +52,10 @@ fragment half4 dyFragment(DYRaster in [[stage_in]],
half4 color=dy_grade(sample,in.uv,source,preLUT,look1,look2,look3,look4,look5,hslMixer,whiteBalance,colorGrading,colorUniforms,sceneLevel);
result.rgb=mix(color.rgb,result.rgb,half(options.blackWhiteMix));
}
+ if(spiderSize.x>0 && uniforms.spiderSectionEnabled>.5f && uniforms.spiderMix>0.0f){
+ float3 color=float3(result.rgb);float3 warped=dyVariableSpider(color,spiderSize.x,spiderSize.y,spiderSamples);
+ result.rgb=half3(dyLimit(mix(color,warped,uniforms.spiderMix)));
+ }
result.a = sample.a;
if (options.outputPremultiplied) result.rgb *= result.a;
return result;
diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm
index a84bb4f..74d1a71 100644
--- a/大鱼调色/Plugin/DYInspector.mm
+++ b/大鱼调色/Plugin/DYInspector.mm
@@ -4,6 +4,7 @@
#import "DYLUTLibrary.h"
#import "DYLUTBrowser.h"
#import "DYRenderer.h"
+#include "DYSpiderState.h"
#import
#include
#include
@@ -167,17 +168,25 @@ static NSArray *DYPresentationSections(void) {
NSMutableDictionary *bySection=[NSMutableDictionary dictionary],*byKey=[NSMutableDictionary dictionary];
for(NSDictionary *s in DYSections())bySection[s[@"key"]]=s;
for(NSDictionary *d in DYDescriptors())byKey[d[@"key"]]=d;
- NSMutableDictionary *input=[[bySection[@"input"] mutableCopy]autorelease];
+ NSMutableDictionary *primary=[[bySection[@"primary"]mutableCopy]autorelease];NSMutableArray *cmRows=[NSMutableArray array];
+ for(NSString *part in @[@"input",@"primary",@"output"]){
+ [cmRows addObject:@{@"key":[@"heading:" stringByAppendingString:part],@"title":[part isEqual:@"input"]?@"输入与工作空间":[part isEqual:@"output"]?@"输出转换":@"一级调色"}];
+ for(NSDictionary *d in bySection[part][@"rows"]){NSString *key=d[@"key"];if([key hasPrefix:@"cmbypass"]||[key isEqual:@"cmbalanceStrength"])continue;
+ if([key isEqual:@"cmbalanceAngle"])[cmRows addObject:@{@"key":@"primaryBalance",@"kind":@"balanceWheel",@"title":@"一级白平衡色轮"}];else[cmRows addObject:d];}
+ }
+ primary[@"rows"]=cmRows;primary[@"enabled"]=byKey[@"primaryMasterEnabled"][@"pid"];primary[@"enableParameters"]=@[bySection[@"input"][@"enabled"],bySection[@"primary"][@"enabled"],bySection[@"output"][@"enabled"]];
NSMutableDictionary *base=[[bySection[@"base"] mutableCopy]autorelease];NSMutableArray *rows=[NSMutableArray array];
for(NSString *key in @[@"temperature",@"tint",@"exposure",@"contrast",@"highlights",@"shadows",@"whites",@"blacks",@"texture",@"clarity",@"dehaze",@"vibrance",@"saturation",@"skinEnabled",@"copyAutoGrade"]){NSDictionary*d=byKey[key];if(d)[rows addObject:d];}
base[@"rows"]=rows;base[@"extraEnabled"]=bySection[@"color"][@"enabled"];
base[@"title"]=@"基础调整";
- return @[input,bySection[@"primary"],bySection[@"output"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"]];
+ return @[primary,bySection[@"spider"],base,bySection[@"skin"],bySection[@"look"],bySection[@"hsl"],bySection[@"curve"],bySection[@"grading"],bySection[@"primaries"],bySection[@"levels"],bySection[@"blackwhite"],bySection[@"balance"]];
}
@protocol DYGraphicDelegate
- (void)writeGraphicValues:(NSDictionary *)values;
+- (void)writeSpiderMesh:(NSData *)mesh linked:(BOOL)linked;
+- (void)graphicGesture:(BOOL)begin title:(NSString *)title;
@end
/// The graph uses the same sorted monotone Hermite tangent limiter as the GPU.
@@ -368,6 +377,8 @@ static NSImage *DYWheelImage(void) {
- (void)layout {[super layout];CGFloat w=self.bounds.size.width/2,h=self.bounds.size.height/2;for(NSInteger i=0;i<4;i++)[_wheels[i] setFrame:NSMakeRect((i%2)*w,(i/2)*h,w,h)];}
@end
+#include "DYNewPanels.inc.h"
+
@interface DYInspector () {
id _manager;
NSScrollView *_scroll;
@@ -387,7 +398,8 @@ static NSImage *DYWheelImage(void) {
NSArray *_themeButtons;
NSMutableDictionary *_tabs;
NSInteger _visibleLooks;
- BOOL _refreshing;
+ BOOL _refreshing,_graphicUndoOpen;
+ DYSpiderPanel *_spiderPanel;
NSMutableDictionary *_assetLoads,*_assetLoadIDs;
NSUInteger _nextAssetLoadID;
NSProgress *_menuScan;
@@ -444,6 +456,8 @@ static NSImage *DYWheelImage(void) {
return self;
}
- (void)dealloc {
+ [self graphicGesture:NO title:nil];_spiderPanel.delegate=nil;
+ for(id graphic in _graphics)if([graphic isKindOfClass:DYPrimaryBalanceWheel.class])[(DYPrimaryBalanceWheel*)graphic setDelegate:nil];
for(NSProgress *p in _assetLoads.allValues)[p cancel];[_assetLoads release];[_assetLoadIDs release];[_menuScan cancel];[_menuScan release];[_pendingAssetMenuCommand release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_brand release]; [_subtitle release]; [_resetAll release]; [_save release]; [_load release]; [_export release];
@@ -460,7 +474,7 @@ static NSImage *DYWheelImage(void) {
- (NSSize)intrinsicContentSize { return NSMakeSize(360,780); }
- (void)viewDidMoveToWindow {
[super viewDidMoveToWindow];
- if(!self.window)[self cancelAssetLoads];
+ if(!self.window){[self graphicGesture:NO title:nil];[self cancelAssetLoads];}
if(self.window) {
[self refresh];
NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification);
@@ -508,7 +522,7 @@ static NSImage *DYWheelImage(void) {
[card addSubview:reset];
NSMutableArray *body=[NSMutableArray array];
NSString *key=section[@"key"]?:@"";
- if([key isEqual:@"input"]) {
+ if([key isEqual:@"primary"]) {
NSButton *migrate=DYButton(@"旧版输入 → 改用 CST",self,@selector(useCST:));migrate.identifier=@"legacyInput";migrate.toolTip=@"保留旧工程输入效果;点击后改用上方 CST 设置,可撤销";[card addSubview:migrate];[body addObject:migrate];
}
if([key localizedCaseInsensitiveContainsString:@"look"]) {
@@ -540,12 +554,15 @@ static NSImage *DYWheelImage(void) {
if([key isEqual:@"grading"]) {
DYWheelPanel *wheels=[[[DYWheelPanel alloc]initWithFrame:NSZeroRect]autorelease];wheels.delegate=self;wheels.identifier=@"gradingWheels";[card addSubview:wheels];[body addObject:wheels];[_graphics addObject:wheels];
}
+ if([key isEqual:@"spider"]){_spiderPanel=[[[DYSpiderPanel alloc]initWithFrame:NSZeroRect]autorelease];_spiderPanel.delegate=self;_spiderPanel.identifier=@"spiderGraph";[card addSubview:_spiderPanel];[body addObject:_spiderPanel];}
for(NSDictionary *d in section[@"rows"]) {
DYFlippedView *row=[[[DYFlippedView alloc] initWithFrame:NSZeroRect] autorelease];
row.identifier=d[@"key"];
row.accessibilityLabel=d[@"title"];
[card addSubview:row]; [body addObject:row];
- NSNumber *pid=d[@"pid"]; if(!pid)continue;
+ NSNumber *pid=d[@"pid"];
+ if([d[@"kind"]isEqual:@"balanceWheel"]){DYPrimaryBalanceWheel *wheel=[[[DYPrimaryBalanceWheel alloc]initWithFrame:NSZeroRect]autorelease];wheel.identifier=@"primaryBalance";wheel.delegate=self;[row addSubview:wheel];[_graphics addObject:wheel];continue;}
+ if(!pid){NSTextField *heading=DYLabel(d[@"title"],11);heading.font=[NSFont boldSystemFontOfSize:11];heading.textColor=DYAccent();[row addSubview:heading];continue;}
NSTextField *label=DYLabel(d[@"title"]?:d[@"key"],11); label.toolTip=d[@"title"];
[row addSubview:label];
NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"descriptor":d,@"row":row,@"label":label}];
@@ -590,7 +607,7 @@ static NSImage *DYWheelImage(void) {
}
for(NSView *row in body)if(![ordered containsObject:row])row.hidden=YES;body=ordered;
}
- NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"section":section,@"view":card,@"header":header,@"enabled":enabled,@"reset":reset,@"body":body,@"collapsed":@(![@[@"primary",@"base"]containsObject:key])}];
+ NSMutableDictionary *record=[NSMutableDictionary dictionaryWithDictionary:@{@"section":section,@"view":card,@"header":header,@"enabled":enabled,@"reset":reset,@"body":body,@"collapsed":@(![@[@"primary",@"spider",@"base"]containsObject:key])}];
if([key isEqual:@"look"]){NSButton *add=DYButton(@"+",self,@selector(addLook:));add.bordered=NO;add.font=[NSFont boldSystemFontOfSize:20];add.accessibilityLabel=@"添加风格 LUT";[card addSubview:add];record[@"add"]=add;}
[_cards addObject:record];
index++;
@@ -624,7 +641,7 @@ static NSImage *DYWheelImage(void) {
if([section isEqual:@"look"]){int slot=0;if(sscanf(key.UTF8String,"asset:look%d",&slot)==1)return slot<_visibleLooks;if([key isEqual:@"postLUTStrength"])return YES;int number=0;if(sscanf(key.UTF8String,"look%dStrength",&number)==1)return number-1<_visibleLooks;return NO;}
return YES;
}
-- (CGFloat)heightForRow:(NSView *)row {return [row.identifier isEqual:@"curveGraph"]?240:[row.identifier isEqual:@"gradingWheels"]?292:32;}
+- (CGFloat)heightForRow:(NSView *)row {if([row.identifier isEqual:@"spiderGraph"])return 444;if([row.identifier isEqual:@"primaryBalance"])return 232;if([row.identifier hasPrefix:@"heading:"])return 27;return [row.identifier isEqual:@"curveGraph"]?240:[row.identifier isEqual:@"gradingWheels"]?292:32;}
- (void)layout {
[super layout];
CGFloat w=MAX(280,self.bounds.size.width),h=self.bounds.size.height;
@@ -650,6 +667,8 @@ static NSImage *DYWheelImage(void) {
for(NSView *row in body) {
BOOL show=!collapsed&&[self showRow:row section:key];row.hidden=!show;if(!show)continue;
CGFloat rh=[self heightForRow:row];row.frame=NSMakeRect(12,rowY,cw-24,rh-1);rowY+=rh;
+ if([row.identifier isEqual:@"primaryBalance"])for(NSView *v in row.subviews)v.frame=row.bounds;
+ if([row.identifier hasPrefix:@"heading:"])for(NSView *v in row.subviews)v.frame=NSMakeRect(3,7,row.bounds.size.width-6,18);
if([row.identifier isEqual:@"autoControls"]||[row.identifier isEqual:@"sampleControls"]) {
CGFloat buttonWidth=(row.bounds.size.width-4*(row.subviews.count-1))/MAX((NSUInteger)1,row.subviews.count);NSInteger i=0;
for(NSView *button in row.subviews)[button setFrame:NSMakeRect((buttonWidth+4)*i++,3,buttonWidth,25)];
@@ -693,6 +712,7 @@ static NSImage *DYWheelImage(void) {
[r[@"toggle"] setState:v>=.5?NSControlStateValueOn:NSControlStateValueOff];
NSPopUpButton *popup=r[@"popup"]; if(popup.numberOfItems>0){NSArray *values=d[@"values"];NSInteger index=values?[values indexOfObject:@((int)llround(v))]:(NSInteger)llround(v);[popup selectItemAtIndex:index==NSNotFound?0:MAX(0,MIN(index,popup.numberOfItems-1))];}
}
+ for(NSDictionary *d in DYDescriptors())if([@[@"cmbalanceAngle",@"cmbalanceStrength"]containsObject:d[@"key"]]){double v=[d[@"default"]doubleValue];[get getFloatValue:&v fromParameter:[d[@"pid"]unsignedIntValue] atTime:t];graphicValues[d[@"key"]]=@(v);}
for(id graphic in _graphics)[graphic setValues:graphicValues];
for(NSMutableDictionary *c in _cards) {
NSNumber *pid=c[@"section"][@"enabled"];
@@ -711,7 +731,7 @@ static NSImage *DYWheelImage(void) {
[c[@"enabled"]setToolTip:enabled?@"停用本组,保留参数和展开状态":@"启用本组,保留展开状态"];[c[@"enabled"]setAccessibilityHelp:[c[@"enabled"]toolTip]];
for(NSView *row in c[@"body"])row.alphaValue=enabled?1:.45;
}
- DYAssetState *assets=DYReadAssets(_manager,t);
+ DYAssetState *assets=DYReadAssets(_manager,t);[_spiderPanel setMesh:assets.spiderMesh linked:assets.spiderLinked];
double profile=0,configured=0;[get getFloatValue:&profile fromParameter:2013 atTime:t];[get getFloatValue:&configured fromParameter:2236 atTime:t];
DYInspectorToken *oldToken=nil;[get getCustomParameterValue:&oldToken fromParameter:DYInspectorParameterID atTime:t];
_tabs[@"legacyInput"]=@(configured<.5&&(configured<0||profile>.5||[assets.paths[@"input"]length]||oldToken.schema<2));
@@ -751,7 +771,7 @@ static NSImage *DYWheelImage(void) {
[action startAction:self];
@try { id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)]; [set setFloatValue:v toParameter:pid.unsignedIntValue atTime:action.currentTime];if([d[@"key"]hasPrefix:@"cm"]||[d[@"key"]isEqual:@"blackWhiteMix"]){
idget=[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];DYInspectorToken *old=nil;[get getCustomParameterValue:&old fromParameter:DYInspectorParameterID atTime:action.currentTime];
- if([d[@"key"]hasPrefix:@"cm"])[set setFloatValue:1 toParameter:2236 atTime:action.currentTime];
+ if([d[@"key"]hasPrefix:@"cm"]){[set setFloatValue:1 toParameter:2236 atTime:action.currentTime];[self clearPrimaryBypasses:set time:action.currentTime];}
else if(old.schema<2){double cfg=0;[get getFloatValue:&cfg fromParameter:2236 atTime:action.currentTime];if(cfg<.5)[set setFloatValue:-1 toParameter:2236 atTime:action.currentTime];}
if(old.schema<2){DYInspectorToken *token=[[old copy]autorelease];token.schema=2;[set setCustomParameterValue:token toParameter:DYInspectorParameterID atTime:action.currentTime];}
} }
@@ -762,7 +782,7 @@ static NSImage *DYWheelImage(void) {
NSDictionary *r=_controls[@(sender.tag)],*d=r[@"descriptor"];if(!d)return;
id action=[self actionAPI];if(!action)return;
[action startAction:self];
- @try {id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];[set setFloatValue:[d[@"default"] doubleValue] toParameter:(UInt32)sender.tag atTime:action.currentTime];if([d[@"key"]hasPrefix:@"cm"])[set setFloatValue:1 toParameter:2236 atTime:action.currentTime];}
+ @try {id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];[set setFloatValue:[d[@"default"] doubleValue] toParameter:(UInt32)sender.tag atTime:action.currentTime];if([d[@"key"]hasPrefix:@"cm"]){[set setFloatValue:1 toParameter:2236 atTime:action.currentTime];[self clearPrimaryBypasses:set time:action.currentTime];}}
@finally {[action endAction:self];}
[self postChanged];
}
@@ -780,10 +800,20 @@ static NSImage *DYWheelImage(void) {
[action startAction:self];
@try {
CMTime t=action.currentTime;id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
- for(NSString *key in values) {NSDictionary *d=byKey[key];double v=[values[key] doubleValue];if(!d||!std::isfinite(v))continue;v=fmax([d[@"min"]doubleValue],fmin([d[@"max"]doubleValue],v));[set setFloatValue:v toParameter:[d[@"pid"]unsignedIntValue] atTime:t];}
+ BOOL primaryEdit=NO;for(NSString *key in values) {NSDictionary *d=byKey[key];primaryEdit|=[key hasPrefix:@"cm"];double v=[values[key] doubleValue];if(!d||!std::isfinite(v))continue;v=fmax([d[@"min"]doubleValue],fmin([d[@"max"]doubleValue],v));[set setFloatValue:v toParameter:[d[@"pid"]unsignedIntValue] atTime:t];}
+ if(primaryEdit){[set setFloatValue:1 toParameter:2236 atTime:t];[self clearPrimaryBypasses:set time:t];}
} @finally {[action endAction:self];}
[self postChanged];
}
+- (void)clearPrimaryBypasses:(id)set time:(CMTime)t{for(NSDictionary *d in DYDescriptors())if([d[@"key"]hasPrefix:@"cmbypass"])[set setFloatValue:0 toParameter:[d[@"pid"]unsignedIntValue] atTime:t];}
+- (void)graphicGesture:(BOOL)begin title:(NSString *)title{
+ if(begin==_graphicUndoOpen)return;ida=[self actionAPI];if(!a)return;[a startAction:self];
+ @try{idundo=[_manager apiForProtocol:@protocol(FxUndoAPI)];if(begin)_graphicUndoOpen=[undo startUndoGroup:title?:@"调整颜色"];else{[undo endUndoGroup];_graphicUndoOpen=NO;}}@finally{[a endAction:self];}
+}
+- (void)writeSpiderMesh:(NSData *)mesh linked:(BOOL)linked{
+ if(mesh.length&&!DYSpiderMeshIsValid(mesh))return;ida=[self actionAPI];if(!a)return;[a startAction:self];
+ @try{DYAssetState *state=[[DYReadAssets(_manager,a.currentTime)copy]autorelease];state.spiderMesh=mesh;state.spiderLinked=linked;DYWriteAssets(_manager,state,a.currentTime);}@finally{[a endAction:self];}[self postChanged];
+}
- (void)setSectionEnabled:(BOOL)enabled atIndex:(NSInteger)index {
if(index<0||index>=_cards.count)return;
NSDictionary *section=_cards[index][@"section"];
@@ -794,6 +824,7 @@ static NSImage *DYWheelImage(void) {
id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
[set setFloatValue:enabled?1:0 toParameter:pid.unsignedIntValue atTime:action.currentTime];
NSNumber *extra=section[@"extraEnabled"];if(extra)[set setFloatValue:enabled?1:0 toParameter:extra.unsignedIntValue atTime:action.currentTime];
+ for(NSNumber *linked in section[@"enableParameters"])[set setFloatValue:enabled?1:0 toParameter:linked.unsignedIntValue atTime:action.currentTime];
}
@finally {[action endAction:self];}
@@ -824,7 +855,7 @@ static NSImage *DYWheelImage(void) {
[action startAction:self];
@try {
CMTime t=action.currentTime;id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
- for(NSDictionary *d in section[@"rows"]) {[set setFloatValue:[d[@"default"] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];if(d[@"enabled"])[set setFloatValue:1 toParameter:[d[@"enabled"] unsignedIntValue] atTime:t];}
+ for(NSDictionary *d in section[@"rows"]) {if(!d[@"pid"])continue;[set setFloatValue:[d[@"default"] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];if(d[@"enabled"])[set setFloatValue:1 toParameter:[d[@"enabled"] unsignedIntValue] atTime:t];}
double defaultEnabled=[section[@"defaultEnabled"]doubleValue];
NSNumber *enabled=section[@"enabled"];if(enabled)[set setFloatValue:defaultEnabled toParameter:enabled.unsignedIntValue atTime:t];
if([@[@"input",@"primary",@"output"]containsObject:section[@"key"]])[set setFloatValue:1 toParameter:2236 atTime:t];
@@ -832,6 +863,8 @@ static NSImage *DYWheelImage(void) {
NSNumber *extra=section[@"extraEnabled"];if(extra)[set setFloatValue:defaultEnabled toParameter:extra.unsignedIntValue atTime:t];
NSString *key=section[@"key"]?:@"";
+ if([key isEqual:@"primary"]){for(NSDictionary *d in DYDescriptors())if([d[@"key"]hasPrefix:@"cm"])[set setFloatValue:[d[@"default"]doubleValue] toParameter:[d[@"pid"]unsignedIntValue] atTime:t];[set setFloatValue:1 toParameter:2236 atTime:t];for(NSNumber *linked in section[@"enableParameters"])[set setFloatValue:1 toParameter:linked.unsignedIntValue atTime:t];[set setFloatValue:0 toParameter:2013 atTime:t];DYAssetState *state=[[DYReadAssets(_manager,t)copy]autorelease];NSMutableDictionary *paths=[[state.paths mutableCopy]autorelease];[paths removeObjectForKey:@"input"];state.paths=paths;DYWriteAssets(_manager,state,t);}
+ if([key isEqual:@"spider"]){DYAssetState *state=[[DYReadAssets(_manager,t)copy]autorelease];auto m=DYSpiderMesh(state.spiderMesh);m=dy::neutralMesh(m.hues,m.rings+1);state.spiderMesh=[NSData dataWithBytes:&m length:sizeof(m)];DYWriteAssets(_manager,state,t);}
if([key localizedCaseInsensitiveContainsString:@"input"]||[key localizedCaseInsensitiveContainsString:@"look"]) {
DYAssetState *assets=[[DYReadAssets(_manager,t) copy] autorelease];
if(!assets)assets=[[[DYAssetState alloc] init] autorelease];
@@ -853,7 +886,7 @@ static NSImage *DYWheelImage(void) {
for(NSDictionary *d in DYDescriptors())[set setFloatValue:[d[@"default"] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];
DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=@{};DYWriteAssets(_manager,assets,t);
[set setCustomParameterValue:[[[DYInspectorToken alloc]init]autorelease] toParameter:DYInspectorParameterID atTime:t];
- for(NSMutableDictionary *card in _cards)card[@"collapsed"]=@(![@[@"primary",@"base"]containsObject:card[@"section"][@"key"]]);
+ for(NSMutableDictionary *card in _cards)card[@"collapsed"]=@(![@[@"primary",@"spider",@"base"]containsObject:card[@"section"][@"key"]]);
} @finally {[action endAction:self];}
[self postChanged];
}
@@ -958,15 +991,15 @@ static NSImage *DYWheelImage(void) {
}
- (NSDictionary *)presetSnapshot {
id action=[self actionAPI];if(!action)return nil;
- NSMutableDictionary *values=[NSMutableDictionary dictionary];NSDictionary *paths=@{};
+ NSMutableDictionary *values=[NSMutableDictionary dictionary];NSDictionary *paths=@{},*spider=nil;
[action startAction:self];
@try {
CMTime t=action.currentTime;id get=[_manager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
for(NSDictionary *d in DYDescriptors()) {double v=[d[@"default"] doubleValue];[get getFloatValue:&v fromParameter:[d[@"pid"] unsignedIntValue] atTime:t];if(std::isfinite(v))values[d[@"key"]]=@(v);}
DYUniforms effective;DYReadUniforms(_manager,t,&effective);values[@"cmConfigured"]=@(effective.cm.configured);values[@"blackWhiteMix"]=@(effective.cm.blackWhiteMix);
- paths=[[DYReadAssets(_manager,t).paths copy] autorelease]?:@{};
+ DYAssetState *state=DYReadAssets(_manager,t);paths=[[state.paths copy]autorelease]?:@{};spider=DYSpiderJSON(state.spiderMesh,state.spiderLinked);
} @finally {[action endAction:self];}
- return @{@"format":@"com.dayu.color.preset",@"version":@2,@"values":values,@"paths":paths};
+ return @{@"format":@"com.dayu.color.preset",@"version":@3,@"values":values,@"paths":paths,@"spider":spider};
}
- (void)savePreset:(id)sender {
NSDictionary *snapshot=[self presetSnapshot];if(!snapshot)return;
@@ -981,8 +1014,8 @@ static NSImage *DYWheelImage(void) {
NSError *error=nil;NSData *data=[NSData dataWithContentsOfURL:panel.URL options:0 error:&error];
if(!data||data.length>2*1024*1024){[self showError:error.localizedDescription?:@"预设文件过大"];return;}
id json=[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
- if(![json isKindOfClass:NSDictionary.class]||![json[@"format"] isEqual:@"com.dayu.color.preset"]||![@[@1,@2]containsObject:json[@"version"]]||![json[@"values"] isKindOfClass:NSDictionary.class]||![json[@"paths"] isKindOfClass:NSDictionary.class]){[self showError:@"这不是有效的大鱼调色预设。"];return;}
- NSDictionary *values=json[@"values"],*paths=json[@"paths"];
+ if(![json isKindOfClass:NSDictionary.class]||![json[@"format"] isEqual:@"com.dayu.color.preset"]||![@[@1,@2,@3]containsObject:json[@"version"]]||![json[@"values"] isKindOfClass:NSDictionary.class]||![json[@"paths"] isKindOfClass:NSDictionary.class]){[self showError:@"这不是有效的大鱼调色预设。"];return;}
+ NSDictionary *values=json[@"values"],*paths=json[@"paths"];NSData *mesh=[json[@"version"]isEqual:@3]?DYSpiderFromJSON(json[@"spider"]):nil;if([json[@"version"]isEqual:@3]&&!mesh){[self showError:@"预设包含无效蜘蛛盘,当前调色未修改。"];return;}
for(NSDictionary *d in DYDescriptors()) {
id v=values[d[@"key"]];if(!v)continue;
if(![v isKindOfClass:NSNumber.class]||!std::isfinite([v doubleValue])||[v doubleValue]<[d[@"min"] doubleValue]||[v doubleValue]>[d[@"max"] doubleValue]||(d[@"values"]&&![d[@"values"]containsObject:v])){[self showError:@"预设包含无效参数,尚未修改当前调色。"];return;}
@@ -1000,7 +1033,7 @@ static NSImage *DYWheelImage(void) {
CMTime t=action.currentTime;id set=[_manager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];
for(NSDictionary *d in DYDescriptors())if(values[d[@"key"]])[set setFloatValue:[values[d[@"key"]] doubleValue] toParameter:[d[@"pid"] unsignedIntValue] atTime:t];
if([json[@"version"]isEqual:@1]&&!values[@"cmConfigured"]){[set setFloatValue:-1 toParameter:2236 atTime:t];[set setFloatValue:1 toParameter:2270 atTime:t];}
- DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=validPaths;DYWriteAssets(_manager,assets,t);
+ DYAssetState *assets=[[[DYAssetState alloc] init] autorelease];assets.paths=validPaths;assets.spiderMesh=mesh;assets.spiderLinked=mesh?[json[@"spider"][@"linked"]boolValue]:YES;DYWriteAssets(_manager,assets,t);
} @finally {[action endAction:self];}
[self postChanged];
if(missing.count)[self showError:[@"调色参数已恢复,以下 LUT 文件需要重新选择:\n" stringByAppendingString:[missing componentsJoinedByString:@"\n"]]];
diff --git a/大鱼调色/Plugin/DYModel.h b/大鱼调色/Plugin/DYModel.h
index 8f9d66d..ff9a37e 100644
--- a/大鱼调色/Plugin/DYModel.h
+++ b/大鱼调色/Plugin/DYModel.h
@@ -12,6 +12,8 @@ FOUNDATION_EXPORT void DYReadUniforms(id manager,CMTime time,DY
@interface DYAssetState : NSObject
@property(copy) NSDictionary *paths;
+@property(nonatomic,copy) NSData *spiderMesh;
+@property BOOL spiderLinked;
@end
@interface DYInspectorToken : NSObject
@property(copy) NSDictionary *folds;
diff --git a/大鱼调色/Plugin/DYModel.mm b/大鱼调色/Plugin/DYModel.mm
index 50fa644..ee16e3b 100644
--- a/大鱼调色/Plugin/DYModel.mm
+++ b/大鱼调色/Plugin/DYModel.mm
@@ -1,5 +1,6 @@
#import "DYModel.h"
#include
+#include "DYSpiderState.h"
NSString *const DYModelChanged=@"DYModelChanged";
static NSMutableArray *sections,*descriptors;
static UInt32 PID(NSUInteger offset){return 2000+(UInt32)offset/4;}
@@ -103,7 +104,7 @@ static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{
CH(workingTransfer,@"工作曲线",10,0,transfers);CH(workingGamut,@"工作色域",16,0,DYCMGamuts());
CM(mix,@"CST 混合",0,1,1,0);
CM(basisEnabled,@"一级调色启用",0,1,1,1);
- CM(exposure,@"一级曝光",-5,5,0,1);CM(balanceAngle,@"色彩平衡方向",0,1,0,1);CM(balanceStrength,@"色彩平衡强度",0,1,0,1);CM(saturation,@"一级饱和度",0,2,1,1);
+ CM(exposure,@"一级曝光",-5,5,0,1);CM(balanceAngle,@"色彩平衡方向",0,360,0,1);CM(balanceStrength,@"色彩平衡强度",0,1,0,1);CM(saturation,@"一级饱和度",0,2,1,1);
CM(contrast,@"一级对比度",-1,1,0,1);CM(pivot,@"对比度轴心",-3,3,0,1);CM(hiContrast,@"高光对比度",-1,1,0,1);CM(hiPivot,@"高光轴心",-1,1,0,1);CM(shadowContrast,@"阴影对比度",-1,1,0,1);CM(shadowPivot,@"阴影轴心",-1,1,0,1);
CM(white,@"白点",.5,1.5,1,1);CM(shoulder,@"肩部压缩",0,1,.5,1);CM(highlights,@"一级高光",-1,1,0,1);CM(midtones,@"一级中间调",-1,1,0,1);CM(shadows,@"一级阴影",-1,1,0,1);CM(black,@"黑点",-1,1,0,1);CM(toe,@"趾部压缩",0,1,.5,1);CM(chromaMix,@"色度混合",0,1,.5,1);
CM(bypassExposure,@"旁路一级曝光",0,1,0,1);CM(bypassBalance,@"旁路一级色彩",0,1,0,1);CM(bypassContrast,@"旁路一级对比",0,1,0,1);CM(bypassTone,@"旁路一级影调",0,1,0,1);
@@ -126,6 +127,8 @@ static void initialize(){static dispatch_once_t once;dispatch_once(&once,^{
[descriptors replaceObjectAtIndex:[descriptors indexOfObjectPassingTest:^BOOL(id obj,NSUInteger idx,BOOL*stop){return [obj[@"key"]isEqual:keys[i]];}] withObject:r];[base addObject:r];
}
NSDictionary*copyAuto=@{@"key":@"copyAutoGrade",@"title":@"复制时自动调色",@"pid":@8800,@"offset":@(-1),@"min":@0,@"max":@1,@"default":@0,@"step":@1,@"kind":@"bool",@"notAnimatable":@YES};[descriptors addObject:copyAuto];
+ row(@"primaryMasterEnabled",@"一级调色总开关",offsetof(DYUniforms,primarySectionEnabled),0,1,1,@"bool");
+ section(@"spider",@"蜘蛛盘校色仪",offsetof(DYUniforms,spiderSectionEnabled),@[scalar(@"spiderMix",@"蜘蛛盘混合",offsetof(DYUniforms,spiderMix),0,1,1)]);
section(@"base",@"基础调色",136,[[[base subarrayWithRange:NSMakeRange(0,6)]arrayByAddingObjectsFromArray:[base subarrayWithRange:NSMakeRange(10,3)]]arrayByAddingObject:copyAuto],1);
section(@"color",@"白平衡与颜色",140,@[base[6],base[7],base[9],base[8]],1);
section(@"skin",@"肤色保护",464,@[scalar(@"skinStrength",@"保护程度",468,0,100,60),scalar(@"skinHue",@"肤色色相",472,0,60,28)],1);
@@ -164,14 +167,15 @@ BOOL DYCreateParameters(idm,NSError**error){id delegate;
+- (void)setMesh:(NSData *)mesh linked:(BOOL)linked;
+@end
+@implementation DYSpiderPanel {
+ DYSpiderDisc *_disc; NSPopUpButton *_hues,*_saturation; NSButton *_link;
+ NSTextField *_status; BOOL _linked;
+}
+- (instancetype)initWithFrame:(NSRect)frame {
+ if((self=[super initWithFrame:frame])){
+ _linked=YES;_disc=[[DYSpiderDisc alloc]initWithFrame:NSZeroRect];[self addSubview:_disc];
+ __block DYSpiderPanel *owner=self;
+ _disc.changed=^(DYGrade g,NSData *pins){if(owner.delegate)[owner.delegate writeSpiderMesh:owner->_disc.meshData linked:owner->_linked];};
+ _disc.gesture=^(BOOL begin){[owner.delegate graphicGesture:begin title:@"调整蜘蛛盘"];};
+ _status=[DYLabel(@"拖动一点,同列自由点联动。⌘ 多选,Shift 固定,右键复位。",10)retain];_status.maximumNumberOfLines=2;[self addSubview:_status];
+ _disc.selectionChanged=^(NSString *text){owner->_status.stringValue=text;};
+ for(int axis=0;axis<2;axis++){
+ NSPopUpButton *menu=[[NSPopUpButton alloc]initWithFrame:NSZeroRect pullsDown:NO];for(int n:{6,8,12,16,24}){[menu addItemWithTitle:[NSString stringWithFormat:@"%d",n]];menu.lastItem.tag=n;}
+ menu.font=[NSFont systemFontOfSize:11];menu.target=self;menu.action=@selector(resolutionChanged:);menu.accessibilityLabel=axis?@"蜘蛛盘饱和度点数":@"蜘蛛盘色相点数";[self addSubview:menu];if(axis)_saturation=menu;else _hues=menu;
+ NSTextField *label=DYLabel(axis?@"饱和度":@"色相",10);label.tag=101+axis;[self addSubview:label];
+ }
+ _link=[[NSButton checkboxWithTitle:@"联动" target:self action:@selector(linkChanged:)]retain];_link.font=[NSFont systemFontOfSize:10];_link.accessibilityLabel=@"联动蜘蛛盘点数";[self addSubview:_link];
+ NSArray *titles=@[@"固定 / 取消固定",@"重置蜘蛛盘",@"选择整环",@"选择色相列",@"复位所选"];
+ for(int i=0;i<5;i++){NSButton *b=DYButton(titles[i],self,@selector(command:));b.tag=201+i;b.font=[NSFont systemFontOfSize:10];b.accessibilityLabel=titles[i];[self addSubview:b];}
+ [self setMesh:nil linked:YES];
+ }return self;
+}
+- (void)dealloc{_disc.changed=nil;_disc.gesture=nil;_disc.selectionChanged=nil;[_disc release];[_hues release];[_saturation release];[_link release];[_status release];[super dealloc];}
+- (void)setMesh:(NSData *)data linked:(BOOL)linked{auto m=DYSpiderMesh(data);_disc.meshData=[NSData dataWithBytes:&m length:sizeof(m)];_linked=linked;[_hues selectItemWithTag:m.hues];[_saturation selectItemWithTag:m.rings+1];_link.state=linked?NSControlStateValueOn:NSControlStateValueOff;}
+- (void)layout{[super layout];CGFloat w=self.bounds.size.width;_disc.frame=NSMakeRect(0,0,w,300);
+ [[self viewWithTag:101]setFrame:NSMakeRect(0,307,32,20)];_hues.frame=NSMakeRect(33,301,60,27);
+ [[self viewWithTag:102]setFrame:NSMakeRect(99,307,43,20)];_saturation.frame=NSMakeRect(142,301,60,27);_link.frame=NSMakeRect(MAX(205,w-61),304,61,23);
+ _status.frame=NSMakeRect(2,334,w-4,36);CGFloat gap=5,bw=(w-gap)/2;
+ for(int i=0;i<2;i++)[[self viewWithTag:201+i]setFrame:NSMakeRect(i*(bw+gap),375,bw,27)];bw=(w-gap*2)/3;
+ for(int i=0;i<3;i++)[[self viewWithTag:203+i]setFrame:NSMakeRect(i*(bw+gap),406,bw,27)];}
+- (void)resolutionChanged:(NSPopUpButton *)sender{int h=(int)_hues.selectedTag,s=(int)_saturation.selectedTag;if(_linked)h=s=(int)sender.selectedTag;[_disc changeHueCount:h saturationCount:s];}
+- (void)linkChanged:(NSButton *)sender{_linked=sender.state==NSControlStateValueOn;if(_linked&&_disc.hueCount!=_disc.saturationCount)[_disc changeHueCount:(int)_disc.hueCount saturationCount:(int)_disc.hueCount];else[_delegate writeSpiderMesh:_disc.meshData linked:_linked];}
+- (void)command:(NSButton *)sender{switch(sender.tag){case 201:[_disc toggleLock];break;case 202:[_disc resetMesh];break;case 203:[_disc selectRing];break;case 204:[_disc selectSpoke];break;case 205:[_disc resetSelected];break;}}
+@end
+
+@interface DYPrimaryBalanceWheel : NSView
+@property(nonatomic,assign) id delegate;
+- (void)setValues:(NSDictionary *)values;
+@end
+@implementation DYPrimaryBalanceWheel {
+ NSPoint _offset,_dragStartMouse,_dragStartOffset;BOOL _dragging,_gestureActive;
+ NSImage *_wheel;float _angle,_strength;
+}
+- (instancetype)initWithFrame:(NSRect)frame{if((self=[super initWithFrame:frame])){NSString *path=[[NSBundle bundleForClass:self.class]pathForResource:@"Basis_balanceWheel" ofType:@"png"];if(path)_wheel=[[NSImage alloc]initWithContentsOfFile:path];self.accessibilityLabel=@"一级白平衡色轮";self.toolTip=@"拖动调整一级白平衡(精细移动);双击复位。方向键微调。";}return self;}
+- (void)dealloc{[self finishGesture];[_wheel release];[super dealloc];}
+- (BOOL)isAccessibilityElement{return YES;}
+- (NSString *)accessibilityRole{return NSAccessibilityButtonRole;}
+- (NSString *)accessibilityHelp{return self.toolTip;}
+- (id)accessibilityValue{return [NSString stringWithFormat:@"方向 %.1f 度,强度 %.1f%%",_angle,_strength*100];}
+- (BOOL)accessibilityPerformPress{[self.window makeFirstResponder:self];return YES;}
+- (BOOL)acceptsFirstResponder{return YES;}
+- (BOOL)acceptsFirstMouse:(NSEvent *)e{return YES;}
+- (CGFloat)maxDistance{return MAX(1,MIN(self.bounds.size.width,self.bounds.size.height-28)*.5-12);}
+- (NSPoint)center{return NSMakePoint(NSMidX(self.bounds),NSMidY(self.bounds)+10);}
+- (void)setValues:(NSDictionary *)values{_angle=[values[@"cmbalanceAngle"]floatValue];_strength=[values[@"cmbalanceStrength"]floatValue];double angle=(_angle+104)*M_PI/180;_offset=NSMakePoint(cos(angle)*_strength*self.maxDistance,sin(angle)*_strength*self.maxDistance);[self setNeedsDisplay:YES];}
+- (void)finishGesture{if(_gestureActive){_gestureActive=NO;[_delegate graphicGesture:NO title:@"调整一级白平衡"];}}
+- (void)viewWillMoveToWindow:(NSWindow *)w{if(!w)[self finishGesture];[super viewWillMoveToWindow:w];}
+- (void)pushValue{
+ _strength=(float)(hypot(_offset.x,_offset.y)/self.maxDistance);_angle=(float)fmod(atan2(_offset.y,_offset.x)*180/M_PI+360-104,360);
+ [_delegate writeGraphicValues:@{@"cmbalanceAngle":@(_angle),@"cmbalanceStrength":@(_strength)}];[self setNeedsDisplay:YES];
+}
+- (void)drawRect:(NSRect)dirty{NSPoint c=self.center;CGFloat r=self.maxDistance;[_wheel drawInRect:NSMakeRect(c.x-r,c.y-r,2*r,2*r) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1];
+ [NSColor.whiteColor setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(c.x+_offset.x-4,c.y+_offset.y-4,8,8)]fill];
+ NSString *text=[NSString stringWithFormat:@"一级白平衡 %.1f° · %.1f%%",_angle,_strength*100];[text drawAtPoint:NSMakePoint(8,3) withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:10],NSForegroundColorAttributeName:DYInk()}];
+}
+- (void)mouseDown:(NSEvent *)e{[self.window makeFirstResponder:self];if(e.clickCount==2){[_delegate graphicGesture:YES title:@"还原一级白平衡"];_offset=NSZeroPoint;[self pushValue];[_delegate graphicGesture:NO title:@"还原一级白平衡"];return;}
+ NSPoint p=[self convertPoint:e.locationInWindow fromView:nil],c=self.center;NSPoint knob=NSMakePoint(c.x+_offset.x,c.y+_offset.y);if(hypot(p.x-knob.x,p.y-knob.y)self.maxDistance){v.x=v.x/length*self.maxDistance;v.y=v.y/length*self.maxDistance;}_offset=v;[self pushValue];}
+- (void)mouseUp:(NSEvent *)e{if(_dragging)[self mouseDragged:e];_dragging=NO;[self finishGesture];}
+- (void)keyDown:(NSEvent *)e{unichar c=e.charactersIgnoringModifiers.length?[e.charactersIgnoringModifiers characterAtIndex:0]:0;float step=self.maxDistance*((e.modifierFlags&NSEventModifierFlagShift)?.02f:.005f);NSPoint v=_offset;
+ if(c==NSLeftArrowFunctionKey)v.x-=step;else if(c==NSRightArrowFunctionKey)v.x+=step;else if(c==NSUpArrowFunctionKey)v.y+=step;else if(c==NSDownArrowFunctionKey)v.y-=step;else if(c==NSDeleteCharacter||c==NSBackspaceCharacter)v=NSZeroPoint;else{[super keyDown:e];return;}
+ double length=hypot(v.x,v.y);if(length>self.maxDistance){v.x*=self.maxDistance/length;v.y*=self.maxDistance/length;}[_delegate graphicGesture:YES title:@"调整一级白平衡"];_offset=v;[self pushValue];[_delegate graphicGesture:NO title:@"调整一级白平衡"];}
+@end
diff --git a/大鱼调色/Plugin/DYPlugIn.mm b/大鱼调色/Plugin/DYPlugIn.mm
index aaff0dd..6aad3b4 100644
--- a/大鱼调色/Plugin/DYPlugIn.mm
+++ b/大鱼调色/Plugin/DYPlugIn.mm
@@ -12,20 +12,20 @@
- (void)dealloc{[NSNotificationCenter.defaultCenter removeObserver:self];[_renderer release];[super dealloc];}
- (BOOL)properties:(NSDictionary**)p error:(NSError**)e{*p=@{kFxPropertyKey_MayRemapTime:@NO,kFxPropertyKey_PixelTransformSupport:@(kFxPixelTransform_ScaleTranslate),kFxPropertyKey_VariesWhenParamsAreStatic:@NO,kFxPropertyKey_DesiredProcessingColorInfo:@(kFxImageColorInfo_RGB_LINEAR),kFxPropertyKey_NeedsFullBuffer:@YES};return YES;}
- (BOOL)addParametersWithError:(NSError**)e{return DYCreateParameters(_apiManager,e);}
-- (NSSet*)classesForCustomParameterID:(UInt32)pid{return pid==DYAssetsParameterID?[NSSet setWithObjects:DYAssetState.class,NSDictionary.class,NSString.class,nil]:[NSSet setWithObjects:DYInspectorToken.class,NSDictionary.class,NSString.class,NSNumber.class,nil];}
+- (NSSet*)classesForCustomParameterID:(UInt32)pid{return pid==DYAssetsParameterID?[NSSet setWithObjects:DYAssetState.class,NSDictionary.class,NSString.class,NSData.class,nil]:[NSSet setWithObjects:DYInspectorToken.class,NSDictionary.class,NSString.class,NSNumber.class,nil];}
- (NSView*)createViewForParameterID:(UInt32)pid{return pid==DYInspectorParameterID?[[DYInspector alloc]initWithAPIManager:_apiManager renderer:_renderer]:[[NSView alloc]initWithFrame:NSZeroRect];}
- (BOOL)parameterChanged:(UInt32)pid atTime:(CMTime)t error:(NSError**)e{if(pid==2013||pid==2014||(pid>=2236&&pid<2400)||pid==DYAssetsParameterID)[_renderer invalidatePreview];dispatch_async(dispatch_get_main_queue(),^{[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self.apiManager];});return YES;}
- (BOOL)pluginState:(NSData**)state atTime:(CMTime)t quality:(FxQuality)q error:(NSError**)e{
- DYUniforms u;DYReadUniforms(_apiManager,t,&u);DYAssetState*a=DYReadAssets(_apiManager,t);double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSDictionary*s=@{@"schema":@1,@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{}};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil;
+ DYUniforms u;DYReadUniforms(_apiManager,t,&u);DYAssetState*a=DYReadAssets(_apiManager,t);double copyAuto=0;[[_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)]getFloatValue:©Auto fromParameter:8800 atTime:t];NSDictionary*s=@{@"schema":@1,@"copyAuto":@(copyAuto>.5),@"uniforms":[NSData dataWithBytes:&u length:sizeof(u)],@"paths":a.paths?:@{},@"spider":a.spiderMesh?:[NSData data]};*state=[NSPropertyListSerialization dataWithPropertyList:s format:NSPropertyListBinaryFormat_v1_0 options:0 error:e];return *state!=nil;
}
- (BOOL)destinationImageRect:(FxRect*)rect sourceImages:(NSArray*)src destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(!src.count)return NO;*rect=src[0].imagePixelBounds;return YES;}
- (BOOL)sourceTileRect:(FxRect*)rect sourceImageIndex:(NSUInteger)i sourceImages:(NSArray*)src destinationTileRect:(FxRect)dstRect destinationImage:(FxImageTile*)dst pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{if(i>=src.count)return NO;*rect=src[i].imagePixelBounds;return YES;}
- (BOOL)renderDestinationImage:(FxImageTile*)dst sourceImages:(NSArray*)src pluginState:(NSData*)s atTime:(CMTime)t error:(NSError**)e{
- if(!src.count||!src[0].ioSurface||!dst.ioSurface||!s.length)return NO;NSDictionary*p=[NSPropertyListSerialization propertyListWithData:s options:NSPropertyListImmutable format:NULL error:e];if(![p isKindOfClass:NSDictionary.class])return NO;NSData*b=p[@"uniforms"];if(![p[@"schema"]isEqual:@1]||![b isKindOfClass:NSData.class]||b.length!=sizeof(DYUniforms)||![p[@"paths"]isKindOfClass:NSDictionary.class])return NO;DYUniforms u;[b getBytes:&u length:sizeof(u)];BOOL ok=[_renderer renderSource:src[0] destination:dst uniforms:u paths:p[@"paths"] error:e];if(ok){BOOL analyze=NO;@synchronized(self){if(![p[@"copyAuto"]boolValue])_copyAnalyzed=NO;else if(!_copyAnalyzed){_copyAnalyzed=YES;analyze=YES;}}if(analyze){NSDictionary*values=DYAutoGrade([_renderer preview]);if(values)dispatch_async(dispatch_get_main_queue(),^{[self applyValues:values];});}}return ok;
+ if(!src.count||!src[0].ioSurface||!dst.ioSurface||!s.length)return NO;NSDictionary*p=[NSPropertyListSerialization propertyListWithData:s options:NSPropertyListImmutable format:NULL error:e];if(![p isKindOfClass:NSDictionary.class])return NO;NSData*b=p[@"uniforms"];if(![p[@"schema"]isEqual:@1]||![b isKindOfClass:NSData.class]||b.length!=sizeof(DYUniforms)||![p[@"paths"]isKindOfClass:NSDictionary.class])return NO;DYUniforms u;[b getBytes:&u length:sizeof(u)];BOOL ok=[_renderer renderSource:src[0] destination:dst uniforms:u paths:p[@"paths"] spider:p[@"spider"] error:e];if(ok){BOOL analyze=NO;@synchronized(self){if(![p[@"copyAuto"]boolValue])_copyAnalyzed=NO;else if(!_copyAnalyzed){_copyAnalyzed=YES;analyze=YES;}}if(analyze){NSDictionary*values=DYAutoGrade([_renderer preview]);if(values)dispatch_async(dispatch_get_main_queue(),^{[self applyValues:values];});}}return ok;
}
- (void)alert:(NSString*)message{dispatch_async(dispatch_get_main_queue(),^{NSAlert*a=[NSAlert new];a.messageText=@"大鱼调色";a.informativeText=message?:@"操作未完成";[a runModal];[a release];});}
- (void)exportRequested:(NSNotification*)n{
- NSURL*url=n.userInfo[@"url"];if(![url isKindOfClass:NSURL.class])return;ida=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];DYUniforms u;DYReadUniforms(_apiManager,a.currentTime,&u);NSDictionary*paths=[DYReadAssets(_apiManager,a.currentTime).paths copy];[a endAction:self];NSError*e=nil;BOOL ok=[_renderer exportLUT:url uniforms:u paths:paths error:&e];[paths release];if(!ok)[self alert:e.localizedDescription];
+ NSURL*url=n.userInfo[@"url"];if(![url isKindOfClass:NSURL.class])return;ida=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];DYUniforms u;DYReadUniforms(_apiManager,a.currentTime,&u);DYAssetState *assets=DYReadAssets(_apiManager,a.currentTime);NSDictionary*paths=[assets.paths copy];NSData *mesh=[assets.spiderMesh copy];[a endAction:self];NSError*e=nil;BOOL ok=[_renderer exportLUT:url uniforms:u paths:paths spider:mesh error:&e];[mesh release];[paths release];if(!ok)[self alert:e.localizedDescription];
}
- (void)applyValues:(NSDictionary*)values{if(!values){[self alert:@"尚未拿到当前片段画面,请移动播放头后重试。"];return;}ida=[_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];[a startAction:self];@try{ids=[_apiManager apiForProtocol:@protocol(FxParameterSettingAPI_v6)];for(NSDictionary*r in DYDescriptors()){NSNumber*v=values[r[@"key"]];if(v)[s setFloatValue:v.doubleValue toParameter:[r[@"pid"]unsignedIntValue] atTime:a.currentTime];}}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_apiManager];}
- (void)autoRequested:(NSNotification*)n{NSData*frame=[_renderer preview];[self applyValues:[n.name isEqual:@"DYAutoGrade"]?DYAutoGrade(frame):DYAutoWhiteBalance(frame)];}
diff --git a/大鱼调色/Plugin/DYRenderer.h b/大鱼调色/Plugin/DYRenderer.h
index 470a8de..60e5695 100644
--- a/大鱼调色/Plugin/DYRenderer.h
+++ b/大鱼调色/Plugin/DYRenderer.h
@@ -8,6 +8,8 @@
- (NSProgress *)prepareLUTPath:(NSString *)path completion:(void (^)(NSError *error))completion;
- (BOOL)renderSource:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths error:(NSError**)error;
+- (BOOL)renderSource:(FxImageTile*)source destination:(FxImageTile*)destination uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths spider:(NSData*)spider error:(NSError**)error;
+- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)uniforms paths:(NSDictionary*)paths spider:(NSData*)spider error:(NSError**)error;
- (NSData*)preview;
/// Display-encoded float RGBA, 320×180, with the visually top row first.
/// Analysis preview retains the host texture's original row order separately.
diff --git a/大鱼调色/Plugin/DYRenderer.mm b/大鱼调色/Plugin/DYRenderer.mm
index dbdce8f..4154036 100644
--- a/大鱼调色/Plugin/DYRenderer.mm
+++ b/大鱼调色/Plugin/DYRenderer.mm
@@ -1,5 +1,6 @@
#import "DYRenderer.h"
#import "DYModel.h"
+#include "DYSpiderState.h"
#import "DYColorTables.h"
#import "DYLUTLibrary.h"
#import
@@ -119,11 +120,24 @@ static void bypassIdleSkin(DYUniforms *u){
[DYColorTables fillPrimaries:u];idd=e[@"device"];
idh=[_tables hslForDevice:d uniforms:u],w=[_tables whiteBalanceForDevice:d uniforms:u],g=[_tables gradingForDevice:d uniforms:u];if(!h||!w||!g){fail(err,_tables.lastError?:@"颜色查表构建失败");return nil;}[ts addObjectsFromArray:@[h,w,g]];return ts;
}
-- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{@synchronized(self){@autoreleasepool{
+- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths error:(NSError**)err{return [self renderSource:src destination:dst uniforms:u paths:paths spider:nil error:err];}
+- (BOOL)renderSource:(FxImageTile*)src destination:(FxImageTile*)dst uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData *)spider error:(NSError**)err{@synchronized(self){@autoreleasepool{
+ if(spider.length&&!DYSpiderMeshIsValid(spider))return fail(err,@"蜘蛛盘数据无效");
+ if(u.primarySectionEnabled<.5){u.inputSectionEnabled=0;u.cm.basisEnabled=0;u.cm.outputEnabled=0;}
+
[_activeLUTPaths release];_activeLUTPaths=[[NSSet alloc]initWithArray:paths.allValues?:@[]];
NSMutableDictionary*e=[self device:dst.deviceRegistryID error:err];if(!e)return NO;idd=e[@"device"];idinput=[src metalTextureForDevice:d],output=[dst metalTextureForDevice:d];if(!input||!output)return fail(err,@"宿主图像纹理不可用");
BOOL useCM=managed(u,paths);bypassNeutralTools(&u);float bwMix=fmaxf(0,fminf(1,u.cm.blackWhiteMix));if(bwMix<=0)u.blackWhiteSectionEnabled=0;
NSArray*ts=[self textures:paths uniforms:&u entry:e error:err];if(!ts)return NO;bypassIdleSkin(&u);
+ // Only a deformed active mesh allocates samples; device entries retain the
+ // current buffer across frames. Neutral grids are exact identity at all densities.
+ simd_int2 spiderSize={0,0};idspiderBuffer=nil;
+ if(u.spiderSectionEnabled>.5&&u.spiderMix>0&&spider.length){
+ if(![e[@"spiderData"]isEqual:spider]){auto mesh=DYSpiderMesh(spider);auto samples=dy::meshSamples(mesh);BOOL changed=NO;for(float value:samples)changed|=value!=0;
+ e[@"spiderData"]=spider;e[@"spiderActive"]=@(changed);if(changed){idb=[d newBufferWithBytes:samples.data() length:samples.size()*sizeof(float) options:MTLResourceStorageModeShared];if(!b)return fail(err,@"无法分配蜘蛛盘缓冲区");e[@"spiderBuffer"]=b;[b release];e[@"spiderHues"]=@(mesh.hues);e[@"spiderRings"]=@(mesh.rings);}else[e removeObjectForKey:@"spiderBuffer"];
+ }
+ if([e[@"spiderActive"]boolValue]){spiderBuffer=e[@"spiderBuffer"];spiderSize={ [e[@"spiderHues"]intValue],[e[@"spiderRings"]intValue]};}
+ }
NSMutableDictionary*ps=e[@"pipelines"];NSNumber*format=@(output.pixelFormat);idpipeline=ps[format];if(!pipeline){MTLRenderPipelineDescriptor*p=[MTLRenderPipelineDescriptor new];p.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];p.fragmentFunction=[e[@"library"]newFunctionWithName:@"dyFragment"];p.colorAttachments[0].pixelFormat=output.pixelFormat;pipeline=[d newRenderPipelineStateWithDescriptor:p error:err];[p.vertexFunction release];[p.fragmentFunction release];[p release];if(!pipeline)return NO;ps[format]=pipeline;[pipeline release];}
MTLTextureDescriptor*td=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:input.width height:input.height mipmapped:NO];td.storageMode=MTLStorageModePrivate;td.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite;idstraight=[d newTextureWithDescriptor:td];if(!straight)return fail(err,@"无法分配调色缓冲区");
idcb=[e[@"queue"]commandBuffer];idce=[cb computeCommandEncoder];[ce setComputePipelineState:e[@"dyUnpremultiply"]];[ce setTexture:input atIndex:0];[ce setTexture:straight atIndex:1];[ce dispatchThreads:MTLSizeMake(input.width,input.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[ce endEncoding];
@@ -141,7 +155,7 @@ static void bypassIdleSkin(DYUniforms *u){
if(src.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){top=1-top;bottom=1-bottom;}
DYVertex2D vs[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};
if(dst.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(int i=0;i<4;i++)vs[i].position.y=-vs[i].position.y;
- vector_uint2 vp={(unsigned)output.width,(unsigned)output.height};[re setVertexBytes:vs length:sizeof(vs) atIndex:0];[re setVertexBytes:&vp length:sizeof(vp) atIndex:1];[re setViewport:(MTLViewport){0,0,w,h,0,1}];[re setFragmentTexture:straight atIndex:0];for(NSUInteger i=0;id=e[@"device"];const NSUInteger n=33,count=n*n*n,width=n*n,height=n;
MTLTextureDescriptor *desc=[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA16Float width:width height:height mipmapped:NO];desc.storageMode=MTLStorageModeShared;desc.usage=MTLTextureUsageShaderRead|MTLTextureUsageShaderWrite|MTLTextureUsageRenderTarget;
idinput=[d newTextureWithDescriptor:desc],output=[d newTextureWithDescriptor:desc];if(!input||!output){[input release];[output release];return fail(err,@"无法分配 LUT 色格");}
@@ -164,7 +179,7 @@ static void bypassIdleSkin(DYUniforms *u){
[input replaceRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0 withBytes:values.data() bytesPerRow:width*8];
DYExportTile *source=[[[DYExportTile alloc]initWithTexture:input registry:d.registryID]autorelease],*dest=[[[DYExportTile alloc]initWithTexture:output registry:d.registryID]autorelease];
u.textureEnabled=0;u.clarityEnabled=0;u.dehazeEnabled=0;BOOL ok=NO;_exporting=YES;
- @try{ok=[self renderSource:source destination:dest uniforms:u paths:paths error:err];}@finally{_exporting=NO;}
+ @try{ok=[self renderSource:source destination:dest uniforms:u paths:paths spider:spider error:err];}@finally{_exporting=NO;}
if(ok)[output getBytes:values.data() bytesPerRow:width*8 fromRegion:MTLRegionMake2D(0,0,width,height) mipmapLevel:0];[input release];[output release];if(!ok)return NO;
NSMutableString *text=[NSMutableString stringWithString:@"TITLE \"大鱼调色\"\n# 包含 CST 与逐像素颜色;不包含纹理、清晰度和逐画面分析。\nLUT_3D_SIZE 33\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 1 1 1\n"];
for(NSUInteger i=0;i=0?_selected:(NSInteger)_selection.firstIndex;return i>=0&&i<[self nodeCount]?[NSString stringWithFormat:@"已选 %lu 点,主点 %ld,X %.4f,Y %.4f,固定点仍可拖动",(unsigned long)_selection.count,(long)i+1,_mesh.x[i],_mesh.y[i]]:@"拖动一点,周围自由点自动联动";}
+- (BOOL)accessibilityPerformPress{[self.window makeFirstResponder:self];if(!_selection.count)[_selection addIndex:0];[self describeSelection];self.needsDisplay=YES;return YES;}
+- (void)finishGesture{if(_gestureActive){_gestureActive=NO;if(_gesture)_gesture(NO);}}
+- (void)viewWillMoveToWindow:(NSWindow*)window{if(!window)[self finishGesture];[super viewWillMoveToWindow:window];}
+- (NSInteger)nodeCount{return dy::meshCount(_mesh);}
+- (NSInteger)hueCount{return _mesh.hues;}
+- (NSInteger)saturationCount{return _mesh.rings+1;}
+- (NSData*)meshData{return _variableMesh?[NSData dataWithBytes:&_mesh length:sizeof(_mesh)]:nil;}
+- (void)setMeshData:(NSData*)data{dy::SpiderMesh m{};BOOL variable=data.length==sizeof(m);if(variable){memcpy(&m,data.bytes,sizeof(m));if(!dy::validMesh(m))return;}else m=dy::legacyMesh(_grade,(const uint8_t*)self.pinData.bytes);BOOL topology=m.hues!=_mesh.hues||m.rings!=_mesh.rings;_mesh=m;_variableMesh=variable;if(topology){_dragging=_marquee=NO;[self finishGesture];[_selection removeAllIndexes];_selected=-1;}[self updatePins];self.needsDisplay=YES;}
+- (void)updatePins{self.pinned=[NSMutableIndexSet indexSet];for(int i=0;i<[self nodeCount];i++)if(_mesh.pins[i])[_pinned addIndex:i];}
+- (NSData*)pinData{uint8_t flags[81]={};auto m=dy::resampleMesh(_mesh,16,6);for(int i=0;i<81;i++)flags[i]=m.pins[i];return [NSData dataWithBytes:flags length:81];}
+- (void)setPinData:(NSData*)data{if(!_variableMesh){const uint8_t*p=data.length==81?(const uint8_t*)data.bytes:nullptr;_mesh=dy::legacyMesh(_grade,p);[self updatePins];}self.needsDisplay=YES;}
+- (void)notifyChange{for(int i=0;i<[self nodeCount];i++)_mesh.pins[i]=dy::meshBoundary(_mesh,i)||[_pinned containsIndex:i];_grade=dy::meshLegacyGrade(_grade,_mesh);if(_changed)_changed(_grade,self.pinData);[self describeSelection];self.needsDisplay=YES;}
+- (void)changeHueCount:(int)hues saturationCount:(int)saturation{if(!_interactionEnabled||!dySpiderResolution(hues)||!dySpiderResolution(saturation))return;if(hues==_mesh.hues&&saturation==_mesh.rings+1)return;[self finishGesture];_dragging=_marquee=NO;_mesh=dy::resampleMesh(_mesh,hues,saturation);_variableMesh=YES;[_selection removeAllIndexes];_selected=-1;[self updatePins];[self notifyChange];}
+- (void)resetMesh{_mesh=dy::neutralMesh(_mesh.hues,_mesh.rings+1);_variableMesh=YES;[_selection removeAllIndexes];_selected=-1;[self updatePins];[self notifyChange];}
+- (void)moveFrom:(DYGrade)g x:(float)x y:(float)y {
+ if(!_selection.count||(x==0&&y==0))return;std::bitsetselected;for(int i=0;i<[self nodeCount];i++)selected[i]=[_selection containsIndex:i];
+ auto start=_dragging?_dragMesh:_mesh;auto moved=dy::moveMesh(start,selected,x,y);if(!memcmp(&moved,&_mesh,sizeof(moved)))return;_mesh=moved;_grade=g;_grade.spiderEnabled=1;[self updatePins];[self notifyChange];
+}
+- (void)keyDown:(NSEvent*)e {
+ if(!_interactionEnabled)return;unichar c=e.charactersIgnoringModifiers.length?[e.charactersIgnoringModifiers characterAtIndex:0]:0;
+ if(c==27){if(_dragging){_grade=_dragGrade;_mesh=_dragMesh;self.pinned=[[_pinsStart mutableCopy]autorelease];[self notifyChange];}if(_marquee)self.selection=[[_selectionStart mutableCopy]autorelease];_dragging=_marquee=NO;[self finishGesture];self.needsDisplay=YES;return;}
+ if((e.modifierFlags&NSEventModifierFlagCommand)&&c=='a'){[_selection addIndexesInRange:NSMakeRange(0,[self nodeCount])];[self describeSelection];self.needsDisplay=YES;return;}
+ if(c=='\t'){_selected=(_selected+(e.modifierFlags&NSEventModifierFlagShift?[self nodeCount]-1:1)+[self nodeCount])%[self nodeCount];[_selection removeAllIndexes];[_selection addIndex:_selected];[self describeSelection];self.needsDisplay=YES;return;}
+ if(c==' '){[self toggleLock];return;}if(c==NSDeleteCharacter||c==NSBackspaceCharacter){[self resetSelected];return;}
+ float step=e.modifierFlags&NSEventModifierFlagShift?.02f:.005f;
+ if(c==NSLeftArrowFunctionKey)[self moveFrom:_grade x:-step y:0];else if(c==NSRightArrowFunctionKey)[self moveFrom:_grade x:step y:0];else if(c==NSUpArrowFunctionKey)[self moveFrom:_grade x:0 y:-step];else if(c==NSDownArrowFunctionKey)[self moveFrom:_grade x:0 y:step];else[super keyDown:e];
+}
+- (instancetype)initWithFrame:(NSRect)r{if((self=[super initWithFrame:r])){_grade=dyDefaultGrade();_mesh=dy::legacyMesh(_grade);_selected=-1;self.pinData=nil;self.selection=[NSMutableIndexSet indexSet];_interactionEnabled=YES;self.accessibilityLabel=@"蜘蛛盘,拖动一点联动同列自由点";}return self;}
+- (NSRect)discRect{CGFloat s=MIN(self.bounds.size.width,self.bounds.size.height)-32;return NSMakeRect((self.bounds.size.width-s)/2,(self.bounds.size.height-s)/2,s,s);}
+- (NSPoint)point:(NSInteger)i{NSRect r=self.discRect;return NSMakePoint(r.origin.x+_mesh.x[i]*r.size.width,r.origin.y+_mesh.y[i]*r.size.height);}
+- (void)setGrade:(DYGrade)g{if(memcmp(g.spiderX,_grade.spiderX,sizeof(g.spiderX))||memcmp(g.spiderY,_grade.spiderY,sizeof(g.spiderY))){_grade=g;self.meshData=nil;}else _grade=g;self.needsDisplay=YES;}
+- (void)drawRect:(NSRect)dirty{
+ NSRect r=self.discRect;NSPoint c=NSMakePoint(NSMidX(r),NSMidY(r));CGFloat rad=r.size.width/2;
+ for(int s=0;s<64;s++)for(int ring=1;ring<=5;ring++){double a=s*M_PI/32,b=(s+1)*M_PI/32;NSBezierPath*p=[NSBezierPath bezierPath];[p moveToPoint:NSMakePoint(c.x+cos(a)*(ring-1)*rad/5,c.y+sin(a)*(ring-1)*rad/5)];[p lineToPoint:NSMakePoint(c.x+cos(a)*ring*rad/5,c.y+sin(a)*ring*rad/5)];[p lineToPoint:NSMakePoint(c.x+cos(b)*ring*rad/5,c.y+sin(b)*ring*rad/5)];[p lineToPoint:NSMakePoint(c.x+cos(b)*(ring-1)*rad/5,c.y+sin(b)*(ring-1)*rad/5)];[p closePath];[[NSColor colorWithCalibratedHue:s/64. saturation:ring/5. brightness:.47 alpha:1]setFill];[p fill];}
+ [[NSColor colorWithWhite:1 alpha:.30]setStroke];for(int ring=1;ring<=_mesh.rings;ring++){NSBezierPath *p=[NSBezierPath bezierPath];for(int s=0;s<=_mesh.hues;s++){NSPoint q=[self point:dy::meshIndex(_mesh,s%_mesh.hues,ring)];if(s==0)[p moveToPoint:q];else[p lineToPoint:q];}[p stroke];}
+ for(int s=0;s<_mesh.hues;s++){NSBezierPath*p=[NSBezierPath bezierPath];[p moveToPoint:[self point:[self nodeCount]-1]];for(int ring=1;ring<=_mesh.rings;ring++)[p lineToPoint:[self point:dy::meshIndex(_mesh,s,ring)]];[p stroke];}
+ for(int i=0;i<[self nodeCount];i++){NSPoint p=[self point:i];CGFloat z=[_selection containsIndex:i]?4.5:2.6;NSBezierPath *d=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x-z,p.y-z,z*2,z*2)];[([_selection containsIndex:i]?DYAccent():[NSColor colorWithWhite:1 alpha:.85])setFill];[d fill];if([_selection containsIndex:i]){[NSColor.whiteColor setStroke];[d stroke];}if([_pinned containsIndex:i]){[NSColor.blackColor setFill];NSRectFill(NSMakeRect(p.x-1,p.y-1,2,2));}}
+ if(_marquee){
+ NSRect box=NSMakeRect(MIN(_dragOrigin.x,_marqueeEnd.x),MIN(_dragOrigin.y,_marqueeEnd.y),fabs(_dragOrigin.x-_marqueeEnd.x),fabs(_dragOrigin.y-_marqueeEnd.y));
+ NSBezierPath*outline=[NSBezierPath bezierPathWithRect:box];outline.lineWidth=1.25;
+ [DYAccent()setStroke];[outline stroke];
+ }
+}
+- (void)describeSelection{if(_selectionChanged)_selectionChanged([NSString stringWithFormat:@"拖动主点,同列自由点联动 · 已选 %lu 点\n⌘ 多选 · Shift 固定 · 右键复位",(unsigned long)_selection.count]);}
+- (void)toggleLock{if(!_interactionEnabled||!_selection.count)return;BOOL all=YES;for(NSUInteger i=_selection.firstIndex;i!=NSNotFound;i=[_selection indexGreaterThanIndex:i])if(![_pinned containsIndex:i])all=NO;for(NSUInteger i=_selection.firstIndex;i!=NSNotFound;i=[_selection indexGreaterThanIndex:i]){if(all&&!dy::meshBoundary(_mesh,int(i)))[_pinned removeIndex:i];else[_pinned addIndex:i];}[self notifyChange];}
+- (void)selectRing{NSIndexSet*old=[[_selection copy]autorelease];for(NSUInteger i=old.firstIndex;i!=NSNotFound;i=[old indexGreaterThanIndex:i])if(i<[self nodeCount]-1)for(int s=0;s<_mesh.hues;s++)[_selection addIndex:dy::meshIndex(_mesh,s,int(i%_mesh.rings)+1)];[self describeSelection];self.needsDisplay=YES;}
+- (void)selectSpoke{NSIndexSet*old=[[_selection copy]autorelease];for(NSUInteger i=old.firstIndex;i!=NSNotFound;i=[old indexGreaterThanIndex:i])if(i<[self nodeCount]-1)for(int r=1;r<=_mesh.rings;r++)[_selection addIndex:dy::meshIndex(_mesh,int(i/_mesh.rings),r)];[self describeSelection];self.needsDisplay=YES;}
+- (void)resetSelected{if(!_interactionEnabled)return;auto d=dy::neutralMesh(_mesh.hues,_mesh.rings+1);for(NSUInteger i=_selection.firstIndex;i!=NSNotFound;i=[_selection indexGreaterThanIndex:i]){_mesh.x[i]=d.x[i];_mesh.y[i]=d.y[i];if(!dy::meshBoundary(_mesh,int(i)))[_pinned removeIndex:i];}[self notifyChange];}
+- (NSInteger)hitPoint:(NSPoint)p{float best=14;NSInteger chosen=-1;for(int i=0;i<[self nodeCount];i++){NSPoint q=[self point:i];float d=hypot(p.x-q.x,p.y-q.y);if(d=0&&(e.modifierFlags&NSEventModifierFlagShift)){[_pinned addIndex:chosen];[self notifyChange];return;}
+ if(chosen<0){_marquee=YES;if(!additive)[_selection removeAllIndexes];if(!additive)[_selectionStart removeAllIndexes];}
+ else if(additive){if([_selection containsIndex:chosen])[_selection removeIndex:chosen];else[_selection addIndex:chosen];}
+ else {if(![_selection containsIndex:chosen]){[_selection removeAllIndexes];[_selection addIndex:chosen];}if(e.clickCount>=2)[self resetSelected];else _dragging=YES;}
+ [self describeSelection];self.needsDisplay=YES;
+}
+- (void)mouseDragged:(NSEvent*)e {
+ if(!_interactionEnabled)return;NSPoint p=[self convertPoint:e.locationInWindow fromView:nil];
+ if(_marquee){_marqueeEnd=p;NSRect box=NSMakeRect(MIN(_dragOrigin.x,p.x),MIN(_dragOrigin.y,p.y),fabs(p.x-_dragOrigin.x),fabs(p.y-_dragOrigin.y));self.selection=[[_selectionStart mutableCopy]autorelease];for(int i=0;i<[self nodeCount];i++)if(NSPointInRect([self point:i],box))[_selection addIndex:i];[self describeSelection];self.needsDisplay=YES;}
+ else if(_dragging){if(!_gestureActive){_gestureActive=YES;if(_gesture)_gesture(YES);}NSRect r=self.discRect;[self moveFrom:_dragGrade x:(p.x-_dragOrigin.x)/r.size.width y:(p.y-_dragOrigin.y)/r.size.height];}
+}
+- (void)mouseUp:(NSEvent*)e{_dragging=_marquee=NO;[self finishGesture];self.needsDisplay=YES;}
+@end
+
diff --git a/大鱼调色/Plugin/DYSpiderState.h b/大鱼调色/Plugin/DYSpiderState.h
new file mode 100644
index 0000000..ac8e4a4
--- /dev/null
+++ b/大鱼调色/Plugin/DYSpiderState.h
@@ -0,0 +1,14 @@
+#pragma once
+#import
+#include "SpiderCore/DYSpiderMesh.hpp"
+static inline BOOL DYSpiderMeshIsValid(NSData *data){dy::SpiderMesh m{};if(data.length!=sizeof(m))return NO;memcpy(&m,data.bytes,sizeof(m));return dy::validMesh(m);}
+static inline dy::SpiderMesh DYSpiderMesh(NSData *data){dy::SpiderMesh m=dy::neutralMesh();if(DYSpiderMeshIsValid(data))memcpy(&m,data.bytes,sizeof(m));return m;}
+static inline NSDictionary *DYSpiderJSON(NSData *data,BOOL linked){auto m=DYSpiderMesh(data);NSMutableArray *x=[NSMutableArray array],*y=[NSMutableArray array],*pins=[NSMutableArray array];for(int i=0;i24||sat<6||sat>24||!dySpiderResolution((int)hues)||!dySpiderResolution((int)sat))return nil;
+ auto m=dy::neutralMesh((int)hues,(int)sat);NSUInteger count=dy::meshCount(m);for(NSString *key in @[@"x",@"y",@"pins"])if(![json[key]isKindOfClass:NSArray.class]||[json[key]count]!=count)return nil;
+ for(NSUInteger i=0;iCFBundlePackageType
XPC!
CFBundleShortVersionString
- 1.2.0
+ 1.3.0
CFBundleVersion
- 17
+ 18
NSHumanReadableCopyright
PlugInKit
diff --git a/大鱼调色/Plugin/Resources/Basis_balanceWheel.png b/大鱼调色/Plugin/Resources/Basis_balanceWheel.png
new file mode 100644
index 0000000..1a6ff2d
Binary files /dev/null and b/大鱼调色/Plugin/Resources/Basis_balanceWheel.png differ
diff --git a/大鱼调色/Plugin/SpiderCore/DYColorMath.h b/大鱼调色/Plugin/SpiderCore/DYColorMath.h
new file mode 100644
index 0000000..cbffd43
--- /dev/null
+++ b/大鱼调色/Plugin/SpiderCore/DYColorMath.h
@@ -0,0 +1,236 @@
+#pragma once
+#ifdef __METAL_VERSION__
+#include
+using namespace metal;
+#define DYREF constant
+#else
+#include
+#include
+#include
+using float3 = simd_float3;
+#define DYREF const
+using std::floor; using std::pow; using std::sqrt; using std::atan2; using std::log2; using std::exp2; using std::isfinite;
+#endif
+
+// Plain scalar layout is identical in the Metal and C++ ABI.
+struct DYGrade {
+ float exposure, contrast, saturation, temperature, tint;
+ float shadows, highlights, blackPoint, whitePoint, gamma;
+ float lift[3], gain[3], midtone[3];
+ float curve[5];
+ float spiderX[81], spiderY[81];
+ float lutMix, mix;
+ float localExposure, localSaturation;
+ float maskX, maskY, maskW, maskH, maskAngle, feather, imageAspect;
+ int spiderEnabled, maskEnabled, maskInvert, maskView, bypass;
+ // Schema 4 extension. Keep the complete legacy 808-byte prefix above intact.
+ float hslHue, hslSaturation, hslLightness;
+ // R, Y, G, C, B, M and an independently adjustable skin-tone target.
+ // Hue and half-width use turns; saturation is a multiplier, lightness is -1...1.
+ float vectorHue[7], vectorSaturation[7], vectorLightness[7], vectorWidth[7];
+ float skinHue;
+ float rgbCurve[3][5];
+ // Row-major RGB output-from-input matrix.
+ float channelMixer[9];
+};
+inline float dyClamp(float x,float a,float b){return xb?b:x);}
+// For bounded lookup coordinates only: NaN selects the first sample, infinities
+// select an endpoint. Finite arithmetic and unrestricted HDR values elsewhere
+// are unchanged; this is not a color-range clamp.
+inline float dyUnitIndexCoordinate(float x){return isfinite(x)?dyClamp(x,0,1):(x>0?1:0);}
+inline float dySafePow(float x,float e){if(x<=0)return 0;if(e==1)return x;return exp2(dyClamp(log2(x)*e,-80,15));}
+inline float3 dyLimit(float3 c){for(int k=0;k<3;k++)c[k]=isfinite(c[k])?dyClamp(c[k],-65504,65504):0;return c;}
+inline float dyMix(float a,float b,float t){return a+(b-a)*t;}
+inline float dySmooth(float a,float b,float x){float t=dyClamp((x-a)/(b-a),0,1);return t*t*(3-2*t);}
+inline float dyLuma(float3 c){return c.x*.2126f+c.y*.7152f+c.z*.0722f;}
+inline float3 dyRGBHSV(float3 c){
+ float mx=c.x>c.y?(c.x>c.z?c.x:c.z):(c.y>c.z?c.y:c.z);
+ float mn=c.x1e-8f){if(mx==c.x)h=(c.y-c.z)/d;else if(mx==c.y)h=(c.z-c.x)/d+2;else h=(c.x-c.y)/d+4;h/=6;if(h<0)h+=1;}
+ return float3{h,mx>1e-8f?d/mx:0,mx};
+}
+inline float3 dyHSVRGB(float3 h){
+ if(!isfinite(h.x))return float3{h.x,h.x,h.x};
+ float h6=(h.x-floor(h.x))*6;int k=int(floor(h6));float f=h6-k;
+ float p=h.z*(1-h.y),q=h.z*(1-h.y*f),t=h.z*(1-h.y*(1-f));
+ switch(k){case 0:return float3{h.z,t,p};case 1:return float3{q,h.z,p};case 2:return float3{p,h.z,t};case 3:return float3{p,q,h.z};case 4:return float3{t,p,h.z};default:return float3{h.z,p,q};}
+}
+// HSL tools are an independent implementation. Extended-range RGB is translated
+// and scaled into a unit working interval, then restored without clipping HDR or
+// negative values. Neutral controls bypass this conversion exactly.
+inline float3 dyRGBHSL(float3 c){
+ float mx=c.x>c.y?(c.x>c.z?c.x:c.z):(c.y>c.z?c.y:c.z);
+ float mn=c.x1e-8f){
+ if(mx==c.x)h=(c.y-c.z)/delta;else if(mx==c.y)h=(c.z-c.x)/delta+2;else h=(c.x-c.y)/delta+4;
+ h/=6;if(h<0)h+=1;
+ float denominator=l<.5f?mx+mn:2-mx-mn;
+ s=denominator>1e-8f?delta/denominator:0;
+ }
+ return float3{h,dyClamp(s,0,1),l};
+}
+inline float3 dyHSLRGB(float3 h){
+ if(!isfinite(h.x))return float3{h.x,h.x,h.x};
+ float light=dyClamp(h.z,0,1),sat=dyClamp(h.y,0,1);
+ float chroma=(light<.5f?2*light:2*(1-light))*sat;
+ float hue=(h.x-floor(h.x))*6,part=hue-floor(hue/2)*2;
+ float second=chroma*(1-(part>1?part-1:1-part));
+ float3 c;switch(int(floor(hue))){
+ case 0:c=float3{chroma,second,0};break;case 1:c=float3{second,chroma,0};break;
+ case 2:c=float3{0,chroma,second};break;case 3:c=float3{0,second,chroma};break;
+ case 4:c=float3{second,0,chroma};break;default:c=float3{chroma,0,second};break;
+ }
+ return c+float3{light-chroma*.5f,light-chroma*.5f,light-chroma*.5f};
+}
+inline float dyHueDistance(float a,float b){float d=a-b;d-=floor(d+.5f);return d<0?-d:d;}
+inline float dyLightnessShift(float light,float amount){
+ amount=dyClamp(amount,-1,1);return amount>=0?light+(1-light)*amount:light*(1+amount);
+}
+inline float3 dyHSLTools(float3 c,DYREF DYGrade& p){
+ bool quick=p.hslHue!=0||p.hslSaturation!=1||p.hslLightness!=0,vectors=false;
+ for(int i=0;i<7;i++)vectors=vectors||p.vectorHue[i]!=0||p.vectorSaturation[i]!=1||p.vectorLightness[i]!=0;
+ if(!quick&&!vectors)return c;
+ // Bounded finite input also prevents a huge channel span from overflowing.
+ c=dyLimit(c);
+ float minimum=c.xc.y?(c.x>c.z?c.x:c.z):(c.y>c.z?c.y:c.z);
+ float offset=minimum<0?minimum:0,scale=maximum-offset;if(scale<1)scale=1;
+ float3 base=float3{offset,offset,offset};float3 hsl=dyRGBHSL((c-base)/scale);
+ if(quick){hsl.x+=p.hslHue;hsl.x-=floor(hsl.x);hsl.y=dyClamp(hsl.y*p.hslSaturation,0,1);hsl.z=dyLightnessShift(hsl.z,p.hslLightness);}
+ if(vectors){
+ // Select all zones from one immutable hue. A changed vector never moves
+ // the selection region of a later vector. Neutral pixels receive no tint.
+ float hue=hsl.x,hueShift=0,saturation=1,lightness=0;
+ float chromaWeight=dySmooth(0,.06f,hsl.y);
+ for(int i=0;i<7;i++){
+ if(p.vectorHue[i]==0&&p.vectorSaturation[i]==1&&p.vectorLightness[i]==0)continue;
+ float center=i<6?float(i)/6:p.skinHue;
+ float weight=(1-dySmooth(0,dyClamp(p.vectorWidth[i],1.f/720,.5f),dyHueDistance(hue,center)))*chromaWeight;
+ hueShift+=p.vectorHue[i]*weight;saturation+=(p.vectorSaturation[i]-1)*weight;lightness+=p.vectorLightness[i]*weight;
+ }
+ hsl.x+=hueShift;hsl.y=dyClamp(hsl.y*saturation,0,1);hsl.z=dyLightnessShift(hsl.z,lightness);
+ }
+ return dyHSLRGB(hsl)*scale+base;
+}
+inline int dySpiderIndex(int s,int ring){return ring<=0?80:((s+16)%16)*5+(ring>5?4:ring-1);}
+inline float3 dySpider(float3 c,DYREF DYGrade& p){
+ float3 hsv=dyRGBHSV(c);if(hsv.z<=1e-8f)return c;float u=hsv.x*16,v=dyClamp(hsv.y,0,1)*5;
+ if(!isfinite(u)||!isfinite(v))return c;
+ int s=int(floor(u)),r=int(floor(v));float a=u-s,b=v-r;
+ int i00=dySpiderIndex(s,r),i10=dySpiderIndex(s+1,r),i01=dySpiderIndex(s,r+1),i11=dySpiderIndex(s+1,r+1);
+ float x=dyMix(dyMix(p.spiderX[i00],p.spiderX[i10],a),dyMix(p.spiderX[i01],p.spiderX[i11],a),b)-.5f;
+ float y=dyMix(dyMix(p.spiderY[i00],p.spiderY[i10],a),dyMix(p.spiderY[i01],p.spiderY[i11],a),b)-.5f;
+ // Compensate the chord contraction of the polar control mesh, so a neutral mesh is identity.
+ float theta=hsv.x*6.28318530718f,rad=hsv.y*.5f;
+ float ax=0,ay=0;
+ for(int j=0;j<4;j++){
+ int ss=s+(j%2),rr=r+(j/2);rr=rr>5?5:rr;
+ float w=(j%2?a:1-a)*(j/2?b:1-b);
+ float ang=float(ss%16)*6.28318530718f/16;
+ ax+=cos(ang)*float(rr)*.1f*w;ay+=sin(ang)*float(rr)*.1f*w;
+ }
+ x+=cos(theta)*rad-ax;y+=sin(theta)*rad-ay;
+ // Metal fast atan2(0,0) is undefined. A mapped neutral has no hue;
+ // return its luminance directly, while still allowing a moved center to tint it.
+ if(x*x+y*y<1e-16f)return float3{hsv.z,hsv.z,hsv.z};
+ float hue=atan2(y,x)/6.28318530718f;if(hue<0)hue+=1;
+ return dyHSVRGB(float3{hue,sqrt(x*x+y*y)*2,hsv.z});
+}
+inline float dyCurveControls(float x,DYREF float* controls){
+ // Monotone cubic interpolation of five fixed abscissas; zero controls yield exact identity.
+ // Preserve invalid color for the caller's transfer policy, without ever
+ // converting NaN to an integer or using it as an array subscript.
+ if(!isfinite(x))return x;
+ float t=dyClamp(x,0,1)*4;int i=int(floor(t));if(i>3)i=3;t-=i;
+ float y0=float(i)*.25f+controls[i],y1=float(i+1)*.25f+controls[i+1];
+ float d=(y1-y0)*4;
+ float left=i>0?(y0-(float(i-1)*.25f+controls[i-1]))*4:d;
+ float right=i<3?((float(i+2)*.25f+controls[i+2])-y1)*4:d;
+ float m0=left*d<=0?0:2*left*d/(left+d),m1=right*d<=0?0:2*right*d/(right+d);
+ float t2=t*t,t3=t2*t;float out=(2*t3-3*t2+1)*y0+(t3-2*t2+t)*m0*.25f+(-2*t3+3*t2)*y1+(t3-t2)*m1*.25f;
+ return x<0?x+controls[0]:(x>1?x+controls[4]:out);
+}
+inline float dyCurve(float x,DYREF DYGrade& p){return dyCurveControls(x,p.curve);}
+#ifdef __METAL_VERSION__
+#define DYSPIDER_BUFFER device const
+#else
+#define DYSPIDER_BUFFER const
+#endif
+inline bool dySpiderResolution(int n){return n==6||n==8||n==12||n==16||n==24;}
+inline int dyMeshIndex(int hue,int ring,int hues,int rings){return ring<=0?hues*rings:((hue+hues)%hues)*rings+(ring>rings?rings-1:ring-1);}
+// Samples are XY displacements from the undeformed polar mesh, interleaved.
+// This avoids polygon chord contraction and gives an exactly neutral mesh.
+inline float3 dyVariableSpider(float3 c,int hues,int rings,DYSPIDER_BUFFER float* samples){
+ float3 hsv=dyRGBHSV(c);if(hsv.z<=1e-8f)return c;
+ float u=hsv.x*hues,v=dyClamp(hsv.y,0,1)*rings;if(!isfinite(u)||!isfinite(v))return c;
+ int h=int(floor(u)),r=int(floor(v));float a=u-h,b=v-r,dx=0,dy=0;
+ for(int j=0;j<4;j++){int i=dyMeshIndex(h+j%2,r+j/2,hues,rings);float w=(j%2?a:1-a)*(j/2?b:1-b);dx+=samples[2*i]*w;dy+=samples[2*i+1]*w;}
+ if(dx==0&&dy==0)return c;
+ float theta=hsv.x*6.28318530718f,x=cos(theta)*hsv.y*.5f+dx,y=sin(theta)*hsv.y*.5f+dy;
+ if(x*x+y*y<1e-16f)return float3{hsv.z,hsv.z,hsv.z};
+ float hue=atan2(y,x)/6.28318530718f;if(hue<0)hue+=1;
+ return dyHSVRGB(float3{hue,sqrt(x*x+y*y)*2,hsv.z});
+}
+inline float3 dyGradeColor(float3 c,DYREF DYGrade& p,int hues=0,int rings=0,DYSPIDER_BUFFER float* mesh=nullptr){
+ c*=pow(2.f,p.exposure);
+ c*=float3{pow(2.f,p.temperature*.22f+p.tint*.08f),pow(2.f,-p.tint*.16f),pow(2.f,-p.temperature*.22f+p.tint*.08f)};
+ for(int k=0;k<3;k++){
+ float v=c[k]+p.lift[k]*(1-c[k]);v*=1+p.gain[k];
+ v=v>=0?dySafePow(v,1.f/dyClamp(1+p.midtone[k],.1f,4.f)):v;
+ v=(v-p.blackPoint)/(p.whitePoint-p.blackPoint>1e-5f?p.whitePoint-p.blackPoint:1e-5f);
+ v=(v-.5f)*p.contrast+.5f;
+ v+=p.shadows*.22f*(1-dySmooth(0,.65f,v))+p.highlights*.22f*dySmooth(.3f,1,v);
+ v=v>=0?dySafePow(v,1.f/dyClamp(p.gamma,.1f,10.f)):v;c[k]=dyCurve(v,p);
+ bool rgbCurveActive=false;for(int j=0;j<5;j++)rgbCurveActive=rgbCurveActive||p.rgbCurve[k][j]!=0;
+ if(rgbCurveActive)c[k]=dyCurveControls(c[k],p.rgbCurve[k]);
+ }
+ float y=dyLuma(c);c=float3{y,y,y}+(c-float3{y,y,y})*p.saturation;
+ if(p.spiderEnabled)c=hues?dyVariableSpider(c,hues,rings,mesh):dySpider(c,p);
+ c=dyHSLTools(c,p);
+ bool mixerActive=false;for(int i=0;i<9;i++)mixerActive=mixerActive||p.channelMixer[i]!=(i%4==0?1:0);
+ if(mixerActive){float3 input=c;for(int row=0;row<3;row++)c[row]=p.channelMixer[row*3]*input.x+p.channelMixer[row*3+1]*input.y+p.channelMixer[row*3+2]*input.z;}
+ return c;
+}
+inline float dyMask(float x,float y,DYREF DYGrade& p){
+ float aspect=p.imageAspect>0?p.imageAspect:1;
+ float dx=(x-p.maskX)*aspect,dy=y-p.maskY,ca=cos(p.maskAngle),sa=sin(p.maskAngle);
+ float u=(dx*ca+dy*sa)/(p.maskW*aspect*.5f),v=(-dx*sa+dy*ca)/(p.maskH*.5f);
+ float d=sqrt(u*u+v*v);float a=1-dySmooth(1-dyClamp(p.feather,.001f,.99f),1,d);
+ return p.maskInvert?1-a:a;
+}
+inline float3 dyLocal(float3 c,float a,DYREF DYGrade& p){
+ float3 l=c*pow(2.f,p.localExposure);float y=dyLuma(l);
+ l=float3{y,y,y}+(l-float3{y,y,y})*p.localSaturation;return c+(l-c)*a;
+}
+#ifndef __METAL_VERSION__
+inline DYGrade dyDefaultGrade(){
+ DYGrade p{};p.contrast=p.saturation=p.whitePoint=p.gamma=p.lutMix=p.mix=p.localSaturation=1;
+ p.hslSaturation=1;p.skinHue=1.f/12;
+ for(int i=0;i<7;i++){p.vectorSaturation[i]=1;p.vectorWidth[i]=i<6?1.f/6:1.f/12;}
+ for(int i=0;i<3;i++)p.channelMixer[i*4]=1;
+ p.imageAspect=1;p.maskX=p.maskY=.5f;p.maskW=p.maskH=.3f;p.feather=.25f;
+ for(int s=0;s<16;s++)for(int r=1;r<=5;r++){int i=dySpiderIndex(s,r);float a=s*6.28318530718f/16;p.spiderX[i]=.5f+cos(a)*r*.1f;p.spiderY[i]=.5f+sin(a)*r*.1f;}
+ p.spiderX[80]=p.spiderY[80]=.5f;return p;
+}
+inline DYGrade dySanitizeGrade(DYGrade p){
+ DYGrade d=dyDefaultGrade();float*a=(float*)&p;const float*b=(const float*)&d;
+ for(size_t i=0;i
+#include
+#include
+#include
+namespace dy {
+enum {SpiderMeshCapacity=24*23+1};
+// Fixed, zero-initialized archive layout. Counts include the neutral center on
+// the saturation axis: Resolve's 6x6 is six hues and five rings plus center.
+struct SpiderMesh {int hues,rings;float x[SpiderMeshCapacity],y[SpiderMeshCapacity];uint8_t pins[SpiderMeshCapacity];};
+inline int meshCount(const SpiderMesh&m){return m.hues*m.rings+1;}
+inline int meshIndex(const SpiderMesh&m,int h,int r){return dyMeshIndex(h,r,m.hues,m.rings);}
+inline bool meshBoundary(const SpiderMesh&m,int i){return i==meshCount(m)-1||i%m.rings==m.rings-1;}
+inline simd_float2 meshNeutral(const SpiderMesh&m,int i){if(i==meshCount(m)-1)return {.5f,.5f};float a=float(i/m.rings)*6.28318530718f/m.hues,r=float(i%m.rings+1)*.5f/m.rings;return {.5f+cos(a)*r,.5f+sin(a)*r};}
+inline SpiderMesh neutralMesh(int hues=6,int saturation=6){SpiderMesh m{};m.hues=hues;m.rings=saturation-1;for(int i=0;i4||fabs(m.y[i])>4||m.pins[i]>1||(!m.pins[i]&&meshBoundary(m,i)))return false;return true;}
+inline SpiderMesh legacyMesh(const DYGrade&g,const uint8_t*pins=nullptr){auto m=neutralMesh(16,6);for(int i=0;i<81;i++){m.x[i]=g.spiderX[i];m.y[i]=g.spiderY[i];m.pins[i]=meshBoundary(m,i)||(pins&&pins[i]);}return m;}
+inline bool legacyMeshNeutral(const DYGrade&g){auto d=dyDefaultGrade();return !memcmp(g.spiderX,d.spiderX,sizeof(g.spiderX))&&!memcmp(g.spiderY,d.spiderY,sizeof(g.spiderY));}
+inline simd_float2 meshDelta(const SpiderMesh&m,float hue,float saturation){float u=hue*m.hues,v=saturation*m.rings;int h=int(floor(u)),r=int(floor(v));float a=u-h,b=v-r;simd_float2 d{};for(int j=0;j<4;j++){int i=meshIndex(m,h+j%2,r+j/2);auto q=meshNeutral(m,i);float w=(j%2?a:1-a)*(j/2?b:1-b);d+=(simd_float2{m.x[i],m.y[i]}-q)*w;}return d;}
+inline SpiderMesh resampleMesh(const SpiderMesh&from,int hues,int saturation){if(from.hues==hues&&from.rings+1==saturation)return from;auto m=neutralMesh(hues,saturation);for(int i=0;i meshSamples(const SpiderMesh&m){std::vectors(2*meshCount(m));for(int i=0;i&selected,float dx,float dy){auto m=start;if(selected.none()||!std::isfinite(dx)||!std::isfinite(dy))return m;
+ auto delta=[&](int i){return simd_float2{selected[i]?dx:0,selected[i]?dy:0};};auto apply=[&](int i,simd_float2 d){m.x[i]=dyClamp(start.x[i]+d.x,-4,4);m.y[i]=dyClamp(start.y[i]+d.y,-4,4);};int center=meshCount(m)-1;apply(center,delta(center));
+ for(int h=0;hCFBundlePackageType
APPL
CFBundleShortVersionString
- 1.2.0
+ 1.3.0
CFBundleVersion
- 17
+ 18
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
NSHumanReadableCopyright