SwiftyDraw icon indicating copy to clipboard operation
SwiftyDraw copied to clipboard

I want to draw line with image pattern.

Open AngelDev0329 opened this issue 3 years ago • 3 comments

How are you? I am going to draw line with image pattern.

How can I do for this? Could you guide me how can I do?

Thank you.

AngelDev0329 avatar Jul 25 '21 11:07 AngelDev0329

Sorry, I'm not sure what you mean. Can you try to explain please?

LinusGeffarth avatar Jul 25 '21 16:07 LinusGeffarth

Thank you for your answer.

When draw line, you used this at 163 line of SwiftyDraw.swift file

override open func draw(_ rect: CGRect) {
    super.draw(rect)
    
    guard let context: CGContext = UIGraphicsGetCurrentContext() else { return }

    for item in drawItems {
        context.setLineCap(.round)
        context.setLineJoin(.round)
        context.setLineWidth(item.brush.width)
        context.setBlendMode(item.brush.blendMode.cgBlendMode)
        context.setAlpha(item.brush.opacity)

        if (item.isFillPath)
        {
            context.setFillColor(item.brush.color.uiColor.cgColor)
            context.addPath(item.path)
            context.fillPath()
        }
        else {
            context.setStrokeColor(item.brush.color.uiColor.cgColor)
            context.addPath(item.path)
            context.strokePath()
        }
    }
}

Then it will draw line. But I want to line using some image pattern. I didn't find any solution yet. So I need your help.

Thank you.

AngelDev0329 avatar Jul 29 '21 03:07 AngelDev0329

draw line with image pattern.

Have you found a solution to this demand?

CHPisces avatar Feb 25 '23 07:02 CHPisces