bittermelon v2.0.2
Breaking changes
-
We no longer embed an increasingly outdated version of monobit.
monobithas now grown too large to embed within{bittermelon}and stay within CRAN package size limits.- Users interested in reading/writing bitmap fonts formats other than
.hexand.yafffiles
will need to manually install their own version ofmonobitusingpip3 install monobit. - The interpretation of the argument
monobit_pathinread_monobit()andwrite_monobit()
and the global optionbittermelon.monobit_pathhas been changed and now means the path
to pass tobase::Sys.which()(if the new default name"monobit-convert"is not good enough). - Any previously installed versions of
monobittorappdirs::site_config_dir("bittermelon", "monobit")orrappdirs::user_config_dir("bittermelon", "monobit")will now be ignored.
Please consider deleting them or update thebittermelon.monobit_pathoption to point to them. - The function
update_monobit()has been removed.
-
The default
colargument toas.raster.bm_bitmap()andplot.bm_bitmap()is now
getOption("bittermelon.col", col_bitmap)where the newly exported
col_bitmap = c("transparent", "black", "grey50", "grey25").
In particular by default0Lvalues will now be cast to "transparent" instead of "grey80".
To get the old behaviour setoptions("bittermelon.col" = c("grey80", "black", "grey40")). -
We no longer export a generic S3
which()method which by default callsbase::which()
and remove the specialwhich.bm_bitmap()method that first cast to a logical.
Instead now usewhich(as.logical(x))forbm_bitmap()objects. -
Many functions were upgraded to S3 generics that support more bitmap objects.
The first argument of these functions are now usuallyxinstead ofbm_object.
If specifying the first argument by name instead of positionally you'll now
need to usexinstead. -
bm_distort()is now a wrapper aroundmagick::image_resize().
x,width, andheightare now the only supported positional arguments
and theinterpolate,vp, andpng_devicearguments are no longer supported.
It now requires the suggested package{magick}. -
The default for
heightinbm_expand()is now the value ofwidthi.e.
bm_expand(x, 2L)will now double the size ofxin both directions.
To get the previous behaviour you may now need to explicitly setheight = 1L.
New features
-
bm_pixmap()creates a S3 object representing raster image pixmaps (#60).
Intended to represent pixel art / sprites but can be used
to represent more complicated raster images.
It supports the following S3 methods:-
as.matrix.bm_pixmap()andas.array.bm_pixmap() -
as.raster.bm_pixmap()andplot.bm_pixmap() -
cbind.bm_pixmap()andrbind.bm_pixmap() -
format.bm_pixmap()andprint.bm_pixmap() -
as_bm_pixmap()is a S3 method that coerces objects tobm_pixmap()objectsas_bm_pixmap.array()(e.g. from{png},{jpeg}, and{webp})as_bm_pixmap.bm_bitmap()as_bm_pixmap.default()as_bm_pixmap.glyph_bitmap()(from{fontr})as_bm_pixmap.grob()as_bm_pixmap.magick-image()(from{magick})as_bm_pixmap.matrix()as_bm_pixmap.maze()(from{mazing})as_bm_pixmap.nativeRaster()as_bm_pixmap.pattern_square()(from{gridpattern})as_bm_pixmap.pattern_weave()(from{gridpattern})as_bm_pixmap.pixeltrix()(from{pixeltrix})as_bm_pixmap.pixmapGrey()(from{pixmap})as_bm_pixmap.pixmapIndexed()(from{pixmap})as_bm_pixmap.pixmapRGB()(from{pixmap})as_bm_pixmap.raster()
-
is_bm_pixmap()returnsTRUEforbm_pixmap()objects (or subclasses)
andFALSEfor all other objects. -
Some of the "Ops" group generic operators such as
==and!=.
-
-
The following functions are now S3 generics that have methods that support (at least)
bm_bitmap()/bm_pixmap(),bm_font()/bm_list(), "magick-image", and "raster" / "nativeRaster" objects:bm_bold()bm_clamp()bm_compress()bm_distort()bm_expand()bm_extend()bm_flip()bm_glow()bm_heights()bm_mask()bm_outline()bm_overlay()bm_pad()bm_padding_lengths()bm_resize()bm_rotate()bm_shadow()bm_shift()bm_trim()bm_widths()
-
New bitmap/pixmap manipulation function:
bm_downscale()bm_gray()with aliasbm_grey()bm_invert()bm_replace()
-
Other new functions:
bm_print()andbm_format()can be used to pretty print bitmap objects to the terminal.farming_crops_16x16()returns a named list of lists
of twenty farming crops in five stages of growth plus a portrait asbm_pixmap()objects.bm_options()returns a list of (current or default)bittermelonoptions values.px_auto()determines which character vector to use for "pixels" based on
whethercli::is_utf8_output()isTRUEor not.
-
New
as_bm_bitmap()class methods:as_bm_bitmap.array()(e.g. from{png},{jpeg}, and{webp})as_bm_bitmap.bm_pixmap()as_bm_pixmap.glyph_bitmap()(from{fontr})as_bm_bitmap.magick-image()(from{magick})as_bm_bitmap.maze()coerces (from{mazing})as_bm_bitmap.nativeRaster()as_bm_bitmap.pattern_square()(from{gridpattern})as_bm_bitmap.pattern_weave()(from{gridpattern})as_bm_bitmap.pixeltrix()(from{pixeltrix})as_bm_bitmap.pixmapGrey()(from{pixmap})as_bm_bitmap.pixmapIndexed()(from{pixmap})as_bm_bitmap.pixmapRGB()(from{pixmap})as_bm_bitmap.raster()
-
New
"bm_bitmap"class S3 generics features:format.bm_bitmap()andprint.bm_bitmap()gain adownscaleargument to downscale the image
togetOption("width")(if necessary to fit in terminal).as.raster.bm_bitmap()now has anativeargument to cast to "nativeRaster" objects.as.matrix.bm_bitmap()now has afirst_row_is_topargument to flip the rows
so that the first row represents the top of the bitmap instead of the bottom.- New
as.array.bm_bitmap()function for writing bitmaps withpng::writePNG()and friends.
-
New color utilities:
col2hex()standardize color strings into a unique hex color string.col2int()andint2col()convert back and forth to (native) color integers.
-
Following
bm_list()upgrades (#69):- Can now contain
bm_bitmap(),bm_pixmap(), "magick-image", "nativeRaster", or "raster" bitmaps. as_bm_list.list()now supportsFUNfor a function which can be applied to each element of the list
such asidentity(),as_bm_bitmap(), andas_bm_pixmap().
- Can now contain
-
New package options:
- The
bittermelon.downscaleoption can be used to change the default for
thedownscaleargument informat.bm_bitmap(),print.bm_bitmap(),
format.bm_pixmap(), andprint.bm_pixmap().
- The