AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Rgb <---> ryb

Ein Thema von WojTec · begonnen am 15. Jun 2010 · letzter Beitrag vom 4. Jan 2012
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Rgb <---> ryb

  Alt 15. Jun 2010, 16:06
I found new (but historical) colors set - RYB. Do you know how to make convertion RGB <---> RYB (I not found any informations about it)?

Geändert von WojTec (15. Jun 2010 um 16:06 Uhr) Grund: Forgot prefix
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Rgb <---> ryb

  Alt 15. Jun 2010, 16:08
It ain't that easy. Because you have to calc Yellow from the other color channels
Markus Kinzler
  Mit Zitat antworten Zitat
tkone

Registriert seit: 2. Okt 2009
Ort: Sachsen
63 Beiträge
 
Delphi 7 Professional
 
#3

AW: Rgb <---> ryb

  Alt 15. Jun 2010, 16:49
try looking here

http://www.paintassistant.com/rybrgb.html
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Rgb <---> ryb

  Alt 15. Jun 2010, 18:53
Hmm, From RYB is not hard:

Code:
<script language="javascript1.1" type="text/javascript">

        function cubicInt(t, A, B){
          var weight = t*t*(3-2*t);
          return A + weight*(B-A);
          }

   function getR (iR, iY, iB) {
      var x0, x1, x2, x3, y0, y1;
      //red
      var x0 = cubicInt(iB, 1.0, 0.163);
      var x1 = cubicInt(iB, 1.0, 0.0);
      var x2 = cubicInt(iB, 1.0, 0.5);
      var x3 = cubicInt(iB, 1.0, 0.2);
      var y0 = cubicInt(iY, x0, x1);
      var y1 = cubicInt(iY, x2, x3);
      return Math.ceil (255 * cubicInt(iR, y0, y1));
        }

   function getG (iR, iY, iB) {
      var x0, x1, x2, x3, y0, y1;
      //green
      x0 = cubicInt(iB, 1.0, 0.373);
      x1 = cubicInt(iB, 1.0, 0.66);
      x2 = cubicInt(iB, 0.0, 0.0);
      x3 = cubicInt(iB, 0.5, 0.094);
      y0 = cubicInt(iY, x0, x1);
      y1 = cubicInt(iY, x2, x3);
      return Math.ceil (255 * cubicInt(iR, y0, y1));
         }

   function getB (iR, iY, iB) {
      var x0, x1, x2, x3, y0, y1;
      //blue
      x0 = cubicInt(iB, 1.0, 0.6);
      x1 = cubicInt(iB, 0.0, 0.2);
      x2 = cubicInt(iB, 0.0, 0.5);
      x3 = cubicInt(iB, 0.0, 0.0);
      y0 = cubicInt(iY, x0, x1);
      y1 = cubicInt(iY, x2, x3);
      return Math.ceil (255 * cubicInt(iR, y0, y1));
          }

   function RYB2RGB(){
      var R = document.all.r0.value;
      var Y = document.all.y0.value;
      var B = document.all.b0.value;
       
      
      if ( 
         isNaN( R ) || isNaN( Y ) || isNaN( B ) ||

         (R < 0 || R > 1) ||
         (Y < 0 || Y > 1) ||
         (B < 0 || B > 1)
         )
         {
         alert('Invalid RYB values');
         return;
      }
      //----------------------------
      var R1 = getR(R,Y,B) ;
      var G1 = getG(R,Y,B) ;
      var B1 = getB(R,Y,B) ;

      
      //----------------------------
      document.all.r1.innerText = R1;
      document.all.g1.innerText = G1;
      document.all.b1.innerText = B1;
      //-----------------------------


      document.getElementById("colorBox").style.backgroundColor="rgb("+R1+","+G1+","+B1+")";

   }

</script>
RYB elements should always be single in range 0..1?

What about from RGB?
  Mit Zitat antworten Zitat
tkone

Registriert seit: 2. Okt 2009
Ort: Sachsen
63 Beiträge
 
Delphi 7 Professional
 
#5

AW: Rgb <---> ryb

  Alt 16. Jun 2010, 11:06
converting ryb and rgb is only a mathematical construct. the way to convert is by a color wheel or the cubic interpolation method. you need to have a look at what the javascript does, and why.
if you understood, how to transform ryb to rgb you can possibly rearange the term for rgb to ryb.

the 0..1 is because only the propotions count in ryb/cmy/cmyk (historical because of mixing paint)
the rgb (0..255) is only because they are used for computerlanguage (hex) 00 to FF

Geändert von tkone (16. Jun 2010 um 11:15 Uhr)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#6

Re: Rgb <---> ryb

  Alt 4. Jan 2012, 15:58
I don't know how to reverse it back. I searched over the net, and don't found any information (only wheel) about this model and conversions. Please F1.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:55 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz