简体   繁体   English

在Flash / Animate中以视觉/手动方式以及通过代码处理颜色的方法?

[英]Way to handle colors visually/manually AND with code, in Flash/Animate?

I used to use a lot of Filters in Animate, and it was glorious because I could make a color filter by hand, see what it looks like, and then integrate code into that too, eg: 我曾经在Animate中使用过很多滤镜,这很辉煌,因为我可以手工制作滤色器,查看滤镜的外观,然后将代码集成到其中,例如:

object.filters = e.currentTarget.filters;

But I'm trying to be good and stay away from filters to reduce processing power etc. Plus, filters don't take in hex codes. 但是我正在努力做一个好人,远离过滤器以减少处理能力等。此外,过滤器不接受十六进制代码。 So I'm trying to use colorTransforms. 所以我正在尝试使用colorTransforms。 But now things get really unwieldly because I figure out which colors I want, write down all the hex codes in Notepad, then write code to transform things to that color. 但是现在事情变得非常麻烦了,因为我找出了我想要的颜色,在记事本中写下了所有十六进制代码,然后编写了将代码转换为该颜色的代码。 And I still can't SEE the colours interacting until I publish the file. 在发布文件之前,我仍然看不到交互的颜色。 Isn't there SOME way to manually fiddle with colorTransforms? 有没有办法手动摆弄colorTransforms? Maybe the Advanced section under Color Effect -> Style? 也许是“色彩效果->样式”下的“高级”部分?

How I imagine this happening in my fantasy is: I have a few movieclips which interact to create a fabric swatch. 我如何想象这种幻想在我的幻想中发生了:我有一些电影剪辑,它们相互作用以创建一个织物样本。 I fiddle with the colorTransform or SOMEhow apply a hex code to them manually (not dynamically in code), and then I can use those swatches to dynamically color other things, something like: 我摆弄colorTransform或SOMEhow手动对其应用十六进制代码(而不是动态地在代码中),然后可以使用这些色板为其他东西动态着色,例如:

newFabric.topPattern.colorTransform.color = fabricSwatch.topPattern.colorTransform.color;

I know I can do this if I added the colour using code first.. but is there any way to add the colour on the stage/visually/manually and then have the code roll it forward? 我知道如果我先使用代码添加颜色,就可以做到这一点。但是有什么方法可以在舞台上/视觉/手动添加颜色,然后让代码向前滚动吗? I know I can draw a bitmap and sample a pixel's color, but the patterns all have very fine, different & complex shapes and transparencies so that won't work here :/ 我知道我可以绘制位图并采样像素的颜色,但是这些图案都具有非常精细,不同和复杂的形状和透明度,因此在这里不起作用:/

There are LOTS of tutorials out there for using colortransforms – like this one . 有很多使用colortransforms的教程-像这样的

As for using hex colors, you can convert back and forth between the various color representations very easily. 至于使用十六进制颜色,您可以轻松地在各种颜色表示形式之间来回转换。 A simple Google search turned up this snippet : 一个简单的Google搜索显示了以下代码段

var brightPinkHex:uint = 0xFF32CC;
var brightPinkRGB:Object = HexToRGB(brightPinkHex);
trace(brightPinkRGB.r+ ", " + brightPinkRGB.g + ", " + brightPinkRGB.b);

function HexToRGB(value:uint):Object {  
    var rgb:Object = new Object();
    rgb.r = (value >> 16) & 0xFF
    rgb.g = (value >> 8) & 0xFF
    rgb.b = value & 0xFF            
    return rgb;
}

// OUTPUT
// 255, 50, 204

Ok! 好! I have found a workaround! 我找到了解决方法! \\o/ \\ o /

I can edit the Tint manually, and even input a hex code or eye-drop a colour from my pre-made palette. 我可以手动编辑“色调”,甚至可以输入十六进制代码或从我的预制调色板中滴色。 I just have to make sure to set the "Tint" setting on the Tint to 100%. 我只需要确保将“色调”的“色调”设置设置为100%。 (Color Effect -> Style:Tint) (色彩效果->样式:色调)

Now I simply use the colorTransform code and it can pull my manually placed Tint, and transfer it to other items: 现在,我只需使用colorTransform代码,它就可以拉出我手动放置的Tint,并将其转移到其他项目:

grl.overlay.shapes.transform.colorTransform = e.currentTarget.shapes.transform.colorTransform;

I didn't even have to change my code AND this is better than filters since I can input hex codes. 我什至不必更改代码,这比过滤器要好,因为我可以输入十六进制代码。 I don't know how this will be on performance relative to filters, but someone just told me that it shouldn't be too bad since nothing is animating. 我不知道相对于滤镜,这会如何提高性能,但是有人只是告诉我,它应该不会太糟,因为没有动画。 I'm so happy :) 我很开心 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM