Writes a tRNS chunk containing the alpha values of indexed colors.

@param \Jdenticon\Canvas\Png\PngPalette $palette Palette containing the
indexed colors.
325054
public function writeTransparency(PngPalette $palette) 
    {
        if ($palette && $palette->isValid && $palette->hasAlphaChannel) {
            $this->buffer->startChunk("tRNS");
            
            $alpha = '';

            foreach ($palette->colors as $color) {
                $alpha .= pack('C', $color & 0xff);
            }
            
            $this->buffer->writeString($alpha);

            $this->buffer->endChunk();
        }
    }
121746
public function write($key, $data)
    {
        apcu_store($this->_prefix . $key, $data, $this->_ttl);
    }
591473
function palette({ baseColor: themeColor = baseColor, src = 'css/rsuite.min.css', dist } = {}, doneCallback) {

  try {
    if (!dist) {
      throw  `ERROR: [option.dist] is required`;
    }
  } catch (e) {
    console.log(e.red);
    return;
  }

  const originColors = color.calcColors(baseColor);
  const themeColors = color.calcColors(themeColor);
  const distPath = Path.dirname(dist);

  const ensureDir = path => new Promise((resolve) => {
    fse.ensureDir(path, () => resolve());
  });

  const readData = path => new Promise(resolve => {
    fs.readFile(path, 'utf-8', (err, data) => {
      resolve(data || '');
    });
  });

  const writeData = (path, data) => new Promise((resolve, reject) => {
    fs.writeFile(path, data, (err) => {
      if (err) {
        reject(err);
      }
      resolve();
    });
  });

  const handleCallback = (...args) => doneCallback && doneCallback(args);

  const generateThemes = async function () {
    try {
      await ensureDir(distPath);
      let data = await readData(Path.join(rootPath, src));
      originColors.forEach((color, index) => {
        data = data.replace(new RegExp(color, 'g'), themeColors[index]);
      });
      await  writeData(dist, data);
      console.log(`Palette ${dist}` + '[SUCCESS]'.green);
      handleCallback();
    } catch (e) {
      console.log(`Palette ${dist}` + '[FAILD]'.red);
      handleCallback(e);
    }
  };

  generateThemes();

  return module.exports;
}
1361849
public function setPalettePropertyValueConditionClassName($palettePropertyValueConditionClassName)
    {
        $event = new SetPalettePropertyValueConditionClassNameEvent($palettePropertyValueConditionClassName, $this);
        $this->dispatchEvent($event);
        $palettePropertyValueConditionClassName = $event->getPalettePropertyValueConditionClassName();

        $this->palettePropertyValueConditionClassName = (string) $palettePropertyValueConditionClassName;
        $this->palettePropertyValueConditionClass     = new \ReflectionClass(
            $this->palettePropertyValueConditionClassName
        );
        return $this;
    }
1206577
def setColorSet(self, colorSet):
        
        self._colorSet = colorSet
        
        # update the palette information
        palette = self.palette()
        palette.setColor( palette.Text, colorSet.color('Standard') )
        palette.setColor( palette.Base, colorSet.color('Background') )
        self.setPalette(palette)
18369
private function getVisibleAndEditAbleProperties(PaletteInterface $palette, ModelInterface $model)
    {
        return \array_intersect(
            \array_map(
                function (PropertyInterface $property) {
                    return $property->getName();
                },
                $palette->getVisibleProperties($model)
            ),
            \array_map(
                function (PropertyInterface $property) {
                    return $property->getName();
                },
                $palette->getEditableProperties($model)
            )
        );
    }
77199
def on_palette_color_set(self, btn):
        

        palette = []
        for i in range(18):
            palette.append(hexify_color(self.get_widget('palette_%d' % i).get_color()))
        palette = ':'.join(palette)
        self.settings.styleFont.set_string('palette', palette)
        self.settings.styleFont.set_string('palette-name', _('Custom'))
        self.set_palette_name('Custom')
        self.update_demo_palette(palette)
100335
public function addColors($colors)
    {
        $args = func_get_args();
        foreach ($args as $arg) {
            if (is_array($arg)) {
                foreach ($arg as $color) {
                    $this->addColor($color);
                }
            } else {
                $this->addColor($arg);
            }
        }
    }
1340240
public function setCharset($charset)
    {
        $this->charset = $charset;
        $this->factory->charsetChanged($charset);
        $this->notifyHeadersOfCharset($charset);
    }
967290
protected function _set_stroke_colour($colour) {
    $colour[0] = round(255 * $colour[0]);
    $colour[1] = round(255 * $colour[1]);
    $colour[2] = round(255 * $colour[2]);

    if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) {
      $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]);
      $this->_last_stroke_color = $color;
    }

  }
775753
def print_colors(palette, outfile="Palette.png"):
    
    fig = plt.figure()
    ax = fig.add_subplot(111)

    xmax = 20 * (len(palette) + 1)
    x1s = np.arange(0, xmax, 20)
    xintervals = [10] * len(palette)
    xx = zip(x1s, xintervals)
    ax.broken_barh(xx, (5, 10), facecolors=palette)

    ax.set_ylim(0, 20)
    ax.set_xlim(0, xmax)
    ax.set_axis_off()

    savefig(outfile)
1233002
public function loadPalette($FileName, $Overwrite = false)
    {
        $path = file_exists($FileName)
            ? $FileName
            : sprintf('%s/../resources/palettes/%s', __DIR__, ltrim($FileName, '/'))
        ;

        $fileHandle = @fopen($path, "r");
        if (!$fileHandle) {
            throw new Exception(sprintf(
                'The requested palette "%s" was not found at path "%s"!',
                $FileName,
                $path
            ));
        }

        if ($Overwrite) {
            $this->Palette = [];
        }

        while (!feof($fileHandle)) {
            $line = fgets($fileHandle, 4096);
            if (false === $line) {
                continue;
            }
            $row = explode(',', $line);
            if (empty($row)) {
                continue;
            }
            if (count($row) !== 4) {
                throw new RuntimeException(sprintf(
                    'A palette row must supply R, G, B and Alpha components, %s given!',
                    var_export($row, true)
                ));
            }
            list($R, $G, $B, $Alpha) = $row;
            $ID = count($this->Palette);
            $this->Palette[$ID] = [
                "R" => trim($R),
                "G" => trim($G),
                "B" => trim($B),
                "Alpha" => trim($Alpha)
            ];
        }
        fclose($fileHandle);

        /* Apply changes to current series */
        $ID = 0;
        if (isset($this->Data["Series"])) {
            foreach ($this->Data["Series"] as $Key => $Value) {
                if (!isset($this->Palette[$ID])) {
                    $this->Data["Series"][$Key]["Color"] = ["R" => 0, "G" => 0, "B" => 0, "Alpha" => 0];
                } else {
                    $this->Data["Series"][$Key]["Color"] = $this->Palette[$ID];
                }
                $ID++;
            }
        }
    }
1001009
public function usePaletteCollection(PaletteCollectionInterface $paletteCollection)
    {
        if ($this->paletteCollection) {
            $this->finishPaletteCollection();
        }

        $event = new UsePaletteCollectionEvent($paletteCollection, $this);
        $this->dispatchEvent($event);
        $this->paletteCollection = $paletteCollection;

        return $this;
    }
703736
function allocateColor( $name, $red, $green, $blue )
    {
        if ( isset( $this->Palette[$name] ) )
        {
            eZDebug::writeError( 'Color already defined: ' . $name, __METHOD__ );
            return null;
        }
        $red = max( 0, min( 255, $red ) );
        $green = max( 0, min( 255, $green ) );
        $blue = max( 0, min( 255, $blue ) );
        $color = ImageColorAllocate( $this->ImageObject, $red, $green, $blue );
        $this->Palette[$name] = $color;
        $this->PaletteIndex[] = $color;
        return $color;
    }
1042671
def set_palette(self, background, foreground):
        
        palette = QPalette()
        palette.setColor(QPalette.Base, background)
        palette.setColor(QPalette.Text, foreground)
        self.setPalette(palette)

        # Set the right background color when changing color schemes
        # or creating new Editor windows. This seems to be a Qt bug.
        # Fixes Issue 2028 and 8069
        if self.objectName():
            style = "QPlainTextEdit#%s {background: %s; color: %s;}" % \
                    (self.objectName(), background.name(), foreground.name())
            self.setStyleSheet(style)
1073798
public static function writeln($text = '', $text_color = null, $bg_color = null)
    {
        self::write("{$text}\n", $text_color, $bg_color);
    }
773002
public function getPaletteByName($paletteName)
    {
        foreach ($this->palettes as $palette) {
            if ($paletteName === $palette->getName()) {
                return $palette;
            }
        }

        throw new DcGeneralInvalidArgumentException('No palette found for name ' . $paletteName);
    }