All Projects → johnsorrentino → center.js

johnsorrentino / center.js

Licence: MIT license
Center.js is a HTML5 Canvas based library that allows you to create simple text based icons, avatars, logos, and more.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to center.js

simple-icons-pdf
PDF icons for popular brands
Stars: ✭ 16 (-81.18%)
Mutual labels:  icons, logos
Assets
A collection of https://www.freeCodeCamp.org logos and other assets
Stars: ✭ 94 (+10.59%)
Mutual labels:  icons, logos
Devicon
Set of icons representing programming languages, designing & development tools
Stars: ✭ 4,536 (+5236.47%)
Mutual labels:  icons, logos
Simple Icons
SVG icons for popular brands
Stars: ✭ 12,090 (+14123.53%)
Mutual labels:  icons, logos
Browser Logos
🗂 High resolution web browser logos
Stars: ✭ 5,538 (+6415.29%)
Mutual labels:  icons, logos
Vectorlogozone
3,000+ gorgeous SVG logos, perfect for your README or credits page
Stars: ✭ 239 (+181.18%)
Mutual labels:  icons, logos
logos-api
Node.js application providing a RESTful API for searching and retrieving logos from various user-contributed sources
Stars: ✭ 21 (-75.29%)
Mutual labels:  logos
n3d1117.github.io
Cydia repo for my personal iOS tweaks: Runaway, OutOfSight and more
Stars: ✭ 28 (-67.06%)
Mutual labels:  logos
Logos-Xcode
Xcode Logos Supports
Stars: ✭ 30 (-64.71%)
Mutual labels:  logos
minidenticons
Super lightweight SVG identicon (icon avatar) generator
Stars: ✭ 89 (+4.71%)
Mutual labels:  avatars
beautified-JOSM-preset
Improved version of the JOSM presets
Stars: ✭ 38 (-55.29%)
Mutual labels:  icons
Nougat
Android notification shade for iOS
Stars: ✭ 25 (-70.59%)
Mutual labels:  logos
Facebook-instan-games-SDK
Learn how to integrate games built with JavaScript and HTML5 with Facebook instant games SDK
Stars: ✭ 59 (-30.59%)
Mutual labels:  html5-canvas
xQube
Boilerplate for realtime 3D rendering and server-side physics in HTML5 and NodeJS
Stars: ✭ 1 (-98.82%)
Mutual labels:  html5-canvas
webFaceID
Use HTML5, Go and Facebox to implement face verification on a website
Stars: ✭ 60 (-29.41%)
Mutual labels:  html5-canvas
urmusic
An application to make your own music visualizer, easily and for free!
Stars: ✭ 52 (-38.82%)
Mutual labels:  html5-canvas
image-titler
An image title generator using The Renegade Coder style
Stars: ✭ 15 (-82.35%)
Mutual labels:  logos
snake-game-2D
The famous 2D snake game in which your goal is to eat until you get huge and accumulate many points.
Stars: ✭ 18 (-78.82%)
Mutual labels:  html5-canvas
payment-logos
💳 High quality vector images for your payment solutions.
Stars: ✭ 52 (-38.82%)
Mutual labels:  logos
gopher-logos
adorable gopher logos
Stars: ✭ 106 (+24.71%)
Mutual labels:  logos

Center.js

Center.js is a HTML5 Canvas based library that allows you to create simple text based icons, avatars, logos, and more. The library assists with drawing simple shapes, centering text, and setting fonts and colors.

Why

Centering text with HTML5 canvas using textAlign and textBaseline has different behavior across browsers and fonts. Center.js removes inconsistencies by manually centering text.

Examples

yarn install
yarn examples

Avatars

Avatars 1 Avatars 2 Avatars 3 Avatars 4 Avatars 5 Avatars 6

Logos

Logos

Icons

Icons 1 Icons 2 Icons 3

Usage

The centerjs library takes a canvas object and some configuration.

centerjs({
  canvas: document.getElementById("canvas"),
  width: 64,
  height: 64,
  shape: "square",
  fontColor: "#581845",
  backgroundColor: "#DAF7A6",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Usage

Shapes

There are 3 shapes to choose from:

  • square
  • circle
  • rounded
centerjs({
  canvas: document.getElementById("square"),
  width: 64,
  height: 64,
  shape: "square",
  fontColor: "white",
  backgroundColor: "#FFC300",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Shapes Square

centerjs({
  canvas: document.getElementById("circle"),
  width: 64,
  height: 64,
  shape: "circle",
  fontColor: "white",
  backgroundColor: "#FFC300",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Shapes Circle

centerjs({
  canvas: document.getElementById("rounded"),
  width: 64,
  height: 64,
  shape: "rounded",
  fontColor: "white",
  backgroundColor: "#FFC300",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Shapes Rounded

Dimensions

The dimensions of the canvas can be controlled using the width and height attributes which are measured in pixels.

centerjs({
  canvas: document.getElementById("square"),
  width: 128,
  height: 64,
  shape: "square",
  fontColor: "white",
  backgroundColor: "#FF5733",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Dimensions 128x64

centerjs({
  canvas: document.getElementById("circle"),
  width: 128,
  height: 128,
  shape: "circle",
  fontColor: "white",
  backgroundColor: "#FF5733",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Dimensions 128x128

centerjs({
  canvas: document.getElementById("rounded"),
  width: 64,
  height: 128,
  shape: "rounded",
  fontColor: "white",
  backgroundColor: "#FF5733",
  text: "C",
  fontFamily: "Helvetica",
  fontSize: 48
});

Dimensions 64x128

Google Web Fonts

Center.js will work with standard fonts as well as Google Web Fonts. Feel free to use any Google Web Fonts you've loaded via <link> tags. If you need to load Google Web Fonts dynamically then include the Web Font loader in your application as shown below.

<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
WebFont.load({
  google: {
    families: ["Aladin"]
  },
  active: function() {
    centerjs({
      canvas: document.getElementById("google-web-fonts-1"),
      width: 256,
      height: 128,
      shape: "rounded",
      fontColor: "white",
      backgroundColor: "#C70039",
      text: "canvas",
      fontFamily: "Aladin",
      fontSize: 80
    });
  }
});

Google Web Fonts 1

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].