working on it ...

Filters

Explore Public Snippets

Sort by

Found 254 snippets matching: "background color"

    public by ronrihoo modified Sep 9, 2017  203  3  5  1

    libGDX Table background color

    Create an instance of this class by giving the constructor the filename of a white PNG from your project resources. Then, use one of the instance's setColor(red, green, blue, alpha) methods. Finally, pass the instance to the libGDX Table using the Table's setBackground(Drawable drawable) method. This is not meant to be a perfect solution for all --
    import com.badlogic.gdx.Gdx;
    import com.badlogic.gdx.graphics.Color;
    import com.badlogic.gdx.graphics.Texture;
    import com.badlogic.gdx.graphics.g2d.Batch;
    import com.badlogic.gdx.graphics.g2d.Sprite;
    import com.badlogic.gdx.graphics.g2d.TextureRegion;
    import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
    
    public class BackgroundColor implements Drawable {
    	
    	private Float x;
    	private Float y;
    	private Float width;
    	private Float height;
    	
    	private Boolean fillParent;
    	
    	private String filename;
    	private Texture texture;
    	private TextureRegion textureRegion;
    	private Sprite sprite;
    	private Color color;
    	
    	public BackgroundColor(String filename) {
    		this(filename, 0.0f, 0.0f, 0.0f, 0.0f);
    	}
    	
    	public BackgroundColor(String filename, float x, float y) {
    		this(filename, x, y, 0.0f, 0.0f);
    	}
    	
    	public BackgroundColor(String filename, float x, float y, float width, float height) {
    		this.setPosition(x, y);
    		this.setSize(width, height);
    		initialize(filename);
    	}
    	
    	private void initialize(String filename) {
    		setFilename(filename);
    		if (x == null || y == null)
    			setPosition();	// x = 0.0f; y = 0.0f;
    		if (width == null || height == null || width < 0.0f || height < 0.0f)
    			setSize();		// width = 0.0f; height = 0.0f;
    		if (color == null)
    			setColor(255, 255, 255, 255);
    		if (sprite == null) {
    			try {
    				setSprite();
    			} catch (Exception e) {
    				System.err.println(e);
    			}
    		}
    		if (fillParent == null)
    			fillParent = true;
    	}
    	
    	private void setTexture() {
    		if (texture != null)
    			texture.dispose();
    		texture = new Texture(Gdx.files.internal(getFilename()));
    	}
    	
    	private void setTextureRegion() {
    		textureRegion = new TextureRegion(texture, (int) getWidth(), (int) getHeight());
    	}
    	
    	private void setSprite() {
    		if (texture == null)
    			setTexture();
    		setTextureRegion();
    		sprite = new Sprite(textureRegion);
    		setSpriteColor();
    	}
    	
    	private void setSpriteColor() {
    		sprite.setColor(color.r, color.g, color.b, color.a);
    	}
    	
    	private void setPosition() {
    		this.x = 0.0f;
    		this.y = 0.0f;
    	}
    	
    	private void setPosition(float x, float y) {
    		this.x = x;
    		this.y = y;
    	}
    	
    	private void setSize() {
    		this.width = sprite.getWidth();
    		this.height = sprite.getHeight();
    	}
    	
    	private void setSize(float width, float height) {
    		this.width = width;
    		this.height = height;
    	}
    	
    	public void setColor(int r, int g, int b, int a) {
    		color = new Color(r/255f, g/255f, b/255f, a/255f);
    	}
    
    	public void setColor(float r, float g, float b, float a) {
    		color = new Color(r/255f, g/255f, b/255f, a/255f);
    	}
    	
    	private void setSpritePosition(float x, float y) {
    		sprite.setX(x);
    		sprite.setY(y);
    	}
    	
    	private void updateSprite(float x, float y, float width, float height) {
    		if (fillParent) {
    			setSpritePosition(x, y);
    			if (width != textureRegion.getRegionWidth() || 
    					height != textureRegion.getRegionHeight()) {
    				setSize(width, height);
    				setSprite();
    			}
    		}
    	}
    	
    	@Override
    	public void draw(Batch batch, float x, float y, float width, float height) {
    		updateSprite(x, y, width, height);
    		sprite.draw(batch);
    	}
    
    	@Override
    	public float getLeftWidth() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setLeftWidth(float leftWidth) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public float getRightWidth() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setRightWidth(float rightWidth) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public float getTopHeight() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setTopHeight(float topHeight) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public float getBottomHeight() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setBottomHeight(float bottomHeight) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public float getMinWidth() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setMinWidth(float minWidth) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	@Override
    	public float getMinHeight() {
    		// TODO Auto-generated method stub
    		return 0;
    	}
    
    	@Override
    	public void setMinHeight(float minHeight) {
    		// TODO Auto-generated method stub
    		
    	}
    	
    	private void setFilename(String filename) {
    		this.filename = filename;
    	}
    	
    	private String getFilename() {
    		return filename;
    	}
    
    	public float getX() {
    		return x;
    	}
    
    	public void setX(float x) {
    		this.x = x;
    	}
    
    	public float getY() {
    		return y;
    	}
    
    	public void setY(float y) {
    		this.y = y;
    	}
    
    	public float getWidth() {
    		return width;
    	}
    
    	public void setWidth(float width) {
    		this.width = width;
    	}
    
    	public float getHeight() {
    		return height;
    	}
    
    	public void setHeight(float height) {
    		this.height = height;
    	}
    
    	public Boolean getFillParent() {
    		return fillParent;
    	}
    
    	public void setFillParent(Boolean fillParent) {
    		this.fillParent = fillParent;
    	}
    
    }
    																																				

    public by ronrihoo modified Friday at 3:37:37 AM  122  0  5  0

    Example usage for the BackgroundColor class

    Companion usage example for the arbitrary libGDX Table BackgroundColor class.
    BackgroundColor backgroundColor = new BackgroundColor("white_color_texture.png");
    backgroundColor.setColor(2, 179, 228, 255); // r, g, b, a
    table.setBackground(backgroundColor);																														

    public by sherazam modified Mar 30, 2016  2782  0  5  0

    How to Add Text with Transparent Color in PDF File using .NET

    // Enter here the actual content of the snippet.      
    //The following code snippet shows how to add text with transparent color.
    
    //C# Code Sample
    
    // create Document instance
    Document doc = new Document();
    // create page to pages collection of PDF file
    Aspose.Pdf.Page page = doc.Pages.Add();
    
    // create Graph object 
    Aspose.Pdf.Drawing.Graph canvas = new Aspose.Pdf.Drawing.Graph(100, 400);
    // create rectangle instance with certain dimensions
    Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400);
    // create color object from Alpha color channel
    rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)));
    // add rectanlge to shapes collection of Graph object
    canvas.Shapes.Add(rect);
    // add graph object to paragraphs collection of page object
    page.Paragraphs.Add(canvas);
    // set value to not change position for graph object
    canvas.IsChangePosition = false;
    
    // create TextFragment instance with sample value
    TextFragment text = new TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ");
    // create color object from Alpha channel
    Aspose.Pdf.Color color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0);
    // set color information for text instance
    text.TextState.ForegroundColor = color;
    // add text to paragraphs collection of page instance
    page.Paragraphs.Add(text);
    // save PDF file
    doc.Save("c:/Transparent_Text.pdf");
    
    //VB.NET Code Sample
    
    ' create Document instance
    Dim doc As Document = New Document()
    ' create page to pages collection of PDF file
    Dim page As Aspose.Pdf.Page = doc.Pages.Add()
    
    ' create Graph object
    Dim canvas As Aspose.Pdf.Drawing.Graph = New Aspose.Pdf.Drawing.Graph(100, 400)
    ' create rectangle instance with certain dimensions
    Dim rect As Aspose.Pdf.Drawing.Rectangle = New Aspose.Pdf.Drawing.Rectangle(100, 100, 400, 400)
    ' create color object from Alpha color channel
    rect.GraphInfo.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(128, System.Drawing.Color.FromArgb(12957183)))
    ' add rectanlge to shapes collection of Graph object
    canvas.Shapes.Add(rect)
    ' add graph object to paragraphs collection of page object
    page.Paragraphs.Add(canvas)
    ' set value to not change position for graph object
    canvas.IsChangePosition = False
    
    ' create TextFragment instance with sample value
    Dim text As Aspose.Pdf.Text.TextFragment = New TextFragment("transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text transparent text ")
    ' create color object from Alpha channel
    Dim color As Aspose.Pdf.Color = Aspose.Pdf.Color.FromArgb(30, 0, 255, 0)
    ' set color information for text instance
    Text.TextState.ForegroundColor = color
    ' add text to paragraphs collection of page instance
    page.Paragraphs.Add(Text)
    ' save PDF file
    doc.Save("c:/Transparent_Text.pdf")
          

    public by Geometry modified Aug 6, 2016  1237  0  6  0

    Show: Displays an image on the screen.

    Displays an image on the screen. The text to display in the title bar of the image box. The image to show. How to display the image inside the image box. The width of the image box. The height of the image box. The background color to use in the window. Default is .
    /// <summary>
    ///   Displays an image on the screen.
    /// </summary>
    /// 
    /// <param name="title">The text to display in the title bar of the image box.</param>
    /// <param name="image">The image to show.</param>
    /// <param name="sizeMode">How to display the image inside the image box.</param>
    /// <param name="width">The width of the image box.</param>
    /// <param name="height">The height of the image box.</param>
    /// <param name="backColor">The background color to use in the window. 
    ///   Default is <see cref="Color.Black"/>.</param>
    /// 
    public static DialogResult Show(string title, UnmanagedImage image,
        PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
    {
        return Show(title, image.ToManagedImage(), sizeMode, width, height, backColor);
    }

    external by Dennis Seah modified Aug 22, 2014  13625  191  4  0

    SAPUI5: Set background color for column in sap.ui.table.Table

    SAPUI5: Set background color for column in sap.ui.table.Table: gistfile1.js
    <!DOCTYPE HTML>
    <html>
    <head>
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    
    <script id="sap-ui-bootstrap" 
        type="text/javascript"
        data-sap-ui-libs="sap.ui.table,sap.ui.commons"
        data-sap-ui-theme="sap_bluecrystal" 
        src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js">
    </script>
    
    <style>
    .coloredTable {
        background-color: rgba(99,99,99, 0.1);
    }
    </style>
    
    <script>
    jQuery(function() {
        sap.ui.table.Column.extend('ColoredColumnTable', {
            metadata: {
                properties: {
                    coloredStyleClass: 'string'
                }
            }               
        });
    
    
        var aData = [
            {name: "Dente", company: "http://www.sap.com", status: 1},
            {name: "Friese",  company: "Google", status: 1},
            {name: "Mann", company: "http://www.sap.com", status: 2},
            {name: "Schutt", company: "SAP", status: 3}
        ];
    
        var oTable = new sap.ui.table.Table({
            width: '350px',
            selectionMode: sap.ui.table.SelectionMode.None,
        });
    
        oTable.addColumn(new ColoredColumnTable({
            label: new sap.ui.commons.Label({text: "Name"}), 
            template: new sap.ui.commons.TextView({text:"{name}"}),
    coloredStyleClass: 'coloredTable'
        }));
    
        oTable.addColumn(new sap.ui.table.Column({
            label: new sap.ui.commons.Label({text: "Company"}), 
            template: new sap.ui.commons.TextView({text:"{company}"})
        }));
    
    
        oTable.onAfterRendering = function() {
            if (sap.ui.table.Table.prototype.onAfterRendering) {
                sap.ui.table.Table.prototype.onAfterRendering.apply(this, arguments);
            }
            var cols = this.getColumns();
    
            for (var i = 0; i < cols.length; i++) {
                if (cols[i].getColoredStyleClass) {
                    var coloredCol = cols[i].getColoredStyleClass();  
                    if (coloredCol) {
                        var th = this.$().find('.sapUiTableColHdr').find('.sapUiTableCol');
                        $(th[i]).addClass(coloredCol);
    
                        var rows = this.$().find('.sapUiTableTr');
    
                        for(var j = 0; j < rows.length; j++) {
                            var r = rows[j];
                            var tds = $(r).find('td');
                            $(tds[i]).addClass(coloredCol);
                        }
                    }
                }
            }
        }
    
        var oModel = new sap.ui.model.json.JSONModel();
        oModel.setData(aData);
        oTable.setModel(oModel);
        oTable.bindRows("/");
        oTable.placeAt("content");
    })
    </script>
    
    </head>
    <body class="sapUiBody">
      <div id="content"></div>
    </body>
    </html>
    
    

    external by amckayay modified Feb 1, 2016  29812  0  3  0

    Sass file that pairs with background-color.js gist, animates background color on scoll. Can be seen live here: http://alisonleemckay.com/

    Sass file that pairs with background-color.js gist, animates background color on scoll. Can be seen live here: http://alisonleemckay.com/: background-color.scss
    // Basic variables
    $header-font: 'Playfair Display', serif;
    $body-font: 'Roboto', Arial, sans-serif;
    
    $color1: #A8EBFF;
    $color2: #FFE2E5;
    $color3: #BAEDC6;
    
    $navy: #334D70;
    $link-color: #269196;
    
    $color1-link: #269196;
    $color2-link: #D66457;
    $color3-link: #418651;
    
    // Begin styles
    body {
    	background-color: $color1;
    	color: $navy;
    	font-size: 13px;
    	font-family: $body-font;
    	font-weight: 300;
    	-webkit-transition: all 4s ease;
    	transition: all 4s ease;
    
    	&.color1 {
    		background-color: $color1;
    
    		.baby-header {
    			background-color: $color1;
    		}
    
    		a {
    			color: $color1-link;
    
    			&:hover,
    			&:focus {
    				text-shadow: 0px 0px 2px $color1-link;
    			}
    		}
    	}
    
    	&.color2 {
    		background-color: $color2;
    
    		.baby-header {
    			background-color: $color2;
    		}
    
    		a {
    			color: $color2-link;
    
    			&:hover,
    			&:focus {
    				text-shadow: 0px 0px 2px $color2-link;
    			}
    		}
    	}
    
    	&.color3 {
    		background-color: $color3;
    
    		.baby-header {
    			background-color: $color3;
    		}
    
    		a {
    			color: $color3-link;
    
    			&:hover,
    			&:focus {
    				text-shadow: 0px 0px 2px $color3-link;
    			}
    		}
    	}
    }
    
    

    external by Keri Hazelton modified Apr 29, 2016  68  0  1  0

    JavaScript file with #message-box background-color changed and user input in contact-form

    JavaScript file with #message-box background-color changed and user input in contact-form : scripts.js
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    
    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
    
    $(document).ready(function() {
    
    // Smooth Scrolling //	
    	var $root = $('html, body');
        $('.navbar-nav a').click(function() {
            var href = $.attr(this, 'href');
            $root.animate({
                scrollTop: $(href).offset().top
            }, 500, function () {
                window.location.hash = href;
            });
            return false;
        });
    
    // Stellar //
     $("#about").stellar();
    $("#faq").stellar();
    $(function() {
        $("#item1").tooltip();
      });
    
    //Tooltip
    
     $(function () {
        $('[data-toggle="tooltip"]').tooltip(); 
      });
    
    });
    
    
    //Textarea background color//
    
    $("#message-box").css("background-color", "#b3ffb3");
    
    
    //Message Box Comment //
    
    $("#contact-button").on("click", function() {
    	var comment=$("#message-box").val();
    	console.log(comment);
    	$("#visible-comment").html("Thank you for commenting!");
    	$("#message.box").hide();
    	return false;
    });
    
    

    external by theDustin modified Jan 19, 2015  57  0  1  0

    Calculate the textcolor (Black or White) by background-color (YIQ-Contrast) [http://24ways.org/2010/calculating-color-contrast/]

    Calculate the textcolor (Black or White) by background-color (YIQ-Contrast) [http://24ways.org/2010/calculating-color-contrast/]: yiq-color-contrast.php
    <?php
    
    $fYIQ = (($iRed * 299) + ($iGreen * 587) + ($iBlue * 114)) / 1000;
    
    if($fYIQ >= 128){
        echo 'Black textcolor.';
    } else {
    	echo 'White textcolor.';
    }
    
    
    

    external by David Lormor modified Feb 24, 2015  22  0  1  0

    Bind Ember component background-color to attribute

    Bind Ember component background-color to attribute: my-component.js
    export default Ember.Component.extend({
      attributeBindings: ['backgroundColor'],
      backgroundColor: 'red', // default background color
      setBackgroundColor: function() {
        this.$().css('background-color', this.get('background-color'))
      }.observes('backgroundColor')
    });
    
    

    external by morekvn modified Jul 12, 2016  22  0  1  0

    Using Jquery to change the background color based on scroll pixel position. When scrolling down after a div the nav-bar gets a new background-color the nav-bar should be fixed at top.

    Using Jquery to change the background color based on scroll pixel position. When scrolling down after a div the nav-bar gets a new background-color the nav-bar should be fixed at top.: navscroll.js
    $(document).ready(function(){       
       var scroll_start = 0;
       var startchange = $('#startchange');
       var offset = startchange.offset();
        if (startchange.length){
       $(document).scroll(function() { 
          scroll_start = $(this).scrollTop();
          if(scroll_start > offset.top) {
              $(".navbar-default").css('background-color', '#f0f0f0');
           } else {
              $('.navbar-default').css('background-color', 'transparent');
           }
       });
        }
    });
    
    
    • Public Snippets
    • Channels Snippets