(defvar sample-question-unauthenticated ;;; A sample of data offered by the question object, without authentication. '((body . "
I am getting \"rgb(18, 115, 224)\" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use
\"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b)
but, My question here's how can I get the r, g,b component values from \"rgb(18, 115, 224)\"
") (title . "get r, g, b component of a color in rgb() format") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format") (body_markdown . "I am getting "rgb(18, 115, 224)" from a dom element. Now I want to assign the color(whatever i am getting from this element) to a span element. So I need hexadecimal equivalent of the color I am getting. For this I can use "#" + componentToHex(r) + componentToHex(g) + componentToHex(b) but, My question here's how can I get the r, g,b component values from "rgb(18, 115, 224)"") (question_id . 26679366) (creation_date . 1414773223.0) (last_activity_date . 1414773433.0) (score . 0) (answer_count . 2) (view_count . 16) (is_answered . :json-false) (comment_count . 1) (comments . [((comment_id . 41957708) (post_id . 26679366) (creation_date . 1414773413.0) (score . 0) (edited . :json-false) (owner (link . "http://stackoverflow.com/users/14104/epascarello") (display_name . "epascarello") (profile_image . "https://www.gravatar.com/avatar/760b4da77fd54d37c104029ff1f56749?s=128&d=identicon&r=PG") (user_type . "registered") (user_id . 14104) (reputation . 76145)))]) (owner (link . "http://stackoverflow.com/users/3867678/rasmita-dash") (display_name . "Rasmita Dash") (profile_image . "http://graph.facebook.com/100001985977413/picture?type=large") (accept_rate . 45) (user_type . "registered") (user_id . 3867678) (reputation . 90)) (tags . ["javascript" "jquery" "html" "css" "colors"]) (answers . [((body . "Now I want to assign the color(whatever i am getting from this element) to a span element.
No you don't, you can just use rgb(18, 115, 224)
directly for a color value in CSS.
You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:
var clr = rgb(18, 115, 224);
$('#myspan').css('color', clr);
") (link . "http://stackoverflow.com/questions/26679366/get-r-g-b-component-of-a-color-in-rgb-format/26679423#26679423") (body_markdown . "You don't need to convert it to anything. If you want to assign this value to a span colour, then simply do:
var clr = rgb(18, 115, 224);
$('#myspan').css('color', clr);") (question_id . 26679366) (answer_id . 26679423) (creation_date . 1414773433.0) (last_activity_date . 1414773433.0) (score . 0) (is_accepted . :json-false) (comment_count . 0) (owner (link . "http://stackoverflow.com/users/717214/aleks-g") (display_name . "Aleks G") (profile_image . "https://www.gravatar.com/avatar/9075315c5f4b734a8f2567be54a4cc45?s=128&d=identicon&r=PG") (accept_rate . 92) (user_type . "registered") (user_id . 717214) (reputation . 26812)))])))
(provide 'sample-question-unauthenticated)