Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ canvas.createPNGStream() // new
canvas.syncJPEGStream() // old
canvas.createSyncJPEGStream() // old
canvas.createJPEGStream() // new

// (6) Context2d.filter has been renamed to context2d.quality to avoid a
// conflict with the new standard 'filter' property.
context.filter = 'best' // old
context.quality = 'best' // new
```

### Breaking
Expand All @@ -72,6 +77,9 @@ canvas.createJPEGStream() // new
* See also: *Correct some of the `globalCompositeOperator` types* under
**Fixed**. These changes were bug-fixes, but will break existing code relying
on the incorrect types.
* Rename `context2d.filter` to `context2d.quality` to avoid a conflict with the
new standard 'filter' property. Note that the standard 'filter' property is
not yet implemented.

### Fixed
* Fix build with SVG support enabled (#1123)
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ This project is an implementation of the Web Canvas API and implements that API
* [Canvas#createPDFStream()](#canvascreatepdfstream)
* [Canvas#toDataURL()](#canvastodataurl)
* [CanvasRenderingContext2D#patternQuality](#canvasrenderingcontext2dpatternquality)
* [CanvasRenderingContext2D#filter](#canvasrenderingcontext2dfilter)
* [CanvasRenderingContext2D#quality](#canvasrenderingcontext2dquality)
* [CanvasRenderingContext2D#textDrawingMode](#canvasrenderingcontext2dtextdrawingmode)
* [CanvasRenderingContext2D#globalCompositeOperator = 'saturate'](#canvasrenderingcontext2dglobalcompositeoperator--saturate)
* [CanvasRenderingContext2D#antialias](#canvasrenderingcontext2dantialias)
Expand Down Expand Up @@ -381,10 +381,10 @@ canvas.toDataURL('image/jpeg', quality, (err, jpeg) => { }) // spec-following; q

Defaults to `'good'`. Affects pattern (gradient, image, etc.) rendering quality.

### CanvasRenderingContext2D#filter
### CanvasRenderingContext2D#quality

> ```ts
> context.filter: 'fast'|'good'|'best'|'nearest'|'bilinear'
> context.quality: 'fast'|'good'|'best'|'nearest'|'bilinear'
> ```

Defaults to `'good'`. Like `patternQuality`, but applies to transformations affecting more than just patterns.
Expand Down
6 changes: 3 additions & 3 deletions src/CanvasRenderingContext2d.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Context2d::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
SetProtoAccessor(proto, Nan::New("shadowBlur").ToLocalChecked(), GetShadowBlur, SetShadowBlur, ctor);
SetProtoAccessor(proto, Nan::New("antialias").ToLocalChecked(), GetAntiAlias, SetAntiAlias, ctor);
SetProtoAccessor(proto, Nan::New("textDrawingMode").ToLocalChecked(), GetTextDrawingMode, SetTextDrawingMode, ctor);
SetProtoAccessor(proto, Nan::New("filter").ToLocalChecked(), GetFilter, SetFilter, ctor);
SetProtoAccessor(proto, Nan::New("quality").ToLocalChecked(), GetQuality, SetQuality, ctor);
Nan::Set(target, Nan::New("CanvasRenderingContext2d").ToLocalChecked(), ctor->GetFunction());
}

Expand Down Expand Up @@ -1569,7 +1569,7 @@ NAN_SETTER(Context2d::SetTextDrawingMode) {
* Get filter.
*/

NAN_GETTER(Context2d::GetFilter) {
NAN_GETTER(Context2d::GetQuality) {
Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
const char *filter;
switch (cairo_pattern_get_filter(cairo_get_source(context->context()))) {
Expand All @@ -1586,7 +1586,7 @@ NAN_GETTER(Context2d::GetFilter) {
* Set filter.
*/

NAN_SETTER(Context2d::SetFilter) {
NAN_SETTER(Context2d::SetQuality) {
Nan::Utf8String str(value->ToString());
Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
cairo_filter_t filter;
Expand Down
4 changes: 2 additions & 2 deletions src/CanvasRenderingContext2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Context2d: public Nan::ObjectWrap {
static NAN_GETTER(GetShadowBlur);
static NAN_GETTER(GetAntiAlias);
static NAN_GETTER(GetTextDrawingMode);
static NAN_GETTER(GetFilter);
static NAN_GETTER(GetQuality);
static NAN_SETTER(SetPatternQuality);
static NAN_SETTER(SetImageSmoothingEnabled);
static NAN_SETTER(SetGlobalCompositeOperation);
Expand All @@ -149,7 +149,7 @@ class Context2d: public Nan::ObjectWrap {
static NAN_SETTER(SetShadowBlur);
static NAN_SETTER(SetAntiAlias);
static NAN_SETTER(SetTextDrawingMode);
static NAN_SETTER(SetFilter);
static NAN_SETTER(SetQuality);
inline void setContext(cairo_t *ctx) { _context = ctx; }
inline cairo_t *context(){ return _context; }
inline Canvas *canvas(){ return _canvas; }
Expand Down