All Projects → nitin42 → react-text-fun

nitin42 / react-text-fun

Licence: other
React meets Blotter.js

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to react-text-fun

Ink
Creative coding in Go
Stars: ✭ 115 (+125.49%)
Mutual labels:  creative-coding, generative-art
Dungeontemplatelibrary
🌏: Dungeon free resources (terrain & roguelike generation)
Stars: ✭ 595 (+1066.67%)
Mutual labels:  creative-coding, generative-art
Generativeart
Generative Art in Go
Stars: ✭ 313 (+513.73%)
Mutual labels:  creative-coding, generative-art
pencil-scribbles
Create pencil effect drawings from pictures using R
Stars: ✭ 30 (-41.18%)
Mutual labels:  creative-coding, generative-art
001
draw_code.001 — ThreeJS, WebGL & GLSL
Stars: ✭ 48 (-5.88%)
Mutual labels:  creative-coding, generative-art
Artline
A Deep Learning based project for creating line art portraits.
Stars: ✭ 3,061 (+5901.96%)
Mutual labels:  creative-coding, generative-art
Glisp
A Lisp-based Design Tool Bridging Graphic Design and Computational Arts
Stars: ✭ 519 (+917.65%)
Mutual labels:  creative-coding, generative-art
gestalt
Creative coding playground - Color, Note, Code
Stars: ✭ 16 (-68.63%)
Mutual labels:  creative-coding, generative-art
Awesome Creative Coding
Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.
Stars: ✭ 8,696 (+16950.98%)
Mutual labels:  creative-coding, generative-art
Worlds2
Building Virtual Reality Worlds using Three.js
Stars: ✭ 34 (-33.33%)
Mutual labels:  creative-coding, generative-art
Urpflanze
A library for developers who want to approach to creative coding, artists who want to approach coding and for those who find it fun to play with math.
Stars: ✭ 118 (+131.37%)
Mutual labels:  creative-coding, generative-art
Watercolor Canvas
Creating watercolor-style canvas art
Stars: ✭ 84 (+64.71%)
Mutual labels:  creative-coding, generative-art
dots
Dots & Boxes Visualization
Stars: ✭ 16 (-68.63%)
Mutual labels:  creative-coding, generative-art
2d Differential Growth Experiments
Visual experiments exploring differential growth as a 2D morphogenesis tool.
Stars: ✭ 140 (+174.51%)
Mutual labels:  creative-coding, generative-art
manyworlds
A scifi-inspired study of signed distanced functions and noise fields in WebGL
Stars: ✭ 24 (-52.94%)
Mutual labels:  creative-coding, generative-art
Pts
A library for visualization and creative-coding
Stars: ✭ 4,628 (+8974.51%)
Mutual labels:  creative-coding, generative-art
GenerativeArtists
No description or website provided.
Stars: ✭ 22 (-56.86%)
Mutual labels:  creative-coding, generative-art
microbium-app
Draw new worlds
Stars: ✭ 89 (+74.51%)
Mutual labels:  creative-coding, generative-art
Curv
a language for making art using mathematics
Stars: ✭ 853 (+1572.55%)
Mutual labels:  creative-coding, generative-art
Sketches
a starting point for sketches
Stars: ✭ 66 (+29.41%)
Mutual labels:  creative-coding, generative-art

react-text-fun

React meets Blotter.js

Table of contents

Introdution

react-text-fun is a small component library that encapsulates Blotter.js shader materials in the form of React components and provides a very easy to use API.

I created react-text-fun after finding myself imperatively using the Blotter.js APIs for custom and existing materials. I decided to convert all its shader materials in the form of React components to make it easier to work with.

Hope you find it useful as well 🙂

Install

yarn add react-text-fun

This package also depends on Blotter.js so make sure you put the below script in your HTML file.

<script src="https://unpkg.com/[email protected]/build/blotter.min.js"></script>

Example

Let's take an example of distortion text material that distorts the shape of the text using various transforms

import { DistortionText } from 'react-text-fun'
import React from 'react';
import ReactDOM from 'react-dom';

const App = props => (
  <div>
    <DistortionText text="Hello wold" />
  </div>
)

// Assuming you have an element with id 'root' to which you want the component to render to.
ReactDOM.render(<App />, document.getElementById('root'))

If your example compiles successfully, you should see this output.

Cool, isn't it?

Check out the API reference for DistortionText component to see what other effects you can apply to the text.

Blotter components

Distortion Text

Distortion text is based on the Rolling Distort Material in Blotter.js.

Example

import { DistortionText } from 'react-text-fun'

<DistortionText
  text="Hello World"
  fontSize={120}
  speed={1.5}
  rotation={45.0}
  distortX={0.9}
  distortY={0.5}
  noiseAmplitude={0.8}
  noiseVolatility={1.2}
/>
Prop Description Type
speed Increase or decrease the speed of animation applied to the distortion on your text number
rotation Change the rotation of distortion effect number
distortX update the horizontal position in which the distortion effect will be applied number
distortY update the vertical position in which the distortion effect will be applied number
noiseAmplitude change the noise amplitude (amplitude of toughs and crests) number
noiseVolatility describes the overall change your text will experience number

I'll recommend reading this brilliant piece written by Josh Comeau on Waveforms. It will give you a little more idea on how and what values you should use to update the noise amplitude, and change its volatility.

Flies Text

Flies Text component is based on the FliesMaterial in Blotter.js

import { FliesText } from 'react-text-fun';

<FliesText
  cellRadius={0.5}
  text="Hello World"
  fontSize={120}
  cellWidth={0.02}
  speed={2}
  dodge={true}
  dodgeY={0.05}
  dodgeSpread={0.08}
/>
Prop Description Type
cellWidth Width of a cell number
cellRadius Radius of a cell number
speed Animation speed number
dodge whether or not to dodge cells from a position (x-axis or y-axis) boolean
dodgeX dodge position of cells around x-axis number
dodgeY dodge position of cells around y-axis number

Split color channel

Split color channel is based on ChannelSplitMaterial in Blotter.js

import { SplitColorChannelText } from 'react-text-fun';

<SplitColorChannelText
  text="Hello World"
  fontSize={120}
  rotation={5.0}
  rgbOffset={0.8}
  addBlur={false}
  addNoise={true}
/>
Prop Description Type
rotation Change the angle of rgb channel splitting number
rgbOffset Describes the distance apart the RGB values should spread number
addBlur Add blur to the text boolean
addNoise Add noise distortion to text boolean

Liquid distortion text

import { LiquidDistortionText } from 'react-text-fun';

<LiquidDistortionText
  text="Hello World"
  fontSize={120}
  speed={0.6}
  volatility={0.02}
/>
Prop Description Type
speed Speed of the animation number
volatility Describes the change in distortion of a text number

Styling text

You can use the below props with any of the above component to style the text. These are the common props.

Prop Description Type
id An unique id for the canvas string
appendTo Specify an id for an element to which the canvas should be appended string
text Text string to render string
fontFamily Set a different font type string
fontSize Set the font size number
fontWeight Set the font weight number
fill Sets the text color string
fontStyle Specify a font style (italic, normal or bold) string
lineHeight Set the line height number
paddingTop Apply top padding number
paddingBottom Apply bottom padding number
paddingLeft Apply padding on left side number
paddingRight Apply padding on right side number

Using text canvas

You can also access the canvas which renders the text using the callback function get2dContext. As the prop name suggests, the callback function receives the 2D rendering context for the drawing surface as an argument. This is useful if you want to update the canvas using any other third party library.

get2dContext can be used with any of the above material components. For instance, here is an example of how you would use it with FliesText component.

<FliesText {...props} get2dContext={ctx => console.log(ctx)} />

Live examples

You can find the live code examples for all the components on the codesandbox

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].