Better rendering for variable fonts

Post pobrano z: Better rendering for variable fonts

I was messing around with a variable font the other day and noticed this weird rendering issue in the latest version of Chrome where certain parts of letterforms were clipping into each other in a really weird way. Thankfully, though, Stephen Nixon has come to the rescue with a temporary hack to fix the issue which using a text-shadow on the text that’s using the variable font:

.variable-font {
  text-shadow: 0 0 0 #000; /* text color goes last here */
} 

Once you do that, you shouldn’t be able to see those weird clip marks in the letterforms anymore. Yeah, it feels pretty hacky but I’m sure this rendering bug will be fixed relatively soon. It doesn’t look like it affects other browsers, as far as I can tell.

Direct Link to ArticlePermalink

The post Better rendering for variable fonts appeared first on CSS-Tricks.

How to Create an Abstract Poster Using the Puppet Warp Tool in Adobe Photoshop

Post pobrano z: How to Create an Abstract Poster Using the Puppet Warp Tool in Adobe Photoshop

Final product image
What You’ll Be Creating

Creating posters is difficult when images are not of optimal size. Here is a trick to create an abstract poster when you either don’t have a good enough image or you want to create something outside the box!

What You Will Need

You will need the following resources in order to complete this project:

1. How to Create a Photoshop Document

Step 1

In Photoshop, go to File > New. Name the document Abstract Poster. Set the Width to 1270 px and Height to 1600 px. Set the Resolution to 72 Pixels/Inch. Click OK.

Create a new Photoshop file

Step 2

Let’s start by adding a black background. On the Layers panel, click on Create a New Fill or Adjustment Layer > Solid Color and choose black as the background.

Add a solid black color background

Step 3

Drag the Building Exterior Wall from Envato Elements by Liufuyu into the Photoshop window. Double click to unselect.

Place the building image into the file

2. How to Use the Puppet Warp Tool

Step 1

For this tutorial, we will be using the Puppet Warp tool to create an interesting abstract image. Head over to Edit > Puppet Warp. This action will apply many triangle shapes to the image. These shapes are the density in which you will be able to edit. You can change this by going to the Options bar and clicking on Density. For this tutorial, we will be using Normal, so set the Mode to Normal and Expansion to 0 px.

Use the Puppet Warp tool on the building image

Step 2

When you hover over the image, you will notice a pin with a plus sign. This will allow us to add points to the image to hold them to a specific place. Click on the top left quadrant—anywhere is fine. 

At this point, nothing will happen. In order for this to work, we need to move these pins around, so we need to place several of them. Click in the opposite direction and move the pin around. 

Create more than two points with the Puppet Warp tool to edit the image

Step 3

Now that we know how the Puppet Warp tool works, add pins on the image and move them around.

Something to remember here is that there is no right or wrong—this is an abstract poster, and pretty much anything goes! 

Create multiple points with the Puppet Warp tool and move them around

Step 4

You can edit the points after you’ve moved them around. Simply head over to the Layers panel and click on the dropdown arrow on the building layer. Double-click on the Puppet Warp layer settings and edit away!

I ended up with the image below. Press Enter when you are done to set the image.

You can edit after youve set on your image on the layers panel

3. How to Use Clipping Masks

Step 1

On the Layers panel, click Create New Fill or Adjustment Layer > Black & White. We want this layer to be applied only to the one below, so while selecting the Black and White layer, Right click > Clipping Mask. To see if this is working, check that the layer has an arrow on the left side pointing down, meaning it will only affect the layer below it.

Add a new black and white adjustment layer and create a clipping mask

Step 2

Add a new layer on the Layers panel. We want to add color blotches on the building. On the toolbar, select the Brush tool. Right click on the page, and set the Size to 300px and Hardness to 0%.

Use the following color codes to create strokes over the layer.

  • Pink: #e21efc 
  • Cyan: #11fdfb
  • Blue: #0018ff
  • Green: #11fdc3
Add a new layer and use the brush to apply different color strokes

Step 3

Set the Blending Mode of the layer with the strokes to Multiply on the Layers panel. Again, we want this layer to be applied only to the two layers below it, and we can do this with Right click > Create Clipping Mask. To see if this is working, check that the layer has an arrow on the left side pointing down, meaning it will only affect the layers below it.

Let’s group these three layers by selecting them and dragging them to the folder on the bottom of the Layers panel.

Set the new layer to multiply and create a clipping mask

Step 4

We want to create a glitchy poster, so let’s move the Group 1 folder to the right side of the page. We want it to go over the margin. Duplicate the folder by pressing Command-J and rename it to Group 2. Then place it in the opposite direction. I am placing them at different heights to add movement.

Create a folder with the layers we created and duplicate it to place on the left side of the poster

Step 5

Let’s create a line between the objects to make it appear like a glitched image. On the toolbar, select the Line Tool (U) and draw a line vertically, holding Shift to draw a straight line. Head over to the Options bar, select white for the Stroke, and set the Shape Stroke Width to 3 pt and the Width to 6 px.

Yo create a misplaced glitchy poster draw a line in between the two objects

Step 6

On the Layers panel, add a new layer and, as before, use the Brush Tool (B) and add strokes of different colors to be applied to the line.

  • Pink: #e21efc 
  • Cyan: #11fdfb
  • Blue: #0018ff
  • Green: #11fdc3

When you are done, while selecting the layer, Right click > Create Clipping Mask.

Add different color brush strokes on a new layer and create a clipping mask over the new line we created

Step 7

Let’s add some more details. Add a new layer on the layers panel; the goal for this will be to add strokes with the same colors as above, but this time they will be applied to the whole poster.

Using the Brush Tool (B), create strokes on the poster. We will edit them in the next step.

  • Pink: #e21efc 
  • Cyan: #11fdfb
  • Blue: #0018ff
  • Green: #11fdc3
Create colored strokes on a new layer again

Step 8

While selecting the layer, choose Filter > Blur > Motion Blur.

Use the Motion Blur effect on the layer we created

Step 9

Move the layer below all the grouped layers. Using the Rectangular Marquee Tool (M), select the areas you’d like to delete. I am deleting things after/before the line we created as this poster is intended to look glitchy and displaced.

Move the layer below all the grouped layers and using the Marquee Tool delete some spots

Step 10

Add a Layer Mask to the strokes layer and use the Brush Tool (B) in black to erase and soften a few spots. Set the Opacity to 80%.

Set the opacity to 80 Add a layer mask and use a black brush to soften some spots

4. How to Add Text Details

Step 1

Let’s go back to the top of the layers. Use the Text Tool (T) to add text. I used Chinese characters to add more interesting shapes to the poster: 步步高升. I used Kozuka Gothic Pr6N in 47pt size, but feel free to use any font in any language! 

I am placing this initial text on the lower right side of the stroke.

Add text details

Step 2

Let’s duplicate these letters and place them on the background. I am placing two on either side of the stroke and changing the Opacity to 15%.

Multiply the text details and resize for prominence Move them to bottom of the layers

Step 3

As before, let’s add a new layer and add color strokes to it, and we’ll also create a Clipping Mask for both of these text layers. Start by applying the strokes on one layer, duplicate it, and then move them to apply a Clipping Mask as in the steps before.

Also feel free to use black on this layer to create a “barely there” look. 

Add a new layer with color strokes and create clipping masks to the text layers

Step 4

Let’s add more text, this time with words related to metamorphosis. I added this twice: “1. denoting a change of position or condition. Metamorphosis.” I set it in RNS Sanz from Envato Elements in 25 pt. 

Duplicate the text layer above by pressing Command-J, and while selecting the duplicated layer, Right click > Rasterize Type.

Add a few more text details and duplicate Rasterize one of the text layers

Step 5

Head over to Filter > Liquify. The Liquify option window will open. Use the Forward Warp Tool and set the Tools options: Brush Size to 300, Brush Density to 10 and Brush Pressure to 60. Click OK. 

Lower both the text layer and the rasterized layer to 40% Opacity.

Liquify the rasterized text layer

Step 6

Add one more text layer with the word “meta” to the left side of the poster to add balance. Rotate the layer vertically by pressing Command-T, and hold Shift for an even rotation.

I added one more word Meta to the top left side of the poster to add balance

Step 7

Let’s add some texture to the poster. Select all of the layers on the Layers panel and duplicate them by dragging them to the Create New Layer button. This action will duplicate all the layers and will keep them selected. While they’re selected, Right click > Merge Layer. 

Let’s add some noise by going to Filter > Noise > Add Noise.

Multiply all the layers and merge them to add texture add noise to the poster

5. How to Save a File

Head over to File > Save and save the file as you would normally. 

To save a JPEG file, head over to File > Save for Web or Shift-Options-Command-S. Select the file type you want to save the document in; I am choosing JPEG and setting 100 for Quality. Under Image size, you can change the pixel size of the image if you have any size constraints. 

On the bottom left-hand side, you can see a preview of the size of the file. This is useful when there are size constraints on a website and you need to lower the quality or the size of the image. 

Click on Save… to choose the location in the new window, and then click on Save again.

Save the poster

Congratulations! You’ve Finished This Tutorial!

In this tutorial, we’ve learned how we can make an image work for an abstract poster. Today we’ve learned:

  • how to use the Puppet Warp Tool
  • how to use Clipping Masks and how to apply them to specific layers
  • how to use layer styles
  • how to use the Liquify effect to add dimension to text

If you liked this tutorial, you might like these:

Handling Errors with Error Boundary

Post pobrano z: Handling Errors with Error Boundary

Thinking and building in React involves approaching application design in chunks, or components. Each part of your application that performs an action can and should be treated as a component. In fact, React is component-based and, as Tomas Eglinkas recently wrote, we should leverage that concept and err on the side of splitting any large chunking into smaller components.

Splitting inevitably introduces component hierarchies, which are good because they bloated components and architecture. However, things can begin to get complicated when an error occurs in a child component. What happens when the whole application crashes?! Seriously, React, why do the parent and sibling components have to pay for the sins of another component? Why?

Error Boundaries

React 16 came with a lot of goodies, one of which is error boundaries. Let’s consult the documentation and break down what it says about this gem because we can use it to spot errors where they occur and resolve them faster and with less headache!

Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.

That’s a lot of jargon but, like components, we can break it down into less complex chunks.

Error boundaries are React Components

This makes a lot of sense and useful because it’s a concept we have using all along. The difference is that juice was sprayed on it to make it different from a normal component. Still, don’t forget the basic idea that error boundaries are themselves React Components!

Error boundaries catch JavaScript errors anywhere in their child component tree

In case you have forgotten how children component tree work, here is an example:

<ParentComponent>
  <FirstChild>
    <FirstChildDaughter>
    </FirstChildDaughter>
  </FirstChild>
  <SecondChild>
  </SecondChild>
</ParentComponent>

We have two parent and three child components. According to what we have learned so far about error boundaries, we can replicate the above tree to:

<ErrorBoundaryComponent>
  <ParentComponent>
    <FirstChild>
      <FirstChildDaughter>
      </FirstChildDaughter>
    </FirstChild>
    <SecondChild>
    </SecondChild>
  </ParentComponent>
</ErrorBoundaryComponent>

By wrapping the whole tree up in an ErrorBoundaryComponent, we can catch any JavaScript errors that occur in its child components. Cool, right?

Error boundaries log those errors

When errors are caught, we want boundaries errors to do something with them, preferably something to tell us about the. Developers often make use of error logging platforms to monitor errors that occur on their software. With error boundaries, we can do the same.

Error boundaries display a fallback UI

Instead of displaying the whole annoying combo of reds in different shades, you can choose a customized user interface to display when an error occurs. That can come in super handy because it allows you to tailor errors in a style that makes it easier for you to read and scan. Super cool, right?

Like me, you’ll think that this means error boundaries will catch all JavaScript errors. Sadly, that’s not true. Here are errors that they will gracefully ignore:

  • Event handlers
  • Asynchronous code (e.g. setTimeout or requestAnimationFrame callbacks)
  • Server-side rendering
  • Errors thrown in the error boundary itself (rather than its children)

componentDidCatch()

The extra juice that makes a component an error boundary is componentDidCatch() — this is a lifecycle method that works like the JavaScript catch{} block, but for components. When an error is found in a child component, the error is handled by the closest error boundary. Only class components can be error boundaries.

componentDidCatch() accepts two parameters:

  • error: This is the error that was thrown
  • info: An object which contains a trace of where the error occurred

Error Boundary In Action

Say we are working on a feature that lists locations where conferences can be held. Something like this:

See the Pen error boundary 0 by Kingsley Silas Chijioke (@kinsomicrote) on CodePen.

The application lists locations from the Location component and the individual locations are output as Location Cards. We take a little extra care to ensure the name of each location is rendered in uppercase for consistency. For this tutorial purpose, we will add an empty object to the list of locations.

class Location extends React.Component {
  state = {
    locations: [
      {
        "name": "Ojo",
        "zone": "Lagos State",
        "region": "South West"
      },
      {
        "name": "Ahiazu Mbaise",
        "zone": "Imo State",
        "region": "South East"
      },
      {
        "name": "Akoko-Edo",
        "zone": "Edo State",
        "region": "South South"
      },
      {
        "name": "Anka",
        "zone": "Zamfara State",
        "region": "North West"
      },
      {
        "name": "Akwanga",
        "zone": "Nasarawa State",
        "region": "North Central"
      },
      {
        
      }
    ]
  }
  render() {
    return (
      <div>
        <div>
          <div>
            <h2>Locations</h2>
          </div>
        </div>
        <div>
          {this.state.locations
            .map(location => 
              <LocationCard key={location.id} {...location} />
          )}
        </div>
      </div>
    )
  }
}

const LocationCard = (props) => {
  return (
    <div>
      <hr />
      <p><b>Name:</b> {props.name.toUpperCase()}</p>
      <p><b>Zone:</b> {props.zone}</p>
      <p><b>Region:</b> {props.region}</p>
      <hr />
    </div>
  )
}

const App = () => (
  <div>
     <Location />
  </div>
)

ReactDOM.render(<App />, document.getElementById("root"));

If you run this in the browser, you will see an error similar to this screenshot:

A screenshot of the Type Error providing the error message Cannot read property toUpperCase of undefined. Background color is tan and there is a block of code with a light red background indicating where the error is in the code base.

That’s not totally helpful, so let’s apply an error boundary to handle help us out. First, we’ll create an ErrorBoundary component:

class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      hasError: false,
      error: null,
      info: null
    };
  }
  componentDidCatch(error, info) {
    this.setState({
      hasError: true,
      error: error,
      info: info
    });
  }
  render() {
    if (this.state.hasError) {
      return (
        <div>
          <h1>Oops, something went wrong :(</h1>
          <p>The error: {this.state.error.toString()}</p>
          <p>Where it occured: {this.state.info.componentStack}</p>
        </div>
      );
    }
    return this.props.children;
  }
}

An initial state for hasError, error, and info is created. Then, the componentDidCatch() lifecycle method is added. If an error occurs in the constructor, render or lifecycle method of any of its children components, the hasError state will be changed to true. When this happens, the ErrorBoundary component renders and displays the error. But if there are no errors, the children of the ErrorBoundary component are rendered instead as we’d expect.

Next, we need to add both the ErrorBoundary and Location components to our main App component:

const App = () => (
  <div>
    <ErrorBoundary>
      <Location />
    </ErrorBoundary>
  </div>
)

See the Pen error boundary 2 by Kingsley Silas Chijioke (@kinsomicrote) on CodePen.

We don’t see that annoying TypeError UI anymore! Things are working!

There’s one little thing we can do to improve the app. If you check the code in the demo, you’ll see an empty object we added at the end. Is it possible to have the other credible locations render? Most definitely! Inside the Location component, we can wrap the LocationCard component with the ErrorBoundary component to scope error logging directly to the cards:

class Location extends React.Component {
  state = {
    locations: [
      {
        "name": "Ojo",
        "zone": "Lagos State",
        "region": "South West"
      },
      {
        "name": "Ahiazu Mbaise",
        "zone": "Imo State",
        "region": "South East"
      },
      {
        "name": "Akoko-Edo",
        "zone": "Edo State",
        "region": "South South"
      },
      {
        "name": "Anka",
        "zone": "Zamfara State",
        "region": "North West"
      },
      {
        "name": "Akwanga",
        "zone": "Nasarawa State",
        "region": "North Central"
      },
      {
        // Empty!
      }
    ]
  }
  render() {
    return (
      <div>
        <div>
          <div>
            <h2>Locations</h2>
          </div>
        </div>
        <div>
          {this.state.locations
            .map(location => 
            <ErrorBoundary>
              // Should render all locations, but the empty instance
              <LocationCard key={location.id} {...location} />
            </ErrorBoundary>
          )}
        </div>
      </div>
    )
  }
}

This time, the credible locations show, except the one that is empty. You can choose to wrap the whole component tree with an error boundary component once, or you can wrap different components at strategic places. The decision is up to you.

Wrapping Up

I encourage you to start making use of error boundaries in your applications. Similarly, it’s worth digging in a little deeper. For that, here are some issues in the React repo on Error Boundaries and event handles, go through them so you can see the current state of where things are at:

The post Handling Errors with Error Boundary appeared first on CSS-Tricks.

How to Create an Editable Pie Chart in Adobe Illustrator

Post pobrano z: How to Create an Editable Pie Chart in Adobe Illustrator

Final product image
What You’ll Be Creating

In the following steps, you will learn how to create an editable pie chart in Adobe Illustrator and how to easily stylize it.

First, you will learn how to create the starting pie chart using the Pie Graph Tool. Using the Direct Selection Tool and the Appearance panel along with some basic colors and effects, you will learn how to stylize the main components of your chart. Finally, you will learn how to create a simple legend and flat background.

For more inspiration on how to adjust or improve your final chart, you can find plenty of resources at GraphicRiver.

1. How to Create a New Document and Create the Starting Chart

Step 1

Hit Control-N to create a new document. Select Pixels from the Units drop-down menu, enter 850 in the width box and 980 in the height box, and then click that More Settings button. Select RGB for the Color Mode, set the Raster Effects to Screen (72 ppi), and then click Create Document.

Enable the Grid (View > Show Grid) and Snap to Grid (View > Snap to Grid). You will need a grid every 10 px, so simply go to Edit > Preferences > Guides & Grid, and enter 10 in the Gridline every box and 1 in the Subdivisions box. Try not to get discouraged by all that grid—it will make your work easier, and keep in mind that you can easily enable or disable it using the Control-„ keyboard shortcut.

You can learn more about Illustrator’s grid system in this short tutorial from Andrei Stefan: Understanding Adobe Illustrator’s Grid System.

You should also open the Info panel (Window > Info) for a live preview with the size and position of your shapes. Don’t forget to set the unit of measurement to pixels from Edit > Preferences > Units. All these options will significantly increase your work speed.

set up grid

Step 2

Focus on your toolbar and double click the Pie Graph Tool to open the Graph Type window. Enter the attributes shown in the following image and then click OK.

pie graph tool

Step 3

Make sure that the Pie Graph Tool is selected and simply click on your artboard to open the Graph window. Set both Width and Height to 450 pt, and then click OK.

Enter the data shown below and then click the Check button. Place your new graph roughly as shown in the following image.

graph

2. How to Edit the Pie Chart Components

Step 1

Pick the Direct Selection Tool (A), select only the shape highlighted in the following image, and focus on the Appearance panel (Window > Appearance).

Remove the existing stroke color and then select the fill. Set its color to R=255 G=190 B=123 and go to Effect > Distort & Transform > Transform. Drag the Move-Vertical slider to -1 px and enter 15 in the Copies box, and then click OK. Return to the Appearance panel and add a second fill using the Add New Fill button. Select it, set the color to R=255 G=223 B=153, and go to Effect > Distort & Transform > Transform. Drag the Move-Vertical slider to -15 px and click OK.

direct selection tool

Step 2

Using the Direct Selection Tool (A), select the other pie chart slices one by one. Remove the stroke color and replace the existing fill colors with the ones shown below.

change color

Step 3

Pick the Group Selection Tool and select one of the text pieces from your pie chart. Click a second time on the same piece of text to easily select all the text.

Open the Character panel (Window > Type > Character) and select the Alma Mono Heavy font. Set the Size to 25 px and change the color to white (R=255 G=255 B=255).

edit text

3. How to Stylize Your Pie Chart

Step 1

Pick the Move Tool (V), select your entire pie chart, and focus on the Appearance panel.

Add a new fill, select it, and make sure that it lies below the „Contents” section. Set the color to R=255 G=242 B=236 and go to Effect > Convert to Shape > Ellipse. Check the Absolute box, set both Width and Height to 500 px, click OK, and then go to Effect > Distort & Transform > Transform. Drag the Move-Vertical slider to 7 px, click OK, and go to Effect > Stylize > Drop Shadow. Enter the attributes shown below and click OK.

add new fill

Step 2

Make sure that your entire pie chart is still selected and keep focusing on the Appearance panel. Add a second fill, drag it below the existing fill, and select it.

Set the color to R=255 G=82 B=119, lower its Opacity to 30%, and go to Effect > Convert to Shape > Ellipse. Check the Absolute box, set both Width and Height to 440 px, click OK, and then go to Effect > Distort & Transform > Transform. Drag the Move-Vertical slider to 45 px, click OK, and go to Effect > Blur > Gaussian Blur. Enter a 15 px Radius and click OK.

gaussian blur

Step 3

Make sure that your entire pie chart is still selected and keep focusing on the Appearance panel. Add a third fill, drag it above the other two fills, and select it.

Set the color to R=255 G=82 B=119, lower its Opacity to 50%, and go to Effect > Convert to Shape > Ellipse. Check the Absolute box, set both Width and Height to 350 px, click OK, and then go to Effect > Distort & Transform > Transform. Drag the Move-Vertical slider to 35 px, click OK, and go to Effect > Blur > Gaussian Blur. Enter a 15 px Radius and click OK.

chart shadow

4. How to Create a Simple Legend

Step 1

Using the Rectangle Tool (M), create a 510 x 80 px shape, and place it as shown in the following image. Make sure that this rectangle stays selected and focus on the Appearance panel.

Select the fill, set its color to R=255 G=242 B=236, and go to Effect > Stylize > Rounded Corners. Enter a 40 px Radius, click OK, and go to Effect > Stylize > Drop Shadow. Enter the attributes shown below and click OK.

rounded rectangle

Step 2

Make sure that your rectangle stays selected and keep focusing on the Appearance panel. Add a second fill and drag it below the other one.

Set the color to R=255 G=82 B=119, lower its Opacity to 30%, and go to Effect > Stylize > Rounded Corners. Enter a 10 px Radius, click OK, and go to Effect > Distort & Transform > Transform. Enter the attributes shown below, click OK, and go to Effect > Blur > Gaussian Blur. Set the Radius to 15 px and click OK.

legend shadow

Step 3

For this step, you will need a grid every 5 px. Simply go to Edit > Preferences > Guides & Grid and enter 5 in the Gridline every box.

Pick the Ellipse Tool (L) and create a 60 px circle, and then select the Rectangle Tool (M) and create a 30 px square. Place your square as shown in the second image and fill it with R=255 G=190 B=123. Select both shapes made in this step and click the Intersect button from the Pathfinder panel (Window > Pathfinder).

pathfinder panel

Step 4

Select your quarter circle and place it as shown in the following image.

quarter circle

Step 5

Make three copies of your quarter circle. Place them as shown below and replace the yellow with the colors shown below.

change color

Step 6

Go to your Toolbar and set the fill color to R=178 G=70 B=116. Focus on the Character panel, select the Auro font, and set the size to 16 px.

Pick the Type Tool (T), click on your artboard, add the „Lemon” piece of text, and then place it as shown below. Type the other three pieces of text and place them as shown below.

type tool

Step 7

Select all four pieces of text and go to Effect > Stylize > Drop Shadow. Enter the attributes shown below and click OK.

drop shadow

5. How to Create a Simple Background

Pick the Rectangle Tool (M) and create an 870 x 1000 px shape. Fill this new rectangle with R=255 G=255 B=250, make sure that it covers your entire artboard, and send it to back (Shift-Control-[).

background

Congratulations! You’re Done!

Here is how it should look. I hope you’ve enjoyed this tutorial and can apply these techniques in your future projects. Don’t hesitate to share your final result in the comments section.

Feel free to adjust the final design and make it your own. You can find some great sources of inspiration at GraphicRiver, with interesting solutions to improve your design.

final product