All Projects → peterhry → Circletype

peterhry / Circletype

Licence: mit
A JavaScript library that lets you curve type on the web.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Circletype

Shevyjs
Configurable Vertical Rhythm & Typography in CSS-in-JS
Stars: ✭ 292 (-45.52%)
Mutual labels:  typography
Sync.sketchplugin
Keep your design team in sync!
Stars: ✭ 357 (-33.4%)
Mutual labels:  typography
Moving Letters
Text animated with anime.js
Stars: ✭ 408 (-23.88%)
Mutual labels:  typography
React Native Typography
Pixel–perfect, native–looking typographic styles for React Native ✒️
Stars: ✭ 3,293 (+514.37%)
Mutual labels:  typography
Entry.css
Customizable and readable less library for Chinese text. 一个可配置的、更适合阅读的中文文章样式库
Stars: ✭ 344 (-35.82%)
Mutual labels:  typography
Theme Ui
Build consistent, themeable React apps based on constraint-based design principles
Stars: ✭ 4,150 (+674.25%)
Mutual labels:  typography
Bonmot
Beautiful, easy attributed strings in Swift
Stars: ✭ 3,182 (+493.66%)
Mutual labels:  typography
Textblock
Continuously responsive typesetting — Demo:
Stars: ✭ 536 (+0%)
Mutual labels:  typography
Otfcc
Optimized OpenType builder and inspector.
Stars: ✭ 348 (-35.07%)
Mutual labels:  typography
Prototypo
Create your own font in a few clicks
Stars: ✭ 388 (-27.61%)
Mutual labels:  typography
Osfcc
一个收集可用于中文字体排印的开源字体集合。
Stars: ✭ 314 (-41.42%)
Mutual labels:  typography
Centurion
Centurion is a web-based framework for rapid prototyping and building larger web projects.
Stars: ✭ 327 (-38.99%)
Mutual labels:  typography
Typesettings
A Sass or Stylus toolkit that sets type in Ems based on modular scale, vertical rhythm, and responsive ratio based headlines.
Stars: ✭ 380 (-29.1%)
Mutual labels:  typography
Simple Typography
A simple starting ground for beautiful typography on the web using Sass.
Stars: ✭ 311 (-41.98%)
Mutual labels:  typography
Typograf
📖 Типографика на JavaScript
Stars: ✭ 476 (-11.19%)
Mutual labels:  typography
Sketch Lint
Check the compliance of your design guidelines within seconds
Stars: ✭ 291 (-45.71%)
Mutual labels:  typography
Typography.js
A powerful toolkit for building websites with beautiful design
Stars: ✭ 3,697 (+589.74%)
Mutual labels:  typography
Qiji Font
齊伋體 - typeface from Ming Dynasty woodblock printed books
Stars: ✭ 536 (+0%)
Mutual labels:  typography
Utility Opentype
Simple, CSS utility classes for advanced typographic features.
Stars: ✭ 481 (-10.26%)
Mutual labels:  typography
Gatsby Starter Prismic
A typography-heavy & light-themed Gatsby Starter which uses the Headless CMS Prismic.
Stars: ✭ 381 (-28.92%)
Mutual labels:  typography

CircleType

Build Status

A JavaScript library that lets you curve type on the web.

Demo: https://circletype.labwire.ca

Installation

In a browser:

<script src="circletype.min.js"></script>

Using npm:

$ npm i circletype --save

Load ES module:

import CircleType from `circletype`;

API

CircleType

A CircleType instance creates a circular text element.

Kind: global class

new CircleType(elem, [splitter])

Param Type Description
elem HTMLElement A target HTML element.
[splitter] function An optional function used to split the element's text content into individual characters

Example

// Instantiate `CircleType` with an HTML element.
const circleType = new CircleType(document.getElementById('myElement'));

// Set the text radius and direction. Note: setter methods are chainable.
circleType.radius(200).dir(-1);

// Provide your own splitter function to handle emojis
// @see https://github.com/orling/grapheme-splitter
const splitter = new GraphemeSplitter()
new CircleType(
  document.getElementById('myElement'),
  splitter.splitGraphemes.bind(splitter)
);

circleType.radius(value) ⇒ CircleType

Sets the desired text radius. The minimum radius is the radius required for the text to form a complete circle. If value is less than the minimum radius, the minimum radius is used.

Kind: instance method of CircleType
Returns: CircleType - The current instance.

Param Type Description
value number A new text radius in pixels.

Example

const circleType = new CircleType(document.getElementById('myElement'));

// Set the radius to 150 pixels.
circleType.radius(150);

circleType.radius() ⇒ number

Gets the text radius in pixels. The default radius is the radius required for the text to form a complete circle.

Kind: instance method of CircleType
Returns: number - The current text radius.
Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.radius();
//=> 150

circleType.dir(value) ⇒ CircleType

Sets the text direction. 1 is clockwise, -1 is counter-clockwise.

Kind: instance method of CircleType
Returns: CircleType - The current instance.

Param Type Description
value number A new text direction.

Example

const circleType = new CircleType(document.getElementById('myElement'));

// Set the direction to counter-clockwise.
circleType.dir(-1);

// Set the direction to clockwise.
circleType.dir(1);

circleType.dir() ⇒ number

Gets the text direction. 1 is clockwise, -1 is counter-clockwise.

Kind: instance method of CircleType
Returns: number - The current text radius.
Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.dir();
//=> 1 (clockwise)

circleType.forceWidth(value) ⇒ CircleType

Sets the forceWidth option. If true the width of the arc is calculated and applied to the element as an inline style.

Kind: instance method of CircleType
Returns: CircleType - The current instance.

Param Type Description
value boolean true if the width should be set

Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.radius(384);

console.log(circleType.container);
//=> <div style="position: relative; height: 3.18275em;">...</div>

// Enable the force width option
circleType.forceWidth(true);

console.log(circleType.container);
//=> <div style="position: relative; height: 3.18275em; width: 12.7473em;">...</div>

circleType.forceWidth() ⇒ boolean

Gets the forceWidth option. If true the width of the arc is calculated and applied to the element as an inline style. Defaults to false.

Kind: instance method of CircleType
Returns: boolean - The current forceWidth value
Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.forceWidth();
//=> false

circleType.forceHeight(value) ⇒ CircleType

Sets the forceHeight option. If true the height of the arc is calculated and applied to the element as an inline style.

Kind: instance method of CircleType
Returns: CircleType - The current instance.

Param Type Description
value boolean true if the height should be set

Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.radius(384);

console.log(circleType.container);
//=> <div style="position: relative; height: 3.18275em;">...</div>

// Disable the force height option
circleType.forceHeight(false);

console.log(circleType.container);
//=> <div style="position: relative;">...</div>

circleType.forceHeight() ⇒ boolean

Gets the forceHeight option. If true the height of the arc is calculated and applied to the element as an inline style. Defaults to true.

Kind: instance method of CircleType
Returns: boolean - The current forceHeight value
Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.forceHeight();
//=> true

circleType.refresh() ⇒ CircleType

Schedules a task to recalculate the height of the element. This should be called if the font size is ever changed.

Kind: instance method of CircleType
Returns: CircleType - The current instance.
Example

const circleType = new CircleType(document.getElementById('myElement'));

circleType.refresh();

circleType.destroy() ⇒ CircleType

Removes the CircleType effect from the element, restoring it to its original state.

Kind: instance method of CircleType
Returns: CircleType - This instance.
Example

const circleType = new CircleType(document.getElementById('myElement'));

// Restore `myElement` to its original state.
circleType.destroy();

Development Commands

Command Description
npm run dev Start dev server
npm start Build for release
npm test Run unit and screenshot tests
npm run docs Generate documentation
npm run reference Generate reference screenshots
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].