Giter Club home page Giter Club logo

canvas-2d-playground's Introduction

canvas-2d-playground

canvas-2d-playground's People

Contributors

amyfoxfn avatar

Watchers

 avatar

canvas-2d-playground's Issues

Does the behavior Browser may automatically change a user-writable property appropriately?

When the canvas.width is set, the Browser will set the CanvasRenderingContext2D.imageSmoothingEnabled to betrue automatically.

As the CanvasRenderingContext2D.imageSmoothingEnabled is a user-writable property, it look confused when user set the property to be false, and after a while found the value changed to true without explicitly notified.

This behavior is defined in W3C Specification as:

  1. Whenever the width and height content attributes are set, removed, changed, or redundantly set to the value they already have, then the user agent must perform the action from the row of the following table that corresponds to the canvas element's context mode.
  2. For context mode 2d, it should follow the steps to set bitmap dimensions to the numeric values of the width and height content attributes.
  3. the first step to set bitmap dimensions is to Reset the rendering context to its default state.
  4. And imageSmoothingEnabled is a canvas state, and its default state is true.

Although the W3C Specification has defined it. I still wonder why need to do these, reset states when set canvas.width, and especially why need to change the CanvasRenderingContext2D.imageSmoothingEnabled to be true.

How to describe the abstraction layer of CanvasRenderingContext2D briefly and to the point?

  • Path, is the core way to define shape. Only some frequently used shape provided special APIs, e.g. rect(), arc().
  • States. There are some important states in CanvasRenderingContext2D, e.g. the current path, imageSmoothingEnabled .etc.
  • Interaction between DOM Element and Canvas Path, e.g. drawFocusIfNeeded().
  • APIs with capacity of Mouse Picking, e.g. isPointInPath().
  • Styles. Some styles is highly consistent with CSS style properties, e.g. Text styles.
  • Compositing methods. e.g. CanvasRenderingContext2D.globalCompositeOperation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.