All Projects → targetcloud → TGImage

targetcloud / TGImage

Licence: MIT license
一款以最新潮的方式来使用UIImage的swift插件

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to TGImage

Qtfm
Qt File Manager
Stars: ✭ 73 (+305.56%)
Mutual labels:  imagemagick
Urxvtconfig
A graphical user interface tool for configuration of the rxvt-unicode terminal emulator.
Stars: ✭ 155 (+761.11%)
Mutual labels:  imagemagick
maptiles
Map tile generator. Converts an image into map tiles using ImageMagick. Map tiles can be used in Google Maps, Leaflet and other map rendering software.
Stars: ✭ 52 (+188.89%)
Mutual labels:  imagemagick
Pgmagick
pgmagick is a yet another boost.python based wrapper for GraphicsMagick/ImageMagick.
Stars: ✭ 100 (+455.56%)
Mutual labels:  imagemagick
Nuxt Image Loader Module
An image loader module for nuxt.js that allows you to configure image style derivatives.
Stars: ✭ 135 (+650%)
Mutual labels:  imagemagick
Googliser
a fast BASH multiple-image downloader
Stars: ✭ 202 (+1022.22%)
Mutual labels:  imagemagick
Cvpr2019
Displays all the 2019 CVPR Accepted Papers in a way that they are easy to parse.
Stars: ✭ 65 (+261.11%)
Mutual labels:  imagemagick
magick-wasm
The WASM library for ImageMagick
Stars: ✭ 259 (+1338.89%)
Mutual labels:  imagemagick
Magick.net
The .NET library for ImageMagick
Stars: ✭ 2,071 (+11405.56%)
Mutual labels:  imagemagick
Node S3 Uploader
Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
Stars: ✭ 237 (+1216.67%)
Mutual labels:  imagemagick
Maim
maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
Stars: ✭ 1,758 (+9666.67%)
Mutual labels:  imagemagick
Spacechop
HTTP service for high-level image processing with first-class Docker support.
Stars: ✭ 133 (+638.89%)
Mutual labels:  imagemagick
Grim
Tool for extracting pages from pdf as images and text as strings.
Stars: ✭ 208 (+1055.56%)
Mutual labels:  imagemagick
Imagick
Go binding to ImageMagick's MagickWand C API
Stars: ✭ 1,269 (+6950%)
Mutual labels:  imagemagick
crymagick
A crystal wrapper for ImageMagick command line.
Stars: ✭ 37 (+105.56%)
Mutual labels:  imagemagick
Optimise Images
Batch image resizer, optimiser and profiler using ImageMagick convert, OptiPNG, JpegOptim and optional ZopfliPNG, Guetzli and MozJPEG.
Stars: ✭ 64 (+255.56%)
Mutual labels:  imagemagick
Php Legofy
Transform your images as if they were made out of LEGO bricks.
Stars: ✭ 161 (+794.44%)
Mutual labels:  imagemagick
UIImageColorRatio
A tool to calculate the color ratio of UIImage in iOS.
Stars: ✭ 34 (+88.89%)
Mutual labels:  uiimage
Neural-Tile
A better tiling script for Neural-Style
Stars: ✭ 35 (+94.44%)
Mutual labels:  imagemagick
Lsix
Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
Stars: ✭ 2,635 (+14538.89%)
Mutual labels:  imagemagick

TGImage

一款以最时髦的方式来使用UIImage的swift插件

Swift Build License MIT Platform Cocoapod

Features

  • 支持链式编程
  • 支持with 和size两种开启模式
  • 支持+= 、+两种图片相加操作
  • 用例丰富、快速使用

Usage

size开启模式

UIImage.size() 或.resizable()
.color .border .corner
.image
.position
其中size开启的是固定大小模式、resizable开启的是可变大小模式
其中color支持传入渐变色,如 gradient: [.lightGray, .white], locations: [0, 1], from: CGPoint(x: 0, y: 1), to: CGPoint(x: 0, y: 0)
其中border可以设置color、width、radius、alignment
其中corner可以分别设置4个角或统一设置四个角为同一个值
其中image用于生成 UIImage
其中position用于后面+或+=时用
注意:按上面大的顺序链式编程,在size和image之间的color 、border 、corner没有顺序要求

size开启方式

UIImage.size(width: CGFloat, height: CGFloat)
UIImage.size(_ size: CGSize)
UIImage.resizable()

with CGContext开启模式

支持UIImage.with类方式开启或image.with类实例开启

类方式是返回单图,实例方式开始是在实例图的基础再加上with图,实际是两图相加模式

with开启方式

UIImage.with(width: CGFloat, height: CGFloat, block: ContextBlock)//
image.with(size: CGSize, opaque: Bool = false, scale: CGFloat = 0, block: ContextBlock)//相加
image.with(_ block: ContextBlock)//

应用场景及Demo(以下图都是用代码绘制的哦)

在cell的某角上放一个某角载剪的渐变图

在某图上再画图

多个图相加放入容器图中

1

UIImageView(image: ({ () -> UIImage in
            var container = UIImage.size(width: 180, height: 20)
                .color(.clear)
                .image
            for i in 0..<7{
                let doti = UIImage.size(width: 20, height: 20)
                    .color(gradient: [UIColor.randomColor(), UIColor.randomColor()], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(radius: 10)
                    .image
                    .position(CGPoint(x: i * 20 + (i + 1) * 3, y: 0))
                container = container + doti
            }
            return container
        })())

2

UIImageView(image: ({ () -> UIImage in
            var container = UIImage.size(width: 30, height: 120)
                .color(.clear)
                .image
            for i in 0..<4{
                let doti = UIImage.size(width: CGFloat(30 - i * 4), height: CGFloat(30 - i * 4))
                    .color(gradient: [UIColor.randomColor(), UIColor.randomColor()], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(radius: CGFloat(30 - i * 4) * 0.5)
                    .image
                    .position(CGPoint(x: i * 2, y: 30 * i + (i + 1) * 3))
                container += doti
            }
            return container
        })())

3

UIImageView(image:
            UIImage.size(width: 27, height: 27)
                .corner(radius: 13.5)
                .color(.white)
                .border(color: .lightGray)
                .border(width: 2)
                .image
                .with({ context in
                    context.setLineCap(.round)
                    UIColor.lightGray.setStroke()
                    context.setLineWidth(2)
                    context.move(to: CGPoint(x: 6, y: 12))
                    context.addLine(to: CGPoint(x: 9, y: 18))
                    context.move(to: CGPoint(x: 9, y: 18))
                    context.addLine(to: CGPoint(x: 21, y: 9))
                    context.strokePath()
                })
        )

4

UIImageView(image: UIImage.size(width: 100, height: 100)
            .color(gradient: [.green, .blue], locations: [0, 1], from: CGPoint(x: 0, y: 1), to: CGPoint(x: 0, y: 0))
            .border(gradient: [.red, .yellow], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 0))
            .border(width: 5)
            .border(alignment: .outside)
            .corner(topLeft: 20)
            .corner(topRight: 50)
            .corner(bottomLeft: 50)
            .corner(bottomRight: 20)
            .image)

5

UIImageView(image: ({ () -> UIImage in
            let background = UIImage.size(width: 120, height: 120)
                .color(gradient: [.black, .white], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 0, y: 1))
                .corner(radius: 13.5)
                .image
            let circle = UIImage.size(width: 106, height: 106)
                .color(.white)
                .corner(radius: 50)
                .image
            let center = UIImage.size(width: 8, height: 8)
                .color(.black)
                .corner(radius: 3)
                .image
            let clock = background + circle + center
            return clock.with { context in
                context.setLineCap(.round)
                UIColor.black.setStroke()
                context.setLineWidth(2)
                context.move(to: CGPoint(x: clock.size.width / 2, y: clock.size.height / 2))
                context.addLine(to: CGPoint(x: clock.size.width / 2 - 5, y: 15))
                context.move(to: CGPoint(x: clock.size.width / 2, y: clock.size.height / 2))
                context.addLine(to: CGPoint(x: clock.size.width - 25, y: clock.size.height / 2 - 3))
                context.strokePath()
                UIColor.red.setStroke()
                context.setLineWidth(1)
                context.move(to: CGPoint(x: clock.size.width / 2 + 8, y: clock.size.height / 2 - 7))
                context.addLine(to: CGPoint(x: 26, y: clock.size.height / 2 + 35))
                context.strokePath()
                UIColor.red.setFill()
                let rect = CGRect(x: clock.size.width / 2 - 1, y: clock.size.height / 2 - 1, width: 3, height: 3)
                context.fillEllipse(in: rect)
            }
        })())

6

UIImageView(image:
            ({ () -> UIImage in
                let circle = UIImage.size(width: 8, height: 8)
                    .color(.white)
                    .corner(radius: 4)
                    .image
                    .position(CGPoint(x: 5, y: 5))
                return UIImage.size(width: UIScreen.main.bounds.width*0.5, height: 44)
                    .color(gradient: [.red, .white], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(bottomRight: 20)
                    .image + circle
            })())

UIImageView(image:
            ({ () -> UIImage in
                let circle = UIImage.size(width: 8, height: 8)
                    .color(.white)
                    .corner(radius: 4)
                    .image
                    .position(CGPoint(x: UIScreen.main.bounds.width * 0.5 - 15, y: 5))
                return UIImage.size(width: UIScreen.main.bounds.width*0.5, height: 44)
                    .color(gradient: [.white, .lightGray], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(bottomLeft: 20)
                    .image + circle
            })())

UIImageView(image:
            ({ () -> UIImage in
                return UIImage.size(width: UIScreen.main.bounds.width*0.5, height: 44)
                    .color(gradient: [.white, UIColor.randomColor().withAlphaComponent(0.5)], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(topLeft: 20)
                    .image
            })())

UIImageView(image:
            ({ () -> UIImage in
                return UIImage.size(width: UIScreen.main.bounds.width*0.5, height: 22)
                    .color(gradient: [UIColor.randomColor(), .white], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(topLeft: 10)
                    .image
            })())
            
UIImageView(image:
            ({ () -> UIImage in
                return UIImage.size(width: UIScreen.main.bounds.width*0.5, height: 22)
                    .color(gradient: [.lightGray, .white], locations: [0, 1], from: CGPoint(x: 0, y: 0), to: CGPoint(x: 1, y: 1))
                    .corner(bottomLeft: 10)
                    .image
            })())

更多使用配置组合效果请download本项目或fork本项目查看

Installation

  • 下载并拖动TGImage.swift到你的工程中

  • Cocoapods

pod 'TGImage'

Reference

如果你觉得赞,请Star

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