|
I started playing around with the "button1.grg" file that comes with Aura and decided to "Rewire" it! I wanted to make buttons and boxes using a texture instead of a color. This script does that. Notice the logo at the top. It was created with this script. It allows you to load an image as a brush, then use it to create a beveled textured rectangle. The problem I ran into was that in Aura 1.0 (it's fixed in 2.0), it will only stretch an image, not tile it, when you fill with a brush. That's fine for some things, but what about seamless textures you get on the web? You don't want to stretch them, you want to tile them! This script allows you do use both.
![]()
![]() ![]() There are a few lines in the script that need to be edited, depending on what you are going to do. Like using Stretch or Tile, and how wide the bevel should be. You can save different versions if you like with the options you like best. I could have made it come up with panels to ask what option, but I wanted to to go right into it and not ask each time. I have one saved with the tile option and one with the stretch. The tile option was a bit tricky since it isn't built in to 1.0 but we save out the current brush, flip to the swap buffer, create our new brush with the "Wrapping Filter", then cut it out and stamp the new brush back down where the user selected. We also save the current brush and then reload it at the end, so you will have what you started with. You can go to the bottom of the page from here and click on the link to download this script, or follow along now as we break down the script, to show you how it does what it does. The acutal script is between the start and end George script lines. My comments will look like this < --- Comment Goes Here --- > and are not actually part of the script itself. < ---------------------------------- Start of George Script ----------------------- > // Texture Bevel // By J.L. White // (C)2000 Visual Inspirations Inc. < --- The first lines are just comment lines. Anything that starts with // is a comment --- > Param Rectangle connect "Aura Commands" Parse result command x1 y1 x2 y2 Button < --- Tells Aura what options to use, like rectangle, circle, for this we need rectangle and parse the info --- > StretchOrFill = 0 //0 = Stretch, 1 = Fill Bevel = 5 // Bevel Size TempBrush = "C:\AuraTempBrush.dip" < --- These are our editable defaults --- > if Button == 0 AColor = "LIGHT" BColor = "SHADE" else AColor = "SHADE" BColor = "LIGHT" end < --- Tell which way Light source is coming from based on mouse button clicked --- > if (x2 < x1) temp=x1 x1=x2 x2=temp end if (y2 < y1) temp=y1 y1=y2 y2=temp end < --- If user drew from right to left, we want to turn our variables around --- > b=Bevel*2 if (x2-x1 < b) x2=x1+b+1 end if (y2-y1 < b) y2=y1+b+1 end < --- Bevel size and test to make sure not bigger than rectangle --- > tv_SetDrawMode "COLOR" tv_GetAPen parse result oldr oldg oldb olda tv_SetApen 255 255 255 255 tv_BrushPower 100 < --- Set draw mode, get current color to reset later, set new color and set brush to full --- > tv_SaveMode "Deep" parse result BType tv_SaveBrush TempBrush < --- Set brush mode and save current brush to reset later --- > if StretchOrFill == 1 tv_BrushInfo parse result MyBrushWidth MyBrushHeight handleOffsetX handleOffsetY toolType brushRadius brushSmoothing tv_SpareKill tv_SpareSwap tv_AliasOff tv_PersWrap 0 0 MyBrushWidth 0 MyBrushWidth MyBrushHeight 0 MyBrushHeight 1 0 tv_AliasOn tv_BrushCut x1 y1 x2 y2 tv_SpareSwap else tv_OptimizeBrush tv_BrushStretch (x2-x1) (y2-y1) end < --- Fills main rectangle based on Stretch or Fill --- > tv_Handle 0 0 tv_Dot x1 y1 < --- Stamp down new brush --- > tv_SetApen 255 255 255 255 tv_SetDrawMode AColor tv_AreaInit tv_AreaMove x1+1 y1 tv_AreaMove x2 y1 tv_AreaMove (x2-Bevel) (y1+Bevel) tv_AreaMove (x1+Bevel)+1 (y1+Bevel) tv_AreaMove x1+1 y1 tv_AreaDraw tv_Redo tv_Redo tv_Redo tv_AreaInit tv_AreaMove x1 y1 tv_AreaMove (x1+Bevel) (y1+Bevel) tv_AreaMove (x1+Bevel) (y2-Bevel) tv_AreaMove x1 y2 tv_AreaDraw tv_Redo tv_SetDrawMode BColor tv_AreaInit tv_AreaMove x1 y2 tv_AreaMove (x1+Bevel) (y2-Bevel) tv_AreaMove (x2-Bevel)-1 (y2-Bevel) tv_AreaMove x2-1 y2 tv_AreaDraw tv_Redo tv_Redo tv_Redo tv_AreaInit tv_AreaMove x2 y1 tv_AreaMove x2 y2 tv_AreaMove (x2-Bevel) (y2-Bevel) tv_AreaMove (x2-Bevel) (y1+Bevel) tv_AreaDraw tv_Redo < --- Draw bevel around new brush. Use redo to make it more dramatic. Fixed in 2.0 --- > tv_SetDrawMode "COLOR" tv_SetApen oldr oldg oldb olda < --- Reset Mode and Color --- > tv_LoadBrush TempBrush tv_SaveMode BType < --- Load old brush back --- > exit < --- Exit program --- > < ---------------------------------- End of George Script ----------------------- > Click Here to Download TextureBevel.zip Well that does it for this one, till next time... |
Back To The Tutorial Page
Copyright © 2000 Visual Inspirations