spongey437 Posted September 12, 2007 Share Posted September 12, 2007 Still playing around with the Codelab and thought I would try to create a rainbow effect. Here is what I came up with. Run on just a blank page it will create something like this: But my use for it was to do something like this. Right now it just creates the rainbow as you see it here with the colors stretching vertically down the page. It works for selections as well, but only rectangular ones. It still creates something with weird shaped selections, but it is all screwed up and I cant seem to wrap my hands around how to program around it. Also, if I had more programming experience I would have liked to have set this up like a gradient tool, but at least for now it just does the rainbow. I have set up three selection bars for Red, Green and Blue starting colors. You can create different rainbow effects by playing with the starting colors, but the default settings will give you your standard rainbow (though for some reason the size of the image can affect how far down the color scale it gets. For example on an 800x600 image it seems to stop at light blue, but for a smaller images reaches purple and even sometimes makes it back to red - which was the intent when programming it). Here is the code in case anyone is interested. int Amount1=255; //[0,255]Red Start int Amount2=0; //[0,255]Green Start int Amount3=0; //[0,255]Blue Start void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); // Delete any of these lines you don't need Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left); long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; int l = 1; int p = 1530 / rect.Right; int r = Amount1; int g = Amount2; int b = Amount3; ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { CurrentPixel = src[x,y]; // TODO: Add pixel processing code here if (x == rect.Left) { r = Amount1; g = Amount2; b = Amount3; } switch(l) { case 1: g = g + p; if (g > 255) { g = 255; l = 2; } break; case 2: r = r - p; if (r < 0) { r = 0; l = 3; } break; case 3: b = b + p; if (b > 255) { b = 255; l = 4; } break; case 4: g = g - p; if (g < 0) { g = 0; l = 5; } break; case 5: r = r + p; if (r > 255) { r = 255; l = 6; } break; case 6: b = b - p; if (b < 0) { b = 0; l = 1; } break; } // Access RGBA values this way, for example: CurrentPixel.R = (byte)r; CurrentPixel.G = (byte)g; CurrentPixel.B = (byte)b; // CurrentPixel.A = (byte)PrimaryColor.A; dst[x,y] = CurrentPixel; } } } } Thanks to Miguel for showing me the 'switch' routine to use (which apparently runs faster than a bunch of if statements). I incorporated it into this and remembered to add an icon this time. Let me know what you think. here is the link to the plugin http://Spongey437.googlepages.com/rainbow3.dll Quote Link to comment Share on other sites More sharing options...
BoltBait Posted September 12, 2007 Share Posted September 12, 2007 This effect can already be done with this plugin: http://boltbait.googlepages.com/Gradient.dll Choose the ending colors for primary and secondary, then run the effect and choose the Long HSV method. Description of this effect can be found here: viewtopic.php?t=2294 Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
spongey437 Posted September 12, 2007 Author Share Posted September 12, 2007 This effect can already be done with this plugin:http://boltbait.googlepages.com/Gradient.dll Choose the ending colors for primary and secondary, then run the effect and choose the Long HSV method. Description of this effect can be found here: viewtopic.php?t=2294 My bad. I didnt have that one and I really had thought I had downloaded all the plugins. Quote Link to comment Share on other sites More sharing options...
barkbark00 Posted September 12, 2007 Share Posted September 12, 2007 What we really need is a gradient plugin where we can load a PdN palette file (or xml like Curves+ and Shape 3D) which would specify the colors and the order that we want the colors blended...like a custom rainbow with all of the options from BB's gradient plugin! Edit: ^^that's a long sentence! Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
Fisherman's Friend Posted September 12, 2007 Share Posted September 12, 2007 My bad. I didnt have that one and I really had thought I had downloaded all the plugins. Well, your plugin can be moved to "color" (via source). So it's useful for me as it doesn't blow up my effects menu. Thank you. Also I don't see that another plugin which can do the same is a reason to stop sharing your work. Some people like this one, some that one. I prefer yours. Quote Link to comment Share on other sites More sharing options...
BuzzKill Posted September 12, 2007 Share Posted September 12, 2007 What we really need is a gradient plugin where we can load a PdN palette file (or xml like Curves+ and Shape 3D) which would specify the colors and the order that we want the colors blended...like a custom rainbow with all of the options from BB's gradient plugin! I second that. Quote - DO NOT contact me asking for the .pdn of my avatar or the PDN logo. Thank you. Have a nice day. Link to comment Share on other sites More sharing options...
barkbark00 Posted September 12, 2007 Share Posted September 12, 2007 I third it! ...Wait, can I even do that? Quote Take responsibility for your own intelligence. -Rick Brewster Link to comment Share on other sites More sharing options...
usedHONDA Posted September 12, 2007 Share Posted September 12, 2007 I fourth it (if BB00 is allowed to third)! Quote "The greatest thing about the Internet is that you can write anything you want and give it a false source." ~Ezra Pound twtr | dA | tmblr | yt | fb Link to comment Share on other sites More sharing options...
Mr Frojo Posted September 12, 2007 Share Posted September 12, 2007 I agree, but who'll code it? Quote I'm still alive! Link to comment Share on other sites More sharing options...
MiguelPereira Posted September 12, 2007 Share Posted September 12, 2007 well this one wont render in a image with high res. I'm working on a pic with 2048x1536 it wont render the rainbow Quote [The stock on my sig is a photo I took not a render from Splatter] [My deviantART][My Gallery][My Space] Link to comment Share on other sites More sharing options...
PythonPower Posted September 17, 2007 Share Posted September 17, 2007 YAAAAAAAAY!! Now I can make rainbows! *huggles creator* *glances around at other comments* You can make those arc rainbows with Gradient? How? Quote Link to comment Share on other sites More sharing options...
Bob Posted September 17, 2007 Share Posted September 17, 2007 This effect can already be done with [my] plugin Does Spongey's code looks good, dear C# Master? Quote No. Way. I've just seen Bob. And... *poof!*—just like that—he disappears into the mist again. ~Helio Link to comment Share on other sites More sharing options...
MiguelPereira Posted September 18, 2007 Share Posted September 18, 2007 You can make those arc rainbows with Gradient? How? Use RectToPolar plugin Quote [The stock on my sig is a photo I took not a render from Splatter] [My deviantART][My Gallery][My Space] Link to comment Share on other sites More sharing options...
BoltBait Posted September 18, 2007 Share Posted September 18, 2007 You can make those arc rainbows with Gradient? How? Use RectToPolar plugin ...and if that doesn't work try Effects > Distort > Polar Inversion Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Blooper Posted October 8, 2007 Share Posted October 8, 2007 Or tube oblique. I like BB's plug-in better, but it's no reason to not publish your work indeed. Quote http://synthastic.deviantart.com http://soundcloud.com/siderealenterprise Lockerz invites are available, PM me Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.