Antialiased Button Drawing
Site Map Feedback

Download:



 Button Tutorial
Up Buttons Circles Curves Lines

This is one of the more complex Stencils which has a full Tutorial in the Procedural Textures section describing how it works. Button drawing is very fast: each pixel in the Buttons rectangle is painted just once. To draw Buttons on a PixelBlock, mix in the CButtonStencil class below and define the SetPixel abstract method. The Button can be drawn 'Up' or 'Down', Highlighted, Clean, with Noise (smoky reflection) or with a Marbled surface.

  gColorSpline ButtonSpline;
  CButtonPainter* B=new CButtonPainter(200,100,0xFFFFFF);
  B->Button(  0, 0,125, 25, ButtonSpline, false, true , 8, CButtonStencil::Marbled);
  B->Button(125, 0, 25, 75, ButtonSpline, true , false, 8, CButtonStencil::Marbled);
  B->Button(  0,25,125, 75, ButtonSpline, false, false, 8, CButtonStencil::Marbled);
  B->Button(125,75, 25, 25, ButtonSpline, false, false, 8, CButtonStencil::Marbled);
  B->Button(150, 0, 50,100, ButtonSpline, true , true , 8, CButtonStencil::Marbled);
Button Finish Types

Adding Colour

The gColorSpline class can be used to inject some color. The following image shows how adding a greyscale color spline makes the original button image look metalic, and how adding a touch of colour makes the button look like gold:
Colour Spline examples

Button Set with Gold Metallic Finish

  gColor ButtonColors[5];
  ButtonColors[0].Set(0);
  ButtonColors[1].SetFromHSL(0.14, 0.75, 0.6); // Golds have a Hue around 0.13
  ButtonColors[2].SetFromHSL(0.1 , 0.75, 0.1); // For metallic effect simply dip down in Lightness in the middle
  ButtonColors[3].SetFromHSL(0.14, 0.75, 0.7); // Keep things dark for most of the spline
  ButtonColors[4].SetRGB(1.0, 1.0, 1.0);
  gColorSpline ButtonSpline(sizeof(ButtonColors)/sizeof(gColor), ButtonColors);

The following image shows a gold ButtonStencil with a red sphere which could be used as a slider control:
Slider with Gold Metallic Finish
The sphere was rendered using a Sphere Shader.

You can mix in as many 'Stencils' as you like to provide all the primitives you need.

The Colours, Effects and Patterns sections have further extensions.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


 (1705) Last modified: Mon, 22 Jun 2009 19:43:07 +0100