Git Product home page Git Product logo

Comments (10)

d4ndo avatar d4ndo commented on August 28, 2024

Looks great.

I don't know if you are familiar with Inkscape.
https://inkscape.org/
It is the number one choice for vector graphic in the open source world.

Since Inkscape plugins are written in python. I recommend you to write a plugin or expand this one:
https://code.google.com/p/qr-code-plugins/wiki/Inkscape

Add some »dropdown list« , to choose a design.

<g id="Pattern">
            <rect x="4" y="4" width="1" height="1" fill="#000000" />
            <rect x="5" y="4" width="1" height="1" fill="#000000" />
            <rect x="6" y="4" width="1" height="1" fill="#000000" />

just replace the rect with your dot templates.

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

I used Inkscape to create my dot templates.
But now, I think to change this way
qrencode -t ascii "My test sentence" | python qrsvg.py > test_sentence_qrcode.svg
to something like
qrencode -t fsvg1 "My test sentence" -o test_sentence_qrcode.svg
where fsvg1 stands for "fancy svg model 1"
So users could directly get such svg from qrencode

I plan also to work on fancy paths instead of dots. that would be fancy svg model 2.

Your idea of inkscape module is nice too. maybe easier for me :) as the module is short and easy to update.

from libqrencode.

fukuchi avatar fukuchi commented on August 28, 2024

Hello @sballe73,

Thank you for sharing your nice work. If your script is publicly available, I'll put the URL to the web page of libqrencode (and perhaps README).

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

so far it's short in code and long in svg template :)

# beta version
# create a svg version of qrcode that fit more seamlessly when over a picture.
# usage qrencode -t ascii "my nice text to encode" | python qrsvg1.py > nice.svg
import sys

file_start="""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="fullSizePlaceHolder"
   height="fullSizePlaceHolder"
   id="svg4106"
   version="1.1"
   inkscape:version="0.48.4 r9939"
   sodipodi:docname="dot4.svg">
  <defs
     id="defs4108">
    <linearGradient
       id="linearGradientWhite">
      <stop
         style="stop-color:#ffffff;stop-opacity:1;"
         offset="0"
         id="stop5139" />
      <stop
         style="stop-color:#ffffff;stop-opacity:0.75;"
         offset="1"
         id="stop5141" />
    </linearGradient>
    <radialGradient
       inkscape:collect="always"
       xlink:href="#linearGradientWhite"
       id="radialGradientWhite"
       cx="5"
       cy="5"
       fx="5"
       fy="5"
       r="5"
       gradientUnits="userSpaceOnUse" />

    <linearGradient
       id="linearGradientBlack">
      <stop
         style="stop-color:#000000;stop-opacity:1;"
         offset="0"
         id="stop5139" />
      <stop
         style="stop-color:#500000;stop-opacity:0.85;"
         offset="1"
         id="stop5141" />
    </linearGradient>
    <radialGradient
       inkscape:collect="always"
       xlink:href="#linearGradientBlack"
       id="radialGradientBlack"
       cx="5"
       cy="5"
       fx="5"
       fy="5"
       r="5"
       gradientUnits="userSpaceOnUse" />
    <filter
       inkscape:collect="always" id="filterBlur" >
      <feGaussianBlur
         inkscape:collect="always"
         stdDeviation="0.2"
         id="feGaussianBlur" />
    </filter>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:showpageshadow="false"
     inkscape:window-maximized="0" />
  <metadata
     id="metadata4111">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Calque 1"
     inkscape:groupmode="layer"
     id="layer1">"""

file_end="""</g></svg>"""

dot_background="""<path
       style="fill:#BackgroundColorPlaceHolder;fill-opacity:0.25;fill-rule:evenodd;stroke:none;filter:url(#filterBlur)"
       d="M XYPlaceHolder
m 0,7 
c 0,0 0,0 0,0
l 0,3 
l 3,0 
c 0,0 0,0 0,0 
c 0,-1.5 -1.5,-3 -3,-3 
z "
       />
    <path
       inkscape:connector-curvature="0"
       style="fill:#BackgroundColorPlaceHolder;fill-opacity:0.25;fill-rule:evenodd;stroke:none;filter:url(#filterBlur)"
       d="M XYPlaceHolder
m 7,10
c 0,0 0,0 0,0
l 3,0
l 0,-3
c 0,0 0,0 0,0 
c -1.5,0 -3,1.5 -3,3
z"
       />
    <path
       inkscape:connector-curvature="0"
       style="fill:#BackgroundColorPlaceHolder;fill-opacity:0.25;fill-rule:evenodd;stroke:none;filter:url(#filterBlur)"
       d="M XYPlaceHolder
m 10,3 
c 0,0 0,0 0,0 
l 0,-3 
l -3,0 
c 0,0 0,0 0,0 
c 0,1.5 1.5,3 3,3 
z"
       />
    <path
       inkscape:connector-curvature="0"
       style="fill:#BackgroundColorPlaceHolder;fill-opacity:0.25;fill-rule:evenodd;stroke:none;filter:url(#filterBlur)"
       d="M XYPlaceHolder
m 3,0 c 0,0 0,0 0,0 
l -3,0
l 0,3 
c 0,0 0,0 0,0 
c 1.5,0 3,-1.5 3,-3 
z"
       />"""

dot_foreground="""<path
       style="fill:url(#radialGradientDotColorPlaceHolder);stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.7;filter:url(#filterBlur)"
       d="M XYPlaceHolder
m 0,5  
c 0,-5 1.5,2 3,-2 
c 0.5,-1.5 -0.5,-3 2,-3  
c 5,0 -2,1.5 2,3 
c 1.5,0.5 3,-0.5 3,2  
c 0,5 -1.5,-2 -3,2 
c -0.5,1.5 0.5,3 -2,3  
c -5,0 2,-1.5 -2,-3 
c -1.5,-0.5 -3,0.5 -3,-2  
z"
       inkscape:connector-curvature="0"
       sodipodi:nodetypes="sssssssss" />"""

linesize=0
linecount=0
actualY=0
for line in sys.stdin:
    linecount+=1
    if linesize==0:
        linesize=(len(line)-17)/2
        print file_start.replace("fullSizePlaceHolder",str((linesize+2)*10),2)
    if linecount>=4 and linecount<=linesize+5:
        actualX=0
        for col in range(0,linesize+2):
            if line[7+col*2:8+col*2]=="#":
                print dot_background.replace("BackgroundColorPlaceHolder","000000",4).replace("XYPlaceHolder",str(actualX*10)+","+str(actualY*10),4)
                print dot_foreground.replace("url(#radialGradientDotColorPlaceHolder)","#000000",1).replace("XYPlaceHolder",str(actualX*10)+","+str(actualY*10),1)
            else:
                print dot_background.replace("BackgroundColorPlaceHolder","ffffff",4).replace("XYPlaceHolder",str(actualX*10)+","+str(actualY*10),4)
                print dot_foreground.replace("url(#radialGradientDotColorPlaceHolder)","#ffffff",1).replace("XYPlaceHolder",str(actualX*10)+","+str(actualY*10),1)
            actualX+=1
        actualY+=1

print file_end

from libqrencode.

yPhil-gh avatar yPhil-gh commented on August 28, 2024

Very nice work indeed, @sballe73 thanks

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

Hi,
I integrated two new options in qrenc.c
The first one is the option -t fsvg1 as I wanted.
The second one is an option for ascii mode :
-A NUMBER or --ascii-plus NUMBER
that displays in ascii not ## or two spaces but only one and the second caracter is 1 or space depending of the bit comparaison between NUMBER and the value of qrcode uint for the cell.
That is not just fun but helps understand how qrcode works and make decisions when altering one in drawings.
By the way, I do not see anything happen with the bit of weight 8. And I would have been nice to distinguish data from error correction with this principle.

Do you think I can branch or push somewhere here the altered version so at some point you may check and integrate modifications in ?

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

Better late than never :)

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

Checkout the new model of fancy codes for teeshirt printing :)
teeshirt_back_magic_big

from libqrencode.

d4ndo avatar d4ndo commented on August 28, 2024

Nice. But to my opinion this does not fit the Unix philosophy.

bloatware is not the goal.

Why not write something that is compatible to qrencode!? To pipe to

qrencode -t SVG | fancysvg -shape round [..]

cheers

from libqrencode.

sballe73 avatar sballe73 commented on August 28, 2024

Because I was not satisfied with the actual SVG option, and I thought that for lambda user it would be easier to have it with the tool than having to know that somewhere there is an addon that does it in command line.

I agree that this version is slightly bloat and I would have liked to do better, but it would take more amount of time doing something that uses for example config files to do fancy things. And I had few. And again, it is really nice to have it all in the box.

Also it is really easier to do it in the code by changing the way SVG is made than converting the SVG generated after.

So here it is... maybe more GNU philosophy than Unix one ;)

If you are able to redo my work in a better way, I will gladly make next fancy SVG following your path.

from libqrencode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.