Class: Rixmap::Palette
- Inherits:
-
Object
- Object
- Rixmap::Palette
- Includes:
- Enumerable
- Defined in:
- src/rixmapcore.cxx,
src/rixmapcore.cxx
Overview
文字列からレイアウトに沿って更新するメソッド (#to_s の逆) の実装
パレット情報クラス.
Defined Under Namespace
Instance Method Summary collapse
-
#==(argObject) ⇒ Boolean
オブジェクトと比較して、同じパレットデータかどうかを調べます.
-
#[](argOffset) ⇒ Rixmap::Color?
パレットからカラーオブジェクトを取得します.
-
#[]=(argOffset, argColor)
パレットのカラーオブジェクトを設定します.
-
#each ⇒ Object
パレットの各色を順番に走査するイテレータを返すか、各色を順にブロックに渡して走査します.
-
#export(layout = 'RGBA') ⇒ Object
パレットをバイト列へと変換します.
-
#import!(data, layout = 'RGBA', range = nil) ⇒ Rixmap::Palette
バイト列データをレイアウトに従って解釈し、パレットデータを更新します.
-
#initialize(size = 256)
constructor
private
パレットを新しく作成します.
-
#initialize_copy(argObject)
private
複製されたオブジェクトを初期化します.
-
#inspect ⇒ String
オブジェクトとしての文字列表現を返します.
-
#map {|color| ... } ⇒ Rixmap::Palette
パレット内の各要素についてブロックを呼び出し、その戻り値からなる新しいパレットを返します.
-
#map! {|color| ... } ⇒ Rixmap::Palette
各要素についてブロックを呼び出し、その戻り値でパレットデータを破壊的に変更します.
-
#size ⇒ Integer
パレットサイズを取得します.
-
#to_a ⇒ Array<Rixmap::Color>
パレットをカラーオブジェクト配列に変換します.
Constructor Details
#initialize(size = 256) (private)
パレットを新しく作成します.
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
# File 'src/rixmapcore.cxx', line 1343 static VALUE Palette_initialize(int argc, VALUE* argv, VALUE self) { VALUE argSize; rb_scan_args(argc, argv, "01", &argSize); long size = 256; if (!NIL_P(argSize)) { size = NUM2LONG(rb_Integer(argSize)); } if (size <= 0) { rb_raise(rb_eArgError, "palette size must be positive: %ld", size); } // |
Instance Method Details
#==(argObject) ⇒ Boolean
オブジェクトと比較して、同じパレットデータかどうかを調べます.
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
# File 'src/rixmapcore.cxx', line 1454 static VALUE Palette_operatorEquals(VALUE self, VALUE argObject) { if (RTEST(rb_obj_is_kind_of(argObject, cRixmapPalette))) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); Rixmap::PaletteData* _that = rixmap_unwrap<Rixmap::PaletteData>(argObject); if (*_this == *_that) { return Qtrue; } else { return Qfalse; } } else { return Qfalse; } } |
#[](argOffset) ⇒ Rixmap::Color?
パレットからカラーオブジェクトを取得します.
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 |
# File 'src/rixmapcore.cxx', line 1401 static VALUE Palette_offsetGet(VALUE self, VALUE argOffset) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); long length = static_cast<long>(_this->getSize()); // FIXME unsigned -> signed |
#[]=(argOffset, argColor)
This method returns an undefined value.
パレットのカラーオブジェクトを設定します.
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 |
# File 'src/rixmapcore.cxx', line 1429 static VALUE Palette_offsetSet(VALUE self, VALUE argOffset, VALUE argColor) { // |
#each ⇒ Enumerator #each {|color| ... }
パレットの各色を順番に走査するイテレータを返すか、各色を順にブロックに渡して走査します.
ブロックが渡された場合はカラーオブジェクト引数にブロックを呼び出します. ブロックが渡されていない場合はイテレータを返します.
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 |
# File 'src/rixmapcore.cxx', line 1497 static VALUE Palette_each(VALUE self) { if (rb_block_given_p()) { // |
#export(layout = 'RGBA') ⇒ Object
パレットをバイト列へと変換します.
1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 |
# File 'src/rixmapcore.cxx', line 1568 static VALUE Palette_export(int argc, VALUE* argv, VALUE self) { // |
#import!(data, layout = 'RGBA', range = nil) ⇒ Rixmap::Palette
バイト列データをレイアウトに従って解釈し、パレットデータを更新します.
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
# File 'src/rixmapcore.cxx', line 1618 static VALUE Palette_importSelf(int argc, VALUE* argv, VALUE self) { // |
#initialize_copy(argObject) (private)
This method returns an undefined value.
複製されたオブジェクトを初期化します.
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 |
# File 'src/rixmapcore.cxx', line 1368 static VALUE Palette_initializeCopy(VALUE self, VALUE argObject) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); Rixmap::PaletteData* _that = rixmap_unwrap<Rixmap::PaletteData>(argObject); // |
#inspect ⇒ String
オブジェクトとしての文字列表現を返します.
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 |
# File 'src/rixmapcore.cxx', line 1717 static VALUE Palette_inspect(VALUE self) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); // |
#map {|color| ... } ⇒ Rixmap::Palette
パレット内の各要素についてブロックを呼び出し、その戻り値からなる新しいパレットを返します.
1545 1546 1547 1548 |
# File 'src/rixmapcore.cxx', line 1545 static VALUE Palette_map(VALUE self) { VALUE pal = rb_obj_clone(self); return rb_funcall_passing_block(pal, rb_intern("map!"), 0, NULL); } |
#map! {|color| ... } ⇒ Rixmap::Palette
各要素についてブロックを呼び出し、その戻り値でパレットデータを破壊的に変更します.
1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
# File 'src/rixmapcore.cxx', line 1522 static VALUE Palette_mapSelf(VALUE self) { if (!rb_block_given_p()) { rb_raise(rb_eRuntimeError, "block parameter are required."); } Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); size_t size = _this->getSize(); for (size_t i = 0; i < size; i++) { VALUE color = RixmapColorPool::Get(_this->at(i)); VALUE resp = rb_yield_values(1, color); Rixmap::Helper::UpdatePalette(_this, i, resp); //rb_funcall(self, rb_intern("[]="), 2, ULONG2NUM(i), resp); } return self; } |
#size ⇒ Integer
パレットサイズを取得します.
1389 1390 1391 1392 |
# File 'src/rixmapcore.cxx', line 1389 static VALUE Palette_getSize(VALUE self) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); return ULONG2NUM(_this->getSize()); } |
#to_a ⇒ Array<Rixmap::Color>
パレットをカラーオブジェクト配列に変換します.
1473 1474 1475 1476 1477 1478 1479 1480 1481 |
# File 'src/rixmapcore.cxx', line 1473 static VALUE Palette_toArray(VALUE self) { Rixmap::PaletteData* _this = rixmap_unwrap<Rixmap::PaletteData>(self); size_t size = _this->getSize(); VALUE ary = rb_ary_new2(size); for (size_t i = 0; i < size; i++) { rb_ary_store(ary, i, RixmapColorPool::Get(_this->at(i))); } return ary; } |