Skip to content

Instantly share code, notes, and snippets.

View Brdjx's full-sized avatar
🏗️
Building

Bradley Jackson Brdjx

🏗️
Building
View GitHub Profile
@Brdjx
Brdjx / cors.markdown
Created September 10, 2021 17:59 — forked from Veejay/cors.markdown
Working around Javascript Canvas API CORS limitations

The problem

Manipulating images through the Javascript Canvas API is great. It allows the developer to apply powerful transformations to an image before displaying it on a web page. Despites its power, the Canvas API also has a limitation that can be extremely annoying: not respecting CORS "taints" the canvas, which severely ampers its most basic uses (see the MDN article about it)

An example of the problem

I have the URI to a Flickr photo (say the picture of a friend for example) and I want to apply a given transformation to the image before displaying it on my webpage. Two choices then:

  1. Cropping the image myself with some random Adobe tool or Picasa / Aviary / whatever
  2. Using the canvas API to do it on the fly in web page
@Brdjx
Brdjx / Widgets
Created July 26, 2020 15:35 — forked from kylehalevi/Widgets
//
// ContentView.swift
// Widgets
//
// Created by Kyle Halevi on 7/3/20.
//
import SwiftUI
struct Widget: View {