Search Results

Search found 1682 results on 68 pages for 'colors'.

Page 18/68 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Stable random color algorithm

    - by Olmo
    Here we have an interesting real-world algorithm requirement involving colors. 1) Nice random colors: In ordeeing to draw a beautifull chart (i.e: pie chart) we need to pick a random set of Colors that: a) are different enought b) Play nicely Doesnt Look hard. For example u fix bright and saturation and divide hue in steps of 360/Num_sectors 2) Stable: given Pie1 with sectors with labes ('A','B','C') and Pie2 with sector with labels ('B','C','D'), will be nice if color('B',pie1)= color('B',pie2) and the same for 'C' and so on, so people don't get crazy when seeing similar updated charts, even if some sectors appear some dissapeared or the number of sectors changed. The label is the only stable thing. 3) hard-coded colors: the algorithm allows hardcoded label-color relationships as an input but stills doing a good work (1 & 2) for the rest of free labels. I think this algorithm, even if it looks quite ad-hoc, will be usefull in more then one situation. Any ideas?

    Read the article

  • Adding data (not only text) to a multi column ListView (WPF)

    - by user811804
    I am working on a WPF application in C# (.NET 4.0) where I have a ListView with a GridView that has two columns. I dynamically want to add rows (in code). My dilemma is that only the first column will have regular text added to it. The second column will have an object that includes a multi column Grid with TextBlocks. (see link http://imageshack.us/photo/my-images/803/listview.png/) If I do what you would normally do when you want to enter text in all columns (ie. DisplayMemberBinding) all I get in the second column is the text "System.Windows.Grid", which obviously isn't what I want. For reference if I just try to add the Grid object (with the TextBlocks) with the code listView1.Items.Add(grid1) (not using DisplayMemberBinding) the object gets added to the second column only (with the first column being blank) and not how it normally works with text where the same text ends up in all columns. I hope my question is detailed enough and any help with this would be much appreciated. EDIT: I have tried the following code, howeever every time I click the button to add a new row every single row gets updated with the same datatemplate. (ie. the second column always shows the same data on every row.) xaml: <Window x:Class="TEST.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="AAA" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"> <Grid Name="grid1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="374*" /> <ColumnDefinition Width="129*" /> </Grid.ColumnDefinitions> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="21,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" Grid.Column="1" Click="button1_Click" /> </Grid> code: public partial class MainWindow : Window { ListView listView1 = new ListView(); GridViewColumn viewCol2 = new GridViewColumn(); public MainWindow() { InitializeComponent(); Style style = new Style(typeof(ListViewItem)); style.Setters.Add(new Setter(ListViewItem.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch)); listView1.ItemContainerStyle = style; GridView gridView1 = new GridView(); listView1.View = gridView1; GridViewColumn viewCol1 = new GridViewColumn(); viewCol1.Header = "Option"; gridView1.Columns.Add(viewCol1); viewCol2.Header = "Value"; gridView1.Columns.Add(viewCol2); grid1.Children.Add(listView1); viewCol1.DisplayMemberBinding = new Binding("Option"); } private void Window_Loaded(object sender, RoutedEventArgs e) { } private void button1_Click(object sender, RoutedEventArgs e) { DataTemplate dataTemplate = new DataTemplate(); FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(Grid)); Random random = new Random(); int cols = random.Next(1, 6); int full = 100; for (int i = 0; i < cols; i++) { FrameworkElementFactory col1 = new FrameworkElementFactory(typeof(ColumnDefinition)); int partWidth = random.Next(0, full); full -= partWidth; col1.SetValue(ColumnDefinition.WidthProperty, new GridLength(partWidth, GridUnitType.Star)); spFactory.AppendChild(col1); } if (full > 0) { FrameworkElementFactory col1 = new FrameworkElementFactory(typeof(ColumnDefinition)); col1.SetValue(ColumnDefinition.WidthProperty, new GridLength(full, GridUnitType.Star)); spFactory.AppendChild(col1); } for (int i = 0; i < cols; i++) { FrameworkElementFactory text1 = new FrameworkElementFactory(typeof(TextBlock)); SolidColorBrush sb1 = new SolidColorBrush(); switch (i) { case 0: sb1.Color = Colors.Blue; break; case 1: sb1.Color = Colors.Red; break; case 2: sb1.Color = Colors.Yellow; break; case 3: sb1.Color = Colors.Green; break; case 4: sb1.Color = Colors.Purple; break; case 5: sb1.Color = Colors.Pink; break; case 6: sb1.Color = Colors.Brown; break; } text1.SetValue(TextBlock.BackgroundProperty, sb1); text1.SetValue(Grid.ColumnProperty, i); spFactory.AppendChild(text1); } if (full > 0) { FrameworkElementFactory text1 = new FrameworkElementFactory(typeof(TextBlock)); SolidColorBrush sb1 = new SolidColorBrush(Colors.Black); text1.SetValue(TextBlock.BackgroundProperty, sb1); text1.SetValue(Grid.ColumnProperty, cols); spFactory.AppendChild(text1); } dataTemplate.VisualTree = spFactory; viewCol2.CellTemplate = dataTemplate; int rows = listView1.Items.Count + 1; listView1.Items.Add(new { Option = "Row " + rows }); } }

    Read the article

  • How to select records as columns in SQL

    - by Leigh
    Hi, I have two tables: tblSizes and tblColors. tblColors has columns called ColorName, ColorPrice and SizeID. There is one size to multiple colors. I need to write a query to select the size and all the colors (as columns) for a that size with the price of each size in its respective column. The colors must be returned as columns, for instance: SizeID : Width : Height : Red : Green : Blue 1---------220-----220----£15----£20-----£29 Hope this makes sense Thank you

    Read the article

  • jQuery Color **Swatch** Picker

    - by Alan Storm
    Has anyone coded up a jQuery query color picker that lets you pick colors from a predetermined list of colors? Something like a product color picker on an Ecommerce site. Most of the searching I've done reveals a lot of general purpose, pick-any-color-in-the-rgb-spectrum, but few options for picking specific colors.

    Read the article

  • how to pass arguments into function within a function in r

    - by jon
    I am writing function that involve other function from base R with alot of arguments. For example (real function is much longer): myfunction <- function (dataframe, Colv = NA) { matrix <- as.matrix (dataframe) out <- heatmap(matrix, Colv = Colv) return(out) } data(mtcars) myfunction (mtcars, Colv = NA) The heatmap has many arguments that can be passed to: heatmap(x, Rowv=NULL, Colv=if(symm)"Rowv" else NULL, distfun = dist, hclustfun = hclust, reorderfun = function(d,w) reorder(d,w), add.expr, symm = FALSE, revC = identical(Colv, "Rowv"), scale=c("row", "column", "none"), na.rm = TRUE, margins = c(5, 5), ColSideColors, RowSideColors, cexRow = 0.2 + 1/log10(nr), cexCol = 0.2 + 1/log10(nc), labRow = NULL, labCol = NULL, main = NULL, xlab = NULL, ylab = NULL, keep.dendro = FALSE, verbose = getOption("verbose"), ...) I want to use these arguments without listing them inside myfun. myfunction (mtcars, Colv = NA, col = topo.colors(16)) Error in myfunction(mtcars, Colv = NA, col = topo.colors(16)) : unused argument(s) (col = topo.colors(16)) I tried the following but do not work: myfunction <- function (dataframe, Colv = NA) { matrix <- as.matrix (dataframe) out <- heatmap(matrix, Colv = Colv, ....) return(out) } data(mtcars) myfunction (mtcars, Colv = NA, col = topo.colors(16))

    Read the article

  • How to create a paging scrollView with space between views

    - by user1558819
    I followed the tutorial about how to create a scrollView Page Control: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ This tutorial is really good and I implement well the code. Here my question: I want to put a space between the my PageViews, but when it change the page it show the space between the views in the next page. The scroll must stop after the space when I change the page. Someone can help me? I change the tutorial code here: - (void)viewDidLoad { [super viewDidLoad]; NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil]; #define space 20 for (int i = 0; i < colors.count; i++) { CGRect frame; frame.origin.x = (self.scrollView.frame.size.width + space) * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; UIView *subview = [[UIView alloc] initWithFrame:frame]; subview.backgroundColor = [colors objectAtIndex:i]; [self.scrollView addSubview:subview]; [subview release]; } self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count+ space*(colors.count-1), self.scrollView.frame.size.height); } Thanks,

    Read the article

  • Mysql query: count and distinct

    - by Azevedo
    I have this hypotetical MySQL table: TABLE cars: (year, color, brand) How do I count # of cars grouped by brand and year? I mean, how can I get to know how many colors are there grouped by brand like: brand "GM": total # of colors: 8. brand "GM": total # of years (grouped together): 14 (meaning there are count of 14 different years). brand "TOYOTA": total # of colors: 3. brand "TOYOTA": total # of years (grouped together): 10 (meaning there are count of 14 different years) I tried playing some queries with COUNT, DISTINCT, GROUP BY but I can't get to it. Actually I'm trying to get the 2 queries... +-------+---------------+ | brand | count(colors) | +-------+---------------+ +-------+--------------+ | brand | count(years) | +-------+--------------+ thanks a lot!

    Read the article

  • How can I make eclipse look like VS.NET 2010?

    - by Juan Manuel
    I am constantly switching between a project written in C# 4.0 and another one written in Java. I find it very difficult to read the code in Java, and I think it's because of its colors (or lack of them really) Is there any way to mimic the colors that VS.NET 2010 has inside eclipse? (even better would be to replace all its hotkeys for their equivalent in VS.NET, like ctrl+k for ctrl+f3, but I believe it would be utopic)

    Read the article

  • Using Toshiba 22EL833 as PC display through HDMI input

    - by Oleg V. Volkov
    I had another Toshiba TV - 19SL738 - connected to this same PC and video card (GTX 8800) through DVI<-HDMI (DVI on PC side, HDMI on TV) before, that was working perfectly at it's native resolution 1360x768. Some time ago I had to change to 22EL833 and immediately faced problem with Windows 7 control panel and NVIDIA control panel both reporting native resolution for new TV as 1080i, 1920x1280, despite TV documentation saying that it have same 1360x768 as previous one. Practical tests confirmed that true native resolution is indeed 1360x768, because plugging in through DVI<-VGA and setting custom resolution through NVIDIA panel shown clear colors and crisp image, while setting anything different with either DVI<-VGA or DVI<-HDMI produced horribly distorted or squished images, with almost unreadable slim lines (as in letters, for example). Now, my problem is that there's no drivers for this TV and I'm unable to get good image while connecting it through DVI<-HDMI directly. The best I've achieved is editing EDID/driver manually, to persuade system that native resolution should be 1360x768, and while image became mostly clear, colors turned to some strange washed out effect, with pools of pure yellow, cyan and magenta there and there filling place of other colors. Gradients also became noticeably stripped as well. Somehow it looks like dithering gone bad and makes me suspect that image is still down/upscaled several times internally somewhere along the line. How can I connect this TV to DVI output of my video card to get best possible clear image, correct colors and correct native resolution?

    Read the article

  • Using Toshiba 22EL833 as PC display with GTX8800

    - by Oleg V. Volkov
    I had another Toshiba TV - 19SL738 - connected to this same PC and video card (GTX 8800) through DVI<-HDMI (DVI on PC side, HDMI on TV) before, that was working perfectly at it's native resolution 1360x768. Some time ago I had to change to 22EL833 and immediately faced problem with Windows 7 control panel and NVIDIA control panel both reporting native resolution for new TV as 1080i, 1920x1280, despite TV documentation saying that it have same 1360x768 as previous one. Practical tests confirmed that true native resolution is indeed 1360x768, because plugging in through DVI<-VGA and setting custom resolution through NVIDIA panel shown clear colors and crisp image, while setting anything different with either DVI<-VGA or DVI<-HDMI produced horribly distorted or squished images, with almost unreadable slim lines (as in letters, for example). Now, my problem is that there's no drivers for this TV and I'm unable to get good image while connecting it through DVI<-HDMI directly. The best I've achieved is editing EDID/driver manually, to persuade system that native resolution should be 1360x768, and while image became mostly clear, colors turned to some strange washed out effect, with pools of pure yellow, cyan and magenta there and there filling place of other colors. Gradients also became noticeably stripped as well. Somehow it looks like dithering gone bad and makes me suspect that image is still down/upscaled several times internally somewhere along the line. How can I connect this TV to DVI output of my video card to get best possible clear image, correct colors and correct native resolution?

    Read the article

  • converting a png with an ICC profile?

    - by jedierikb
    I can convert a jpg from one ICC to another ICC. convert rgb_image.jpg -profile USCoat.icm cmyk_image.jpg Or I can convert a jpg with no ICC to another ICC. convert rgb_image.jpg +profile icm \ -profile sRGB.icc -profile USCoat.icm cmyk_image.jpg But how do I convert a png's pixels into the gamut described by an ICC profile? I understand I cannot embed the profile into the image file, but would at least like to convert the colors. When I reuse the above commands, the colors come out wrong... (different from the colors in the JPG when converted). This is the source image: http://alumni.media.mit.edu/~erikb/tmp/RED_JPG.jpg And here is what I am trying: convert RED_JPG.jpg +profile icm -profile sRGB_v4_ICC_preference.icc -profile USWebUncoated.icc CMYK_PNG.png and this is what I am getting: http://alumni.media.mit.edu/~erikb/tmp/CMYK_PNG.png I was hoping to get an image with the same colors as a JPEG run through the same command: convert RED_JPG.jpg +profile icm -profile sRGB_v4_ICC_preference.icc -profile USWebUncoated.icc CMYK_JPG.jpg resulting in: http://alumni.media.mit.edu/~erikb/tmp/CMYK_JPG.jpg *this image, CMYK_JPG.jpg, is what I am trying to reproduce pixel by pixel in a PNG file.* Any suggestions? Original (unanswered) post here.

    Read the article

  • scrolling lags in emacs 23.2 with GTK

    - by mefiX
    Hey there, I am using emacs 23.2 with the GTK toolkit. I built emacs from source using the following configure-params: ./configure --prefix=/usr --without-makeinfo --without-sound Which builds emacs with the following configuration: Where should the build process find the source code? /home/****/incoming/emacs-23.2 What operating system and machine description files should Emacs use? `s/gnu-linux.h' and `m/intel386.h' What compiler should emacs be built with? gcc -g -O2 -Wdeclaration-after-statement -Wno-pointer-sign Should Emacs use the GNU version of malloc? yes (Using Doug Lea's new malloc from the GNU C Library.) Should Emacs use a relocating allocator for buffers? yes Should Emacs use mmap(2) for buffer allocation? no What window system should Emacs use? x11 What toolkit should Emacs use? GTK Where do we find X Windows header files? Standard dirs Where do we find X Windows libraries? Standard dirs Does Emacs use -lXaw3d? no Does Emacs use -lXpm? yes Does Emacs use -ljpeg? yes Does Emacs use -ltiff? yes Does Emacs use a gif library? yes -lgif Does Emacs use -lpng? yes Does Emacs use -lrsvg-2? no Does Emacs use -lgpm? yes Does Emacs use -ldbus? yes Does Emacs use -lgconf? no Does Emacs use -lfreetype? yes Does Emacs use -lm17n-flt? no Does Emacs use -lotf? yes Does Emacs use -lxft? yes Does Emacs use toolkit scroll bars? yes When I'm scrolling within files of a common size (about 1000 lines) holding the up/down-keys, emacs almost hangs and produces about 50% CPU-load. I use the following plugins: ido linum tabbar auto-complete-config Starting emacs with -q fixes the problem, but then I don't have any plugins. I can't figure out, which part of my .emacs is responsible for this behaviour. Here's an excerpt of my .emacs-file: (require 'ido) (ido-mode 1) (require 'linum) (global-linum-mode 1) (require 'tabbar) (tabbar-mode 1) (tabbar-local-mode 0) (tabbar-mwheel-mode 0) (setq tabbar-buffer-groups-function (lambda () (list "All"))) (global-set-key [M-left] 'tabbar-backward) (global-set-key [M-right] 'tabbar-forward) ;; hide the toolbar (gtk etc.) (tool-bar-mode -1) ;; Mouse scrolling enhancements (setq mouse-wheel-progressive-speed nil) (setq mouse-wheel-scroll-amount '(5 ((shift) . 5) ((control) . nil))) ;; Smart-HOME (defun smart-beginning-of-line () "Forces the cursor to jump to the first none whitespace char of the current line when pressing HOME" (interactive) (let ((oldpos (point))) (back-to-indentation) (and (= oldpos (point)) (beginning-of-line)))) (put 'smart-beginning-of-line 'CUA 'move) (global-set-key [home] 'smart-beginning-of-line) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(column-number-mode t) '(cua-mode t nil (cua-base)) '(custom-buffer-indent 4) '(delete-selection-mode nil) '(display-time-24hr-format t) '(display-time-day-and-date 1) '(display-time-mode t) '(global-font-lock-mode t nil (font-lock)) '(inhibit-startup-buffer-menu t) '(inhibit-startup-screen t) '(pc-select-meta-moves-sexps t) '(pc-select-selection-keys-only t) '(pc-selection-mode t nil (pc-select)) '(scroll-bar-mode (quote right)) '(show-paren-mode t) '(standard-indent 4) '(uniquify-buffer-name-style (quote forward) nil (uniquify))) (setq-default tab-width 4) (setq-default indent-tabs-mode t) (setq c-basic-offset 4) ;; Highlighting of the current line (global-hl-line-mode 1) (set-face-background 'hl-line "#E8F2FE") (defalias 'yes-or-no-p 'y-or-n-p) (display-time) (set-language-environment "Latin-1") ;; Change cursor color according to mode (setq djcb-read-only-color "gray") ;; valid values are t, nil, box, hollow, bar, (bar . WIDTH), hbar, ;; (hbar. HEIGHT); see the docs for set-cursor-type (setq djcb-read-only-cursor-type 'hbar) (setq djcb-overwrite-color "red") (setq djcb-overwrite-cursor-type 'box) (setq djcb-normal-color "black") (setq djcb-normal-cursor-type 'bar) (defun djcb-set-cursor-according-to-mode () "change cursor color and type according to some minor modes." (cond (buffer-read-only (set-cursor-color djcb-read-only-color) (setq cursor-type djcb-read-only-cursor-type)) (overwrite-mode (set-cursor-color djcb-overwrite-color) (setq cursor-type djcb-overwrite-cursor-type)) (t (set-cursor-color djcb-normal-color) (setq cursor-type djcb-normal-cursor-type)))) (add-hook 'post-command-hook 'djcb-set-cursor-according-to-mode) (define-key global-map '[C-right] 'forward-sexp) (define-key global-map '[C-left] 'backward-sexp) (define-key global-map '[s-left] 'windmove-left) (define-key global-map '[s-right] 'windmove-right) (define-key global-map '[s-up] 'windmove-up) (define-key global-map '[s-down] 'windmove-down) (define-key global-map '[S-down-mouse-1] 'mouse-stay-and-copy) (define-key global-map '[C-M-S-down-mouse-1] 'mouse-stay-and-swap) (define-key global-map '[S-mouse-2] 'mouse-yank-and-kill) (define-key global-map '[C-S-down-mouse-1] 'mouse-stay-and-kill) (define-key global-map "\C-a" 'mark-whole-buffer) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:inherit nil :stipple nil :background "#f7f9fa" :foreground "#191919" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "DejaVu Sans Mono")))) '(font-lock-builtin-face ((((class color) (min-colors 88) (background light)) (:foreground "#642880" :weight bold)))) '(font-lock-comment-face ((((class color) (min-colors 88) (background light)) (:foreground "#3f7f5f")))) '(font-lock-constant-face ((((class color) (min-colors 88) (background light)) (:weight bold)))) '(font-lock-doc-face ((t (:inherit font-lock-string-face :foreground "#3f7f5f")))) '(font-lock-function-name-face ((((class color) (min-colors 88) (background light)) (:foreground "Black" :weight bold)))) '(font-lock-keyword-face ((((class color) (min-colors 88) (background light)) (:foreground "#7f0055" :weight bold)))) '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "#7f0055" :weight bold)))) '(font-lock-string-face ((((class color) (min-colors 88) (background light)) (:foreground "#0000c0")))) '(font-lock-type-face ((((class color) (min-colors 88) (background light)) (:foreground "#7f0055" :weight bold)))) '(font-lock-variable-name-face ((((class color) (min-colors 88) (background light)) (:foreground "Black")))) '(minibuffer-prompt ((t (:foreground "medium blue")))) '(mode-line ((t (:background "#222222" :foreground "White")))) '(tabbar-button ((t (:inherit tabbar-default :foreground "dark red")))) '(tabbar-button-highlight ((t (:inherit tabbar-default :background "white" :box (:line-width 2 :color "white"))))) '(tabbar-default ((t (:background "gray90" :foreground "gray50" :box (:line-width 3 :color "gray90") :height 100)))) '(tabbar-highlight ((t (:underline t)))) '(tabbar-selected ((t (:inherit tabbar-default :foreground "blue" :weight bold)))) '(tabbar-separator ((t nil))) '(tabbar-unselected ((t (:inherit tabbar-default))))) Any suggestions? Kind regards, mefiX

    Read the article

  • Different color prompts for different machines when using terminal/ssh?

    - by bcrawl
    I have 5 machines I constantly ssh into to do work. Its getting increasingly frustrating when I am issuing wrong commands on wrong boxes. Luckily I havent done anything bad yet. I wanted to know if there is any hack which I can hardcode which will display my prompt in different colors based on the machine I am ssh into? Such as blue for desktop1, purple for laptop, red for server etc? Is this possible? Currently I am using this command export PS1="\e[0;31m[\u@\h \W]\$ \e[m " taken from here http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/ but it obviously doesnt work across ssh. Also, if you have any other cool bash tips for helping me ease my sight will be wonderful. I got this tip which colors the man pages. http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/

    Read the article

  • I will need a formula showing counts, totals and sub-totals for data set from different sheet

    - by Sapthagiri
    I am using MS2003 EXCEL. I have a cell in Sheet 1 with a color value and totals, with sub-totals. On sheet 2, I have a data set with 3 columns (colors, dress, type). On Sheet 1, I will need a tabulation showing Totals for Colors, with totals at sub-group of dress (shirt,pants) split by type totals (Full, Half, Tee) Below table represents my Data set in Sheet 2 Colors Make Dress Type -------------------------------- Red Arrow shirt full Red Levi shirt half blue Rugger Pant full yellow Wrangler shirt tee yellow Rugger Pant half yellow Arrow shirt tee yellow Wrangler Pant half Green Rugger Pant full Red Levi shirt tee blue Rugger Pant full blue Arrow shirt full blue Wrangler Pant half Green Levi shirt full I will need a formula showing counts, totals and sub-totals on Sheet 1 for data set from Sheet 2. Refer my table below which represent my expected data on Sheet 1, total Shirt Full Half Tees Pants Full Shorts Red 10 8 4 3 1 2 1 1 Blue Green Yellow Please note I am not looking for a Pivot table solution.

    Read the article

  • Different color prompts for different machines when using terminal/ssh?

    - by bcrawl
    Hi, I have 5 machines I constantly ssh into to do work. Its getting increasingly frustrating when I am issuing wrong commands on wrong boxes. Luckily I havent done anything bad yet. I wanted to know if there is any hack which I can hardcode which will display my prompt in different colors based on the machine I am ssh into? Such as blue for desktop1, purple for laptop, red for server etc? Is this possible? Currently I am using this command export PS1="\e[0;31m[\u@\h \W]\$ \e[m " taken from here http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/ but it obviously doesnt work across ssh. Also, if you have any other cool bash tips for helping me ease my sight will be wonderful. I got this tip which colors the man pages. http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/

    Read the article

  • When should I use indexed arrays of OpenGL vertices?

    - by Tartley
    I'm trying to get a clear idea of when I should be using indexed arrays of OpenGL vertices, drawn with gl[Multi]DrawElements and the like, versus when I should simply use contiguous arrays of vertices, drawn with gl[Multi]DrawArrays. (Update: The consensus in the replies I got is that one should always be using indexed vertices.) I have gone back and forth on this issue several times, so I'm going to outline my current understanding, in the hopes someone can either tell me I'm now finally more or less correct, or else point out where my remaining misunderstandings are. Specifically, I have three conclusions, in bold. Please correct them if they are wrong. One simple case is if my geometry consists of meshes to form curved surfaces. In this case, the vertices in the middle of the mesh will have identical attributes (position, normal, color, texture coord, etc) for every triangle which uses the vertex. This leads me to conclude that: 1. For geometry with few seams, indexed arrays are a big win. Follow rule 1 always, except: For geometry that is very 'blocky', in which every edge represents a seam, the benefit of indexed arrays is less obvious. To take a simple cube as an example, although each vertex is used in three different faces, we can't share vertices between them, because for a single vertex, the surface normals (and possible other things, like color and texture co-ord) will differ on each face. Hence we need to explicitly introduce redundant vertex positions into our array, so that the same position can be used several times with different normals, etc. This means that indexed arrays are of less use. e.g. When rendering a single face of a cube: 0 1 o---o |\ | | \ | | \| o---o 3 2 (this can be considered in isolation, because the seams between this face and all adjacent faces mean than none of these vertices can be shared between faces) if rendering using GL_TRIANGLE_FAN (or _STRIP), then each face of the cube can be rendered thus: verts = [v0, v1, v2, v3] colors = [c0, c0, c0, c0] normal = [n0, n0, n0, n0] Adding indices does not allow us to simplify this. From this I conclude that: 2. When rendering geometry which is all seams or mostly seams, when using GL_TRIANGLE_STRIP or _FAN, then I should never use indexed arrays, and should instead always use gl[Multi]DrawArrays. (Update: Replies indicate that this conclusion is wrong. Even though indices don't allow us to reduce the size of the arrays here, they should still be used because of other performance benefits, as discussed in the comments) The only exception to rule 2 is: When using GL_TRIANGLES (instead of strips or fans), then half of the vertices can still be re-used twice, with identical normals and colors, etc, because each cube face is rendered as two separate triangles. Again, for the same single cube face: 0 1 o---o |\ | | \ | | \| o---o 3 2 Without indices, using GL_TRIANGLES, the arrays would be something like: verts = [v0, v1, v2, v2, v3, v0] normals = [n0, n0, n0, n0, n0, n0] colors = [c0, c0, c0, c0, c0, c0] Since a vertex and a normal are often 3 floats each, and a color is often 3 bytes, that gives, for each cube face, about: verts = 6 * 3 floats = 18 floats normals = 6 * 3 floats = 18 floats colors = 6 * 3 bytes = 18 bytes = 36 floats and 18 bytes per cube face. (I understand the number of bytes might change if different types are used, the exact figures are just for illustration.) With indices, we can simplify this a little, giving: verts = [v0, v1, v2, v3] (4 * 3 = 12 floats) normals = [n0, n0, n0, n0] (4 * 3 = 12 floats) colors = [c0, c0, c0, c0] (4 * 3 = 12 bytes) indices = [0, 1, 2, 2, 3, 0] (6 shorts) = 24 floats + 12 bytes, and maybe 6 shorts, per cube face. See how in the latter case, vertices 0 and 2 are used twice, but only represented once in each of the verts, normals and colors arrays. This sounds like a small win for using indices, even in the extreme case of every single geometry edge being a seam. This leads me to conclude that: 3. When using GL_TRIANGLES, one should always use indexed arrays, even for geometry which is all seams. Please correct my conclusions in bold if they are wrong.

    Read the article

  • How do I stop color changes when quitting vi from a terminal emulator?

    - by Michael Warhol
    I have a problem with colors when using vi under Ubuntu 12.04. I'm connecting to my Ubuntu server from a PC, using PowerTerm terminal emulation software. I have PowerTerm set up to display black text on a grey background. When I connect to the Ubuntu box, the screen is fine. When I open a file with vi, the screen is fine. The text is black on a gray background, which is normal for my PowerTerm setup. However, if the file is less than a full screen long, the remainder of the screen is a black background. When I quit vi, the entire background turns black, and the text becomes white. I have to do a Terminal Reset to restore my normal text and background colors. What I want is for there to be no change at all when I use vi. The text should be black and the background grey. I have another server loaded with RedHat 9, and that acts normally; colors don’t change when using vi. Here is my .vimrc file: set compatible syntax off let g:loaded_matchparen=1 set nocp set noincsearch set nohlsearch set noshowmatch set bg=dark I've tried set bg=dark and set bg=light. It makes no difference. Is there some other set command that would clear this up for me, or some TERM setting (my TERM is set to linux)?

    Read the article

  • Using Appendbuffers in unity for terrain generation

    - by Wardy
    Like many others I figured I would try and make the most of the monster processing power of the GPU but I'm having trouble getting the basics in place. CPU code: using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public ComputeShader Generator; public MeshTopology Topology; void OnEnable() { var computedMeshPoints = ComputeMesh(); CreateMeshFrom(computedMeshPoints); } private Vector3[] ComputeMesh() { var size = (32*32) * 4; // 4 points added for each x,z pos var buffer = new ComputeBuffer(size, 12, ComputeBufferType.Append); Generator.SetBuffer(0, "vertexBuffer", buffer); Generator.Dispatch(0, 1, 1, 1); var results = new Vector3[size]; buffer.GetData(results); buffer.Dispose(); return results; } private void CreateMeshFrom(Vector3[] generatedPoints) { var filter = GetComponent<MeshFilter>(); var renderer = GetComponent<MeshRenderer>(); if (generatedPoints.Length > 0) { var mesh = new Mesh { vertices = generatedPoints }; var colors = new Color[generatedPoints.Length]; var indices = new int[generatedPoints.Length]; //TODO: build this different based on topology of the mesh being generated for (int i = 0; i < indices.Length; i++) { indices[i] = i; colors[i] = Color.blue; } mesh.SetIndices(indices, Topology, 0); mesh.colors = colors; mesh.RecalculateNormals(); mesh.Optimize(); mesh.RecalculateBounds(); filter.sharedMesh = mesh; } else { filter.sharedMesh = null; } } } GPU code: #pragma kernel Generate AppendStructuredBuffer<float3> vertexBuffer : register(u0); void genVertsAt(uint2 xzPos) { //TODO: put some height generation code here. // could even run marching cubes / dual contouring code. float3 corner1 = float3( xzPos[0], 0, xzPos[1] ); float3 corner2 = float3( xzPos[0] + 1, 0, xzPos[1] ); float3 corner3 = float3( xzPos[0], 0, xzPos[1] + 1); float3 corner4 = float3( xzPos[0] + 1, 0, xzPos[1] + 1 ); vertexBuffer.Append(corner1); vertexBuffer.Append(corner2); vertexBuffer.Append(corner3); vertexBuffer.Append(corner4); } [numthreads(32, 1, 32)] void Generate (uint3 threadId : SV_GroupThreadID, uint3 groupId : SV_GroupID) { uint2 currentXZ = unint2( groupId.x * 32 + threadId.x, groupId.z * 32 + threadId.z); genVertsAt(currentXZ); } Can anyone explain why when I call "buffer.GetData(results);" on the CPU after the compute dispatch call my buffer is full of Vector3(0,0,0), I'm not expecting any y values yet but I would expect a bunch of thread indexes in the x,z values for the Vector3 array. I'm not getting any errors in any of this code which suggests it's correct syntax-wise but maybe the issue is a logical bug. Also: Yes, I know I'm generating 4,000 Vector3's and then basically round tripping them. However, the purpose of this code is purely to learn how round tripping works between CPU and GPU in Unity.

    Read the article

  • The program is executing properly on dev C++ but is giving problem in Linux.The movement is becoming

    - by srinija
    #include<stdio.h> #include<GL/glut.h> GLfloat v[3][24]={{100.0,300.0,350.0,50.0,100.0,120.0,120.0,100.0,260.0,280.0, 280.0,260.0,140.0,160.0,160.0,140.0,180.0,200.0,200.0,180.0, 220.0,240.0,240.0,220.0},{100.0,100.0,200.0,200.0,160.0, 160.0,180.0,180.0,160.0,160.0,180.0,180.0,160.0,160.0,180.0, 180.0,160.0,160.0,180.0,180.0,160.0,160.0,180.0,180.0}, {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}}; GLfloat v1[3][16]={{50.0,350.0,350.0,50.0,100.0,300.0,300.0,100.0,125.0,175.0, 175.0,125.0,225.0,275.0,275.0,225.0},{200.0,200.0,210.0, 210.0,210.0,210.0,240.0,240.0,240.0,240.0,310.0,310.0,240.0, 240.0,310.0,310.0},{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0}}; GLfloat colors[4][3]={{0.0,0.0,1.0},{0.9961,0.9961,0.65625},{1.0,0.0,1.0}, {1.0,.0,1.0}}; static float q,w,e; static float fq,fw,fe; static GLfloat wa=0,wb=0,wc=0,ba,bb,bc; int flag; void myinit(void) { glClearColor(0.506,.7,1,0.0); glPointSize(2.0); glLoadIdentity(); glOrtho(0.0,499.0,0.0,499.0,-300.0,300.0); } void draw_top_boxes(GLint i,GLint j) { glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glColor3fv(colors[j]); // to draw the boat glVertex2f(v1[0][i+0],v1[1][i+0]); glColor3fv(colors[j+1]); glVertex2f(v1[0][i+1],v1[1][i+1]); glColor3fv(colors[j+2]); glVertex2f(v1[0][i+2],v1[1][i+2]); glColor3fv(colors[j+3]); glVertex2f(v1[0][i+3],v1[1][i+3]); glEnd(); } void draw_polygon(GLint i) { glBegin(GL_POLYGON); // to draw the boat glColor3f(0.0,0.0,0.0); glColor3fv(colors[0]); glVertex2f(v[0][i+0],v[1][i+0]); glColor3fv(colors[1]); glVertex2f(v[0][i+1],v[1][i+1]); glColor3fv(colors[2]); glVertex2f(v[0][i+2],v[1][i+2]); glColor3fv(colors[3]); glVertex2f(v[0][i+3],v[1][i+3]); glEnd(); } void draw_boat() { draw_polygon(0); draw_polygon(4); draw_polygon(8); draw_polygon(12); draw_polygon(16); draw_polygon(20); draw_top_boxes(0,0); draw_top_boxes(4,0); draw_top_boxes(8,0); draw_top_boxes(12,0); glFlush(); glPopMatrix(); glPopMatrix(); } void draw_water() { GLfloat i; GLfloat x=0,y=103,j=0; GLfloat k; glPushMatrix(); glTranslatef(wa,wb,wc); glPushMatrix(); glColor3f(0,0,1); for(k=y;k>0;k-=6) { for(i=1;i<30;i++) { glBegin(GL_LINES); glVertex2f(j,k); glVertex2f(j+10,k); glEnd(); j=j+20; } j=0; } glPopMatrix(); glPopMatrix(); } void draw_fishes() { glPushMatrix(); glTranslatef(fq,12.0,fe); glPushMatrix(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(100,80); glVertex2f(100,60); glVertex2f(85,70); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(100,70); glVertex2f(110,75); glVertex2f(110,65); glEnd(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(90,71); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(200,80); glVertex2f(200,60); glVertex2f(185,70); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(200,70); glVertex2f(210,75); glVertex2f(210,65); glEnd(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(190,71); glEnd(); glPopMatrix(); glPopMatrix(); glFlush(); } void draw_cloud() { GLfloat m=100,n=400,o=10; for(int i=0;i<7;i++) { glPushMatrix(); glColor3f(1.0,1.0,1.0); if(i==1) glTranslated(125,415,10); else if(i==3||i==5) glTranslated(m,n+5,o); else glTranslated(m,n,o); glutSolidSphere(20.0,5000,150); glPopMatrix(); m+=10; } } void draw_square() { glColor3f(0,0.5,0.996); glBegin(GL_POLYGON); glVertex2f(0,0); glVertex2f(1000,0); glVertex2f(0,300); glVertex2f(1000,300); glEnd(); glFlush(); } void draw_brotate() { glPushMatrix(); glColor3f(0.96,0.5,0.25); //to draw body of the bird glTranslated(300,400,10); glScalef(3,1,1); glutSolidSphere(6,50000,15); glPopMatrix(); glPushMatrix(); glTranslated(323,400,10); glutSolidSphere(5,50000,15); glPopMatrix(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(325,401); glEnd(); glColor3f(0.96,0.5,0.25); //to draw wings glBegin(GL_LINES); glVertex2f(294,394); glVertex2f(286,389); glEnd(); glBegin(GL_LINES); glVertex2f(286,389); glVertex2f(295,391); glEnd(); glBegin(GL_LINES); glVertex2f(295,391); glVertex2f(285,385); glEnd(); glBegin(GL_LINES); glVertex2f(285,385); glVertex2f(309,395); glEnd(); glBegin(GL_LINES); glVertex2f(294,406); glVertex2f(286,411); glEnd(); glBegin(GL_LINES); glVertex2f(286,411); glVertex2f(295,409); glEnd(); glBegin(GL_LINES); glVertex2f(295,409); glVertex2f(285,415); glEnd(); glBegin(GL_LINES); glVertex2f(285,415); glVertex2f(309,406); glEnd(); glColor3f(0.96,0.5,0.25); } void draw_bird() { GLfloat x=200,y=400,z=10; draw_brotate(); glBegin(GL_LINES); //draw legs of the bird glVertex2f(285,402); glVertex2f(275,402); glEnd(); glBegin(GL_LINES); glVertex2f(285,398); glVertex2f(275,398); glEnd(); glBegin(GL_LINES); glVertex2f(275,402); glVertex2f(270,405); glEnd(); glBegin(GL_LINES); glVertex2f(275,402); glVertex2f(270,398); glEnd(); glBegin(GL_LINES); glVertex2f(275,398); glVertex2f(273,400); glEnd(); glBegin(GL_LINES); glVertex2f(275,398); glVertex2f(270,395); glEnd(); glBegin(GL_LINES); glVertex2f(323,405); glVertex2f(323,407); glEnd(); glPushMatrix(); glTranslatef(323,409,10); glutSolidSphere(2,200,20); glPopMatrix(); glBegin(GL_TRIANGLES); glVertex2f(328,400); glVertex2f(331,397); glVertex2f(327,398.5); glEnd(); glFlush(); } void drawstars() { glColor3f(1.0,1.0,1.0); glBegin(GL_POINTS); glVertex3f(300.0,400.0,10.0); glVertex3f(200,400.0,10.0); glVertex3f(150,450.0,10.0); glVertex3f(100,470.0,10.0); glVertex3f(50,450.0,10.0); glVertex3f(50,350.0,10.0); glVertex3f(90,365.0,10.0); glVertex3f(350,450.0,10.0); glVertex3f(275,470.0,10.0); glVertex3f(280,430.0,10.0); glVertex3f(250,400.0,10.0); glVertex3f(450,450.0,10.0); glVertex3f(430,430.0,10.0); glVertex3f(430,470.0,10.0); glVertex3f(300,450.0,10.0); glVertex3f(265,380.0,10.0); glVertex3f(235,450.0,10.0); glEnd(); } void draw_all() { glClear(GL_COLOR_BUFFER_BIT); if(flag==0) { glDisable(GL_LIGHTING); //immp one draw_square(); draw_cloud(); glClearColor(0.506,.7,1,0.0); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glPushMatrix(); glColor3f(1.0,1.0,0.0); glTranslated(400,400,10); glutSolidSphere(20.0,5000,150); glPopMatrix(); } if(flag==1) { glDisable(GL_LIGHTING); //imp one draw_square(); draw_cloud(); glClearColor(0.9960,0.7070,0.3164,0.0); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glPushMatrix(); glColor3f(1.0,1.0,0.0); glTranslated(400,400,10); glutSolidSphere(20.0,500,100); glPopMatrix(); } if(flag==2) { // just try and change values in these arrays, specially the position array drawstars(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // GLfloat emission[]={0.1,0.1,0.1,0.0}; GLfloat diffuse[] = { 0.40, 0.40,0.40, 1.0 }; GLfloat ambiance[] = { 0.5, 0.5,0.5, 1.0 }; GLfloat specular[] = { 1.3, 1.3,.3, 1.0 }; GLfloat intensity[]={500.0}; GLfloat position[] = { 10,30,-30,1.0 }; glLightfv (GL_LIGHT0, GL_POSITION, position); glLightfv (GL_LIGHT0, GL_DIFFUSE,diffuse); glLightfv (GL_LIGHT0, GL_AMBIENT,ambiance); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); glLightfv (GL_LIGHT0, GL_SPECULAR,specular); glLightfv (GL_LIGHT0, GL_INTENSITY,intensity); glColor3f(0,0.5,0.996); glBegin(GL_POLYGON); glVertex2f(0,0); glVertex2f(1000,0); glVertex2f(0,150); glVertex2f(1000,150); glEnd(); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); draw_cloud(); glClearColor(0.0,0.0,0.0,0.0); glPushMatrix(); glColor3f(1.0,1.0,1.0); glTranslated(400,400,10); glutSolidSphere(20.0,500,100); glPopMatrix(); glColor3f(1.0,1.0,1.0); glBegin(GL_POINTS); glVertex3f(300.0,400.0,10.0); glEnd(); } glPushMatrix(); glTranslatef(ba,bb,bc); glPushMatrix(); draw_bird(); glPopMatrix(); glPopMatrix(); GLfloat i; glPushMatrix(); GLfloat x=0,y=100,j=0; int k; //draw_water(); Sleep(60); q+=5; fq-=3.5; if(q>=440.0) //470 q=-390.0; //400 if(fq<=-300) //500 fq=400.0; //400 wa-=1; if(wa<=(-20)) wa=-0.5; ba+=6; if(ba>=500) ba=-400; glFlush(); glutSwapBuffers(); } void display(void) { draw_all(); } void color_menu(int id) { switch(id) { case 1: flag=0;break; case 2: flag=1;break; case 3: flag=2;break; case 4: exit(0); break; } glutPostRedisplay(); } void main_menu(int id) { switch(id) { case 1: break; case 2:exit(0);break; glutPostRedisplay(); } } int main(int argc,char **argv) { int sub_menu; glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE); glutInitWindowSize(1000,1000); glutInitWindowPosition(0,0); glutCreateWindow("Ship"); sub_menu=glutCreateMenu(color_menu); glutAddMenuEntry("Morning",1); glutAddMenuEntry("Evening",2); glutAddMenuEntry("Night",3); glutAddMenuEntry("Quit",4); glutCreateMenu(main_menu); glutAddSubMenu("View",sub_menu); glutAddMenuEntry("Quit",2); glutAttachMenu(GLUT_RIGHT_BUTTON); glutDisplayFunc(display); glutIdleFunc(display); myinit(); glutMainLoop(); glFlush(); }

    Read the article

  • This code is working properly in Dev C++ .But on Linux platform it is giving problem with the moveme

    - by srinija
    #include<stdio.h> #include<GL/glut.h> #include<stdlib.h> GLfloat v[3][24]={{100.0,300.0,350.0,50.0,100.0,120.0,120.0,100.0,260.0,280.0, 280.0,260.0,140.0,160.0,160.0,140.0,180.0,200.0,200.0,180.0, 220.0,240.0,240.0,220.0},{100.0,100.0,200.0,200.0,160.0, 160.0,180.0,180.0,160.0,160.0,180.0,180.0,160.0,160.0,180.0, 180.0,160.0,160.0,180.0,180.0,160.0,160.0,180.0,180.0}, {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}}; GLfloat v1[3][16]={{50.0,350.0,350.0,50.0,100.0,300.0,300.0,100.0,125.0,175.0, 175.0,125.0,225.0,275.0,275.0,225.0},{200.0,200.0,210.0, 210.0,210.0,210.0,240.0,240.0,240.0,240.0,310.0,310.0,240.0, 240.0,310.0,310.0},{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0}}; GLfloat colors[4][3]={{0.0,0.0,1.0},{0.9961,0.9961,0.65625},{1.0,0.0,1.0}, {1.0,.0,1.0}}; static float q,w,e; static float fq,fw,fe; static GLfloat wa=0,wb=0,wc=0,ba,bb,bc; int flag; void myinit(void) { glClearColor(0.506,.7,1,0.0); glPointSize(2.0); glLoadIdentity(); glOrtho(0.0,499.0,0.0,499.0,-300.0,300.0); } void draw_top_boxes(GLint i,GLint j) { glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glColor3fv(colors[j]); // to draw the boat glVertex2f(v1[0][i+0],v1[1][i+0]); glColor3fv(colors[j+1]); glVertex2f(v1[0][i+1],v1[1][i+1]); glColor3fv(colors[j+2]); glVertex2f(v1[0][i+2],v1[1][i+2]); glColor3fv(colors[j+3]); glVertex2f(v1[0][i+3],v1[1][i+3]); glEnd(); } void draw_polygon(GLint i) { glBegin(GL_POLYGON); // to draw the boat glColor3f(0.0,0.0,0.0); glColor3fv(colors[0]); glVertex2f(v[0][i+0],v[1][i+0]); glColor3fv(colors[1]); glVertex2f(v[0][i+1],v[1][i+1]); glColor3fv(colors[2]); glVertex2f(v[0][i+2],v[1][i+2]); glColor3fv(colors[3]); glVertex2f(v[0][i+3],v[1][i+3]); glEnd(); } void draw_boat() { draw_polygon(0); draw_polygon(4); draw_polygon(8); draw_polygon(12); draw_polygon(16); draw_polygon(20); draw_top_boxes(0,0); draw_top_boxes(4,0); draw_top_boxes(8,0); draw_top_boxes(12,0); glFlush(); glPopMatrix(); glPopMatrix(); } void draw_water() { GLfloat i; GLfloat x=0,y=103,j=0; GLfloat k; glPushMatrix(); glTranslatef(wa,wb,wc); glPushMatrix(); glColor3f(0,0,1); for(k=y;k>0;k-=6) { for(i=1;i<30;i++) { glBegin(GL_LINES); glVertex2f(j,k); glVertex2f(j+10,k); glEnd(); j=j+20; } j=0; } glPopMatrix(); glPopMatrix(); } void draw_fishes() { glPushMatrix(); glTranslatef(fq,12.0,fe); glPushMatrix(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(100,80); glVertex2f(100,60); glVertex2f(85,70); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(100,70); glVertex2f(110,75); glVertex2f(110,65); glEnd(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(90,71); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(200,80); glVertex2f(200,60); glVertex2f(185,70); glEnd(); glColor3f(.99609375,0.2578125,0.2578125); glBegin(GL_TRIANGLES); glVertex2f(200,70); glVertex2f(210,75); glVertex2f(210,65); glEnd(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(190,71); glEnd(); glPopMatrix(); glPopMatrix(); glFlush(); } void draw_cloud() { GLfloat m=100,n=400,o=10; for(int i=0;i<7;i++) { glPushMatrix(); glColor3f(1.0,1.0,1.0); if(i==1) glTranslated(125,415,10); else if(i==3||i==5) glTranslated(m,n+5,o); else glTranslated(m,n,o); glutSolidSphere(20.0,5000,150); glPopMatrix(); m+=10; } } void draw_square() { glColor3f(0,0.5,0.996); glBegin(GL_POLYGON); glVertex2f(0,0); glVertex2f(1000,0); glVertex2f(0,300); glVertex2f(1000,300); glEnd(); glFlush(); } void draw_brotate() { glPushMatrix(); glColor3f(0.96,0.5,0.25); //to draw body of the bird glTranslated(300,400,10); glScalef(3,1,1); glutSolidSphere(6,50000,15); glPopMatrix(); glPushMatrix(); glTranslated(323,400,10); glutSolidSphere(5,50000,15); glPopMatrix(); glColor3f(0,0,0); glBegin(GL_POINTS); glVertex2f(325,401); glEnd(); glColor3f(0.96,0.5,0.25); //to draw wings glBegin(GL_LINES); glVertex2f(294,394); glVertex2f(286,389); glEnd(); glBegin(GL_LINES); glVertex2f(286,389); glVertex2f(295,391); glEnd(); glBegin(GL_LINES); glVertex2f(295,391); glVertex2f(285,385); glEnd(); glBegin(GL_LINES); glVertex2f(285,385); glVertex2f(309,395); glEnd(); glBegin(GL_LINES); glVertex2f(294,406); glVertex2f(286,411); glEnd(); glBegin(GL_LINES); glVertex2f(286,411); glVertex2f(295,409); glEnd(); glBegin(GL_LINES); glVertex2f(295,409); glVertex2f(285,415); glEnd(); glBegin(GL_LINES); glVertex2f(285,415); glVertex2f(309,406); glEnd(); glColor3f(0.96,0.5,0.25); } void draw_bird() { GLfloat x=200,y=400,z=10; draw_brotate(); glBegin(GL_LINES); //draw legs of the bird glVertex2f(285,402); glVertex2f(275,402); glEnd(); glBegin(GL_LINES); glVertex2f(285,398); glVertex2f(275,398); glEnd(); glBegin(GL_LINES); glVertex2f(275,402); glVertex2f(270,405); glEnd(); glBegin(GL_LINES); glVertex2f(275,402); glVertex2f(270,398); glEnd(); glBegin(GL_LINES); glVertex2f(275,398); glVertex2f(273,400); glEnd(); glBegin(GL_LINES); glVertex2f(275,398); glVertex2f(270,395); glEnd(); glBegin(GL_LINES); glVertex2f(323,405); glVertex2f(323,407); glEnd(); glPushMatrix(); glTranslatef(323,409,10); glutSolidSphere(2,200,20); glPopMatrix(); glBegin(GL_TRIANGLES); glVertex2f(328,400); glVertex2f(331,397); glVertex2f(327,398.5); glEnd(); glFlush(); } void drawstars() { glColor3f(1.0,1.0,1.0); glBegin(GL_POINTS); glVertex3f(300.0,400.0,10.0); glVertex3f(200,400.0,10.0); glVertex3f(150,450.0,10.0); glVertex3f(100,470.0,10.0); glVertex3f(50,450.0,10.0); glVertex3f(50,350.0,10.0); glVertex3f(90,365.0,10.0); glVertex3f(350,450.0,10.0); glVertex3f(275,470.0,10.0); glVertex3f(280,430.0,10.0); glVertex3f(250,400.0,10.0); glVertex3f(450,450.0,10.0); glVertex3f(430,430.0,10.0); glVertex3f(430,470.0,10.0); glVertex3f(300,450.0,10.0); glVertex3f(265,380.0,10.0); glVertex3f(235,450.0,10.0); glEnd(); } void draw_all() { glClear(GL_COLOR_BUFFER_BIT); if(flag==0) { glDisable(GL_LIGHTING); //immp one draw_square(); draw_cloud(); glClearColor(0.506,.7,1,0.0); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glPushMatrix(); glColor3f(1.0,1.0,0.0); glTranslated(400,400,10); glutSolidSphere(20.0,5000,150); glPopMatrix(); } if(flag==1) { glDisable(GL_LIGHTING); //imp one draw_square(); draw_cloud(); glClearColor(0.9960,0.7070,0.3164,0.0); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glPushMatrix(); glColor3f(1.0,1.0,0.0); glTranslated(400,400,10); glutSolidSphere(20.0,500,100); glPopMatrix(); } if(flag==2) { // just try and change values in these arrays, specially the position array drawstars(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // GLfloat emission[]={0.1,0.1,0.1,0.0}; GLfloat diffuse[] = { 0.40, 0.40,0.40, 1.0 }; GLfloat ambiance[] = { 0.5, 0.5,0.5, 1.0 }; GLfloat specular[] = { 1.3, 1.3,.3, 1.0 }; GLfloat intensity[]={500.0}; GLfloat position[] = { 10,30,-30,1.0 }; glLightfv (GL_LIGHT0, GL_POSITION, position); glLightfv (GL_LIGHT0, GL_DIFFUSE,diffuse); glLightfv (GL_LIGHT0, GL_AMBIENT,ambiance); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); glLightfv (GL_LIGHT0, GL_SPECULAR,specular); glLightfv (GL_LIGHT0, GL_INTENSITY,intensity); glColor3f(0,0.5,0.996); glBegin(GL_POLYGON); glVertex2f(0,0); glVertex2f(1000,0); glVertex2f(0,150); glVertex2f(1000,150); glEnd(); glTranslatef(q,w,e); glPushMatrix(); glColor3f(1.0,0.0,0.0); draw_boat(); draw_fishes(); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); draw_cloud(); glClearColor(0.0,0.0,0.0,0.0); glPushMatrix(); glColor3f(1.0,1.0,1.0); glTranslated(400,400,10); glutSolidSphere(20.0,500,100); glPopMatrix(); glColor3f(1.0,1.0,1.0); glBegin(GL_POINTS); glVertex3f(300.0,400.0,10.0); glEnd(); } glPushMatrix(); glTranslatef(ba,bb,bc); glPushMatrix(); draw_bird(); glPopMatrix(); glPopMatrix(); GLfloat i; glPushMatrix(); GLfloat x=0,y=100,j=0; int k; //draw_water(); q+=25; fq-=3.5; if(q>=440.0) //470 q=-390.0; //400 if(fq<=-300) //500 fq=400.0; //400 wa-=1; if(wa<=(-20)) wa=-0.5; ba+=6; if(ba>=500) ba=-400; glFlush(); glutSwapBuffers(); } void display(void) { draw_all(); } void color_menu(int id) { switch(id) { case 1: flag=0;break; case 2: flag=1;break; case 3: flag=2;break; case 4: exit(0); break; } glutPostRedisplay(); } void main_menu(int id) { switch(id) { case 1: break; case 2:exit(0);break; glutPostRedisplay(); } } int main(int argc,char **argv) { int sub_menu; glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE); glutInitWindowSize(1000,1000); glutInitWindowPosition(0,0); glutCreateWindow("Ship"); sub_menu=glutCreateMenu(color_menu); glutAddMenuEntry("Morning",1); glutAddMenuEntry("Evening",2); glutAddMenuEntry("Night",3); glutAddMenuEntry("Quit",4); glutCreateMenu(main_menu); glutAddSubMenu("View",sub_menu); glutAddMenuEntry("Quit",2); glutAttachMenu(GLUT_RIGHT_BUTTON); glutDisplayFunc(display); glutIdleFunc(display); myinit(); glutMainLoop(); glFlush(); }

    Read the article

  • How to fix: "NPMethod called on non-NPObject wrapped JSObject" error?

    - by chandra
    HI, I am trying to call a method defined in flash object from javascript (firefox-3.0/Linux) and getting the exception: "NPMethod called on non- NPObject wrapped JSObject". If I use eval on window.document.flash_object.func() it throws "NPMethod called on non-NPObject wrapped JSObject". Where as, if I define a javascript function in side the page as given below: function myFunc() { return flash_object.func(); } and later do a eval of window.document.myFunc() it works fine. I am running the two evals through a test framework called Selenium. [eval(window.document.flash_object.func()) and eval(window.document.myFunc())]. The issues seems to be issue with invoking the flash-object method without passing 'this' reference. Here is sample html/js code to reproduce this issue: "NPMethod called on non-NPObject wrapped JSObject". <script> function changeColor() { mymovie.changeColor(); } function getColorNP() { var func = mymovie.getColor; func(); } </script> <button type="button" onclick="getColorNP();">getColorNP</button> <button type="button" onclick="getColor();">getColor</button> getColorNP throws the exception Error: NPMethod called on non-NPObject wrapped JSObject! Source File: http://my.host/Colors/colors.html getColorNP throws the exception Error: NPMethod called on non-NPObject wrapped JSObject! Source File: http://my.host/Colors/colors.html Now, question to javascript gurus: Given flash object and a method name, how do I invoke the method on that object. Lets say, a function takes two arguments: a flash object, and a method name as string. I want to do an eval on object.method() inside that function. Is this possible, if so, can you please explain me how this can be done. As flash object's method is not a standard javascript function, i think its not possible to function binding through bind(). Is there any other alternative? Thx, Chandra

    Read the article

  • vtk glyphs 3D, indenpently color and rotation

    - by user3684219
    I try to display thanks to vtk (python wrapper) several glyphs in a scene with each their own colour and rotation. Unfortunately, just the rotation (using vtkTensorGlyph) is taken in consideration by vtk. Reversely, just color is taken in consideration when I use a vtkGlyph3D. Here is a ready to use piece of code with a vtkTensorGlyph. Each cube should have a random color but there all will be in the same color. I read and read again the doc of vtk but I found no solution. Thanks in advance for any idea #!/usr/bin/env python # -*- coding: utf-8 -*- import vtk import scipy.linalg as sc import random as ra import numpy as np import itertools points = vtk.vtk.vtkPoints() # where to locate each glyph in the scene tensors = vtk.vtkDoubleArray() # rotation for each glyph tensors.SetNumberOfComponents(9) colors = vtk.vtkUnsignedCharArray() # should be the color for each glyph colors.SetNumberOfComponents(3) # let's make 10 cubes in the scene for i in range(0, 50, 5): points.InsertNextPoint(i, i, i) # position of a glyph colors.InsertNextTuple3(ra.randint(0, 255), ra.randint(0, 255), ra.randint(0, 255) ) # pick random color rot = list(itertools.chain(*np.reshape(sc.orth(np.random.rand(3, 3)).transpose(), (1, 9)).tolist())) # random rotation matrix (row major) tensors.InsertNextTuple9(*rot) polydata = vtk.vtkPolyData() # create the polydatas polydata.SetPoints(points) polydata.GetPointData().SetTensors(tensors) polydata.GetPointData().SetScalars(colors) cubeSource = vtk.vtkCubeSource() cubeSource.Update() glyphTensor = vtk.vtkTensorGlyph() glyphTensor.SetColorModeToScalars() # is it really work ? try: glyphTensor.SetInput(polydata) except AttributeError: glyphTensor.SetInputData(polydata) glyphTensor.SetSourceConnection(cubeSource.GetOutputPort()) glyphTensor.ColorGlyphsOn() # should not color all cubes independently ? glyphTensor.ThreeGlyphsOff() glyphTensor.ExtractEigenvaluesOff() glyphTensor.Update() # next is usual vtk code mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(glyphTensor.GetOutputPort()) actor = vtk.vtkActor() actor.SetMapper(mapper) ren = vtk.vtkRenderer() ren.SetBackground(0.2, 0.5, 0.3) ren.AddActor(actor) renwin = vtk.vtkRenderWindow() renwin.AddRenderer(ren) iren = vtk.vtkRenderWindowInteractor() iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera()) iren.SetRenderWindow(renwin) renwin.Render() iren.Initialize() renwin.Render() iren.Start()

    Read the article

  • Sourcing a shell script, while running with sudo

    - by WishCow
    I would like to write a shell script that sets up a mercurial repository, and allow all users in the group "developers" to execute this script. The script is owned by the user "hg", and works fine when ran. The problem comes when I try to run it with another user, using sudo, the execution halts with a "permission denied" error, when it tries to source another file. The script file in question: create_repo.sh #!/bin/bash source colors.sh REPOROOT="/srv/repository/mercurial/" ... rest of the script .... Permissions of create_repo.sh, and colors.sh: -rwxr--r-- 1 hg hg 551 2011-01-07 10:20 colors.sh -rwxr--r-- 1 hg hg 1137 2011-01-07 11:08 create_repo.sh Sudoers setup: %developer ALL = (hg) NOPASSWD: /home/hg/scripts/create_repo.sh What I'm trying to run: user@nebu:~$ id uid=1000(user) gid=1000(user) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),113(sambashare),116(admin),1000(user),1001(developer) user@nebu:~$ sudo -l Matching Defaults entries for user on this host: env_reset User user may run the following commands on this host: (ALL) ALL (hg) NOPASSWD: /home/hg/scripts/create_repo.sh user@nebu:~$ sudo -u hg /home/hg/scripts/create_repo.sh /home/hg/scripts/create_repo.sh: line 3: colors.sh: Permission denied So the script is executed, but halts when it tries to include the other script. I have also tried using: user@nebu:~$ sudo -u hg /bin/bash /home/hg/scripts/create_repo.sh Which gives the same result. What is the correct way to include another shell script, if the script may be ran with a different user, through sudo?

    Read the article

  • ActionScript 3.0 Color Output Error?

    - by TheDarkIn1978
    I'm employing color in a current AS3 project, and have come across what appears to be an error in the Flash Player (version 10). it might also be an error with Apple's DigitalColor Meter (version 3.7.2), which is what i'm using to sample the displayed colors on Mac OS X Snow Leopard (version 10.6.3). //Primary, secondary, and tertiary colors of the RGB color wheel var red:Number = 0xFF0000; var orange:Number = 0xFF7D00; var yellow:Number = 0xFFFF00; var chartreuse:Number = 0x7DFF00; var green:Number = 0x00FF00; var spring:Number = 0x00FF7D; var cyan:Number = 0x00FFFF; var azure:Number = 0x007DFF; //reads 0x0077FF var blue:Number = 0x0000FF; var violet:Number = 0x7D00FF; var magenta:Number = 0xFF00FF; //reads 0xFF00F8 var rose:Number = 0xFF007D; //reads 0xFF0077 all of these colors display normally except for 3: Azure, Magenta and Rose. they are coded with the appropriate number, but when i use the color meter to sample the displayed colors, those 3 return inaccurate results. anyone have any insight about this issue? what is causing the error, the Flash runtime or the color sampler? if it's the Flash player, could this problem be much deeper? *sampling this image will return inaccurate results due to .jpg compression. it's simply for illustration

    Read the article

  • Who could ask for more with LESS CSS? (Part 3 of 3&ndash;Clrizr)

    - by ToString(theory);
    Welcome back!  In the first two posts in this series, I covered some of the awesome features in CSS precompilers such as SASS and LESS, as well as how to get an initial project setup up and running in ASP.Net MVC 4. In this post, I will cover an actual advanced example of using LESS in a project, and show some of the great productivity features we gain from its usage. Introduction In the first post, I mentioned two subjects that I will be using in this example – constants, and color functions.  I’ve always enjoyed using online color scheme utilities such as Adobe Kuler or Color Scheme Designer to come up with a scheme based off of one primary color.  Using these tools, and requesting a complementary scheme you can get a couple of shades of your primary color, and a couple of shades of a complementary/accent color to display. Because there is no way in regular css to do color operations or store variables, there was no way to accomplish something like defining a primary color, and have a site theme cascade off of that.  However with tools such as LESS, that impossibility becomes a reality!  So, if you haven’t guessed it by now, this post is on the creation of a plugin/module/less file to drop into your project, plugin one color, and have your primary theme cascade from it.  I only went through the trouble of creating a module for getting Complementary colors.  However, it wouldn’t be too much trouble to go through other options such as Triad or Monochromatic to get a module that you could use off of that. Step 1 – Analysis I decided to mimic Adobe Kuler’s Complementary theme algorithm as I liked its simplicity and aesthetics.  Color Scheme Designer is great, but I do believe it can give you too many color options, which can lead to chaos and overload.  The first thing I had to check was if the complementary values for the color schemes were actually hues rotated by 180 degrees at all times – they aren’t.  Apparently Adobe applies some variance to the complementary colors to get colors that are actually more aesthetically appealing to users.  So, I opened up Excel and began to plot complementary hues based on rotation in increments of 10: Long story short, I completed the same calculations for Hue, Saturation, and Lightness.  For Hue, I only had to record the Complementary hue values, however for saturation and lightness, I had to record the values for ALL of the shades.  Since the functions were too complicated to put into LESS since they aren’t constant/linear, but rather interval functions, I instead opted to extrapolate the HSL values using the trendline function for each major interval, onto intervals of spacing 1. For example, using the hue extraction, I got the following values: Interval Function 0-60 60-140 140-270 270-360 Saturation and Lightness were much worse, but in the end, I finally had functions for all of the intervals, and then went the route of just grabbing each shades value in intervals of 1.  Step 2 – Mapping I declared variable names for each of these sections as something that shouldn’t ever conflict with a variable someone would define in their own file.  After I had each of the values, I extracted the values and put them into files of their own for hue variables, saturation variables, and lightness variables…  Example: /*HUE CONVERSIONS*/@clrizr-hue-source-0deg: 133.43;@clrizr-hue-source-1deg: 135.601;@clrizr-hue-source-2deg: 137.772;@clrizr-hue-source-3deg: 139.943;@clrizr-hue-source-4deg: 142.114;.../*SATURATION CONVERSIONS*/@clrizr-saturation-s2SV0px: 0;@clrizr-saturation-s2SV1px: 0;@clrizr-saturation-s2SV2px: 0;@clrizr-saturation-s2SV3px: 0;@clrizr-saturation-s2SV4px: 0;.../*LIGHTNESS CONVERSIONS*/@clrizr-lightness-s2LV0px: 30;@clrizr-lightness-s2LV1px: 31;@clrizr-lightness-s2LV2px: 32;@clrizr-lightness-s2LV3px: 33;@clrizr-lightness-s2LV4px: 34;...   In the end, I have 973 lines of mapping/conversion from source HSL to shade HSL for two extra primary shades, and two complementary shades. The last bit of the work was the file to compose each of the shades from these mappings. Step 3 – Clrizr Mapper The final step was the hardest to overcome as I was still trying to understand LESS to its fullest extent.  Imports As mentioned previously, I had separated the HSL mappings into different files, so the first necessary step is to import those for use into the Clrizr plugin: @import url("hue.less");@import url("saturation.less");@import url("lightness.less"); Extract Component Values For Each Shade Next, I extracted the necessary information for each shade HSL before shade composition: @clrizr-input-saturation: 1px+floor(saturation(@clrizr-input))-1;@clrizr-input-lightness: 1px+floor(lightness(@clrizr-input))-1; @clrizr-complementary-hue: formatstring("clrizr-hue-source-{0}", ceil(hue(@clrizr-input))); @clrizr-primary-2-saturation: formatstring("clrizr-saturation-s2SV{0}",@clrizr-input-saturation);@clrizr-primary-1-saturation: formatstring("clrizr-saturation-s1SV{0}",@clrizr-input-saturation);@clrizr-complementary-1-saturation: formatstring("clrizr-saturation-c1SV{0}",@clrizr-input-saturation); @clrizr-primary-2-lightness: formatstring("clrizr-lightness-s2LV{0}",@clrizr-input-lightness);@clrizr-primary-1-lightness: formatstring("clrizr-lightness-s1LV{0}",@clrizr-input-lightness);@clrizr-complementary-1-lightness: formatstring("clrizr-lightness-c1LV{0}",@clrizr-input-lightness); Here, you can see a couple of odd things…  On the first line, I am using operations to add units to the saturation and lightness.  This is due to some limitations in the operations that would give me saturation or lightness in %, which can’t be in a variable name.  So, I use first add 1px to it, which casts the result of the following functions as px instead of %, and then at the end, I remove that pixel.  You can also see here the formatstring method which is exactly what it sounds like – something like String.Format(string str, params object[] obj). Get Primary & Complementary Shades Now that I have components for each of the different shades, I can now compose them into each of their pieces.  For this, I use the @@ operator which will look for a variable with the name specified in a string, and then call that variable: @clrizr-primary-2: hsl(hue(@clrizr-input), @@clrizr-primary-2-saturation, @@clrizr-primary-2-lightness);@clrizr-primary-1: hsl(hue(@clrizr-input), @@clrizr-primary-1-saturation, @@clrizr-primary-1-lightness);@clrizr-primary: @clrizr-input;@clrizr-complementary-1: hsl(@@clrizr-complementary-hue, @@clrizr-complementary-1-saturation, @@clrizr-complementary-1-lightness);@clrizr-complementary-2: hsl(@@clrizr-complementary-hue, saturation(@clrizr-input), lightness(@clrizr-input)); That’s is it, for the most part.  These variables now hold the theme for the one input color – @clrizr-input.  However, I have one last addition… Perceptive Luminance Well, after I got the colors, I decided I wanted to also get the best font color that would go on top of it.  Black or white depending on light or dark color.  Now I couldn’t just go with checking the lightness, as that is half the story.  You see, the human eye doesn’t see ALL colors equally well but rather has more cells for interpreting green light compared to blue or red.  So, using the ratio, we can calculate the perceptive luminance of each of the shades, and get the font color that best matches it! @clrizr-perceptive-luminance-ps2: round(1 - ( (0.299 * red(@clrizr-primary-2) ) + ( 0.587 * green(@clrizr-primary-2) ) + (0.114 * blue(@clrizr-primary-2)))/255)*255;@clrizr-perceptive-luminance-ps1: round(1 - ( (0.299 * red(@clrizr-primary-1) ) + ( 0.587 * green(@clrizr-primary-1) ) + (0.114 * blue(@clrizr-primary-1)))/255)*255;@clrizr-perceptive-luminance-ps: round(1 - ( (0.299 * red(@clrizr-primary) ) + ( 0.587 * green(@clrizr-primary) ) + (0.114 * blue(@clrizr-primary)))/255)*255;@clrizr-perceptive-luminance-pc1: round(1 - ( (0.299 * red(@clrizr-complementary-1)) + ( 0.587 * green(@clrizr-complementary-1)) + (0.114 * blue(@clrizr-complementary-1)))/255)*255;@clrizr-perceptive-luminance-pc2: round(1 - ( (0.299 * red(@clrizr-complementary-2)) + ( 0.587 * green(@clrizr-complementary-2)) + (0.114 * blue(@clrizr-complementary-2)))/255)*255; @clrizr-col-font-on-primary-2: rgb(@clrizr-perceptive-luminance-ps2, @clrizr-perceptive-luminance-ps2, @clrizr-perceptive-luminance-ps2);@clrizr-col-font-on-primary-1: rgb(@clrizr-perceptive-luminance-ps1, @clrizr-perceptive-luminance-ps1, @clrizr-perceptive-luminance-ps1);@clrizr-col-font-on-primary: rgb(@clrizr-perceptive-luminance-ps, @clrizr-perceptive-luminance-ps, @clrizr-perceptive-luminance-ps);@clrizr-col-font-on-complementary-1: rgb(@clrizr-perceptive-luminance-pc1, @clrizr-perceptive-luminance-pc1, @clrizr-perceptive-luminance-pc1);@clrizr-col-font-on-complementary-2: rgb(@clrizr-perceptive-luminance-pc2, @clrizr-perceptive-luminance-pc2, @clrizr-perceptive-luminance-pc2); Conclusion That’s it!  I have posted a project on clrizr.codePlex.com for this, and included a testing page for you to test out how it works.  Feel free to use it in your own project, and if you have any questions, comments or suggestions, please feel free to leave them here as a comment, or on the contact page!

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >